Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ###############################
- ##### UH EXTENDED INFO MASKS
- ###############################
- */
- /**< Next field mask. */
- #define UH_NEXT_FIELD_MASK 0xC0
- /**< Next field type mask. */
- #define UH_NEXT_FIELD_TYPE_MASK 0x20
- /**< IP version mask. */
- #define UH_IP_VERSION_MASK 0x10
- /**< IP validity mask. */
- #define UH_IP_VALID_MASK 0x8
- /**< Frag. validity mask. */
- #define UH_FRAG_VALID_MASK 0x4
- /**< Fragmntation mask. */
- #define UH_FRAGMENTATION_MASK 0x3
- /*
- ###############################
- ##### UH EXTENDED INFO MASKS
- ###############################
- */
- /**< Set next field to MPLS, usage: extended_info |= UH_SET_NEXT_FIELD_MPLS */
- #define UH_SET_NEXT_FIELD_MPLS 0x40
- /**< Set next field to VLAN, usage: extended_info |= UH_SET_NEXT_FIELD_ONE_VLAN */
- #define UH_SET_NEXT_FIELD_ONE_VLAN 0x80
- /**< Set next field to two VLANs, usage: extended_info |= UH_SET_NEXT_FIELD_TWO_VLANS */
- #define UH_SET_NEXT_FIELD_TWO_VLANS 0xC0
- /**< Set next field to zero (unused), usage: extended_info &= UH_SET_NEXT_FIELD_UNUSED */
- #define UH_SET_NEXT_FIELD_UNUSED ~(1 << 0xC0)
- /**< Set IP version to IPv4, usage: extended_info &= UH_SET_IP_VERSION_V4 */
- #define UH_SET_IP_VERSION_V4 ~(1 << 0x10)
- /**< Set IP version to IPv6, usage: extended_info |= UH_SET_IP_VERSION_V6 */
- #define UH_SET_IP_VERSION_V6 0x10
- /**< Set IP validity to true, usage: extended_info |= UH_SET_IP_VALID */
- #define UH_SET_IP_VALID 0x8
- /**< Set IP validity to false, usage: extended_info &= UH_SET_IP_INVALID */
- #define UH_SET_IP_INVALID ~(1 << 0x8)
- /**< Set fragmentation validity to true, usage: extended_info |= UH_SET_FRAG_VALID */
- #define UH_SET_FRAG_VALID 0x4
- /**< Set fragmentation validity to false, usage: extended_info |= UH_SET_FRAG_INVALID */
- #define UH_SET_FRAG_INVALID ~(1 << 0x4)
- /**
- * @brief Structure containing important information about packet.
- */
- struct uh_header_s {
- ip_addr_t src_ip; /**< Source IP address */
- ip_addr_t dst_ip; /**< Destination IP address */
- uint16_t src_port; /**< Source port */
- uint16_t dst_port; /**< Destination port */
- uint16_t octets; /**< Packet length. (without CRC) */
- uint8_t protocol; /**< Protocol number */
- uint8_t extended_info; /**< Bits: (HSB) | 00 | 0 | 0 | 0 | 0 | 00 | (LSB)
- Field: | next field | next field type | ip version | ip valid | frag. valid | frag. type|
- next field: 0 - unsued, 1 - MPLS, 2 - (one VLAN), 3 - (two VLANs).
- next field type: unused
- ip version: 0 - IPv4, 1 - IPv6
- ip valid: 0 - invalid IP packet, 1 - valid
- fragmentation valid: 1 - fragmentation type is valid
- fragmentation type: 0 - mid, 1 - last, 2 - first, 3 - no fragment.
- */
- uint16_t vlanid; /**< Vlan ID */
- uint16_t inner_mpls_vlan; /**< Unsued. */
- uint8_t tcp_flags; /**< TCP flags: bit position - FIN(0), SYN(1), RST(2), PSH(3), ACK(4), URG(5), ECE(6), CWR(7) */
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement