ipv4.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2012 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef _IPV4__H_
  27. #define _IPV4__H_
  28. #if defined(ATH_TARGET)
  29. #include <osapi.h> /* A_UINT8 */
  30. #else
  31. #include <a_types.h> /* A_UINT8 */
  32. #endif
  33. #define IPV4_ADDR_LEN 4 /* bytes */
  34. struct ipv4_hdr_t {
  35. A_UINT8 ver_hdrlen; /* version and hdr length */
  36. A_UINT8 tos; /* type of service */
  37. A_UINT8 len[2]; /* total length */
  38. A_UINT8 id[2];
  39. A_UINT8 flags_fragoff[2]; /* flags and fragment offset field */
  40. A_UINT8 ttl; /* time to live */
  41. A_UINT8 protocol;
  42. A_UINT8 hdr_checksum[2];
  43. A_UINT8 src_addr[IPV4_ADDR_LEN];
  44. A_UINT8 dst_addr[IPV4_ADDR_LEN];
  45. };
  46. #define IPV4_HDR_LEN (sizeof(struct ipv4_hdr_t))
  47. #define IPV4_HDR_OFFSET_PROTOCOL (offsetof(struct ipv4_hdr_t, protocol))
  48. #define IPV4_HDR_OFFSET_DST_ADDR (offsetof(struct ipv4_hdr_t, dst_addr[0]))
  49. #endif /* _IPV4__H_ */