ip.h 736 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <assert.h>
  8. #include <bits/stdint.h>
  9. #include <sys/cdefs.h>
  10. #include "in.h"
  11. __BEGIN_DECLS
  12. struct ip {
  13. #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  14. uint8_t ip_v : 4;
  15. uint8_t ip_hl : 4;
  16. #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  17. uint8_t ip_hl : 4;
  18. uint8_t ip_v : 4;
  19. #endif
  20. uint8_t ip_tos;
  21. uint16_t ip_len;
  22. uint16_t ip_id;
  23. uint16_t ip_off;
  24. uint8_t ip_ttl;
  25. uint8_t ip_p;
  26. uint16_t ip_sum;
  27. struct in_addr ip_src;
  28. struct in_addr ip_dst;
  29. } __attribute__((packed));
  30. static_assert(sizeof(struct ip) == 20, "struct ip: invalid length");
  31. __END_DECLS