Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. /*
  2. ###############################
  3. ##### UH EXTENDED INFO MASKS
  4. ###############################
  5. */
  6.  
  7. /**< Next field mask. */
  8. #define UH_NEXT_FIELD_MASK 0xC0
  9.  
  10. /**< Next field type mask. */
  11. #define UH_NEXT_FIELD_TYPE_MASK 0x20
  12.  
  13. /**< IP version mask. */
  14. #define UH_IP_VERSION_MASK 0x10
  15.  
  16. /**< IP validity mask. */
  17. #define UH_IP_VALID_MASK 0x8
  18.  
  19. /**< Frag. validity mask. */
  20. #define UH_FRAG_VALID_MASK 0x4
  21.  
  22. /**< Fragmntation mask. */
  23. #define UH_FRAGMENTATION_MASK 0x3
  24.  
  25. /*
  26. ###############################
  27. ##### UH EXTENDED INFO MASKS
  28. ###############################
  29. */
  30.  
  31. /**< Set next field to MPLS, usage: extended_info |= UH_SET_NEXT_FIELD_MPLS */
  32. #define UH_SET_NEXT_FIELD_MPLS 0x40
  33.  
  34. /**< Set next field to VLAN, usage: extended_info |= UH_SET_NEXT_FIELD_ONE_VLAN */
  35. #define UH_SET_NEXT_FIELD_ONE_VLAN 0x80
  36.  
  37. /**< Set next field to two VLANs, usage: extended_info |= UH_SET_NEXT_FIELD_TWO_VLANS */
  38. #define UH_SET_NEXT_FIELD_TWO_VLANS 0xC0
  39.  
  40. /**< Set next field to zero (unused), usage: extended_info &= UH_SET_NEXT_FIELD_UNUSED */
  41. #define UH_SET_NEXT_FIELD_UNUSED ~(1 << 0xC0)
  42.  
  43. /**< Set IP version to IPv4, usage: extended_info &= UH_SET_IP_VERSION_V4 */
  44. #define UH_SET_IP_VERSION_V4 ~(1 << 0x10)
  45.  
  46. /**< Set IP version to IPv6, usage: extended_info |= UH_SET_IP_VERSION_V6 */
  47. #define UH_SET_IP_VERSION_V6 0x10
  48.  
  49. /**< Set IP validity to true, usage: extended_info |= UH_SET_IP_VALID */
  50. #define UH_SET_IP_VALID 0x8
  51.  
  52. /**< Set IP validity to false, usage: extended_info &= UH_SET_IP_INVALID */
  53. #define UH_SET_IP_INVALID ~(1 << 0x8)
  54.  
  55. /**< Set fragmentation validity to true, usage: extended_info |= UH_SET_FRAG_VALID */
  56. #define UH_SET_FRAG_VALID 0x4
  57.  
  58. /**< Set fragmentation validity to false, usage: extended_info |= UH_SET_FRAG_INVALID */
  59. #define UH_SET_FRAG_INVALID ~(1 << 0x4)
  60.  
  61. /**
  62. * @brief Structure containing important information about packet.
  63. */
  64. struct uh_header_s {
  65. ip_addr_t src_ip; /**< Source IP address */
  66. ip_addr_t dst_ip; /**< Destination IP address */
  67. uint16_t src_port; /**< Source port */
  68. uint16_t dst_port; /**< Destination port */
  69. uint16_t octets; /**< Packet length. (without CRC) */
  70. uint8_t protocol; /**< Protocol number */
  71. uint8_t extended_info; /**< Bits: (HSB) | 00 | 0 | 0 | 0 | 0 | 00 | (LSB)
  72. Field: | next field | next field type | ip version | ip valid | frag. valid | frag. type|
  73.  
  74. next field: 0 - unsued, 1 - MPLS, 2 - (one VLAN), 3 - (two VLANs).
  75. next field type: unused
  76. ip version: 0 - IPv4, 1 - IPv6
  77. ip valid: 0 - invalid IP packet, 1 - valid
  78. fragmentation valid: 1 - fragmentation type is valid
  79. fragmentation type: 0 - mid, 1 - last, 2 - first, 3 - no fragment.
  80. */
  81. uint16_t vlanid; /**< Vlan ID */
  82. uint16_t inner_mpls_vlan; /**< Unsued. */
  83. uint8_t tcp_flags; /**< TCP flags: bit position - FIN(0), SYN(1), RST(2), PSH(3), ACK(4), URG(5), ECE(6), CWR(7) */
  84. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement