44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
#ifndef ETHERLIB_IPV4_PACKET_H
|
|
#define ETHERLIB_IPV4_PACKET_H
|
|
|
|
#include <stdint.h>
|
|
#include "etherlib/packet_registry.h"
|
|
|
|
#define ETH_IPv4_PACKET_CLASS (0x0800)
|
|
|
|
// IPv4 fejlécet leíró struktúra
|
|
typedef struct {
|
|
PcktPropsHeader
|
|
|
|
// 1. 32-bit
|
|
uint8_t IHL; ///< header size
|
|
uint8_t Version; ///< version (always 4)
|
|
uint8_t DSF; ///< service type
|
|
uint16_t TotalLength; ///< total packet length
|
|
|
|
// 2. 32-bit
|
|
uint16_t Identification; ///< identification
|
|
uint8_t Flags; ///< packet flags
|
|
uint16_t FragmentOffset; ///< packet fragmentation offset
|
|
|
|
// 3. 32-bit
|
|
uint8_t TTL; // Time-To-Live
|
|
uint8_t Protocol; ///< Protocol
|
|
uint16_t HeaderChecksum; ///< header IP-checksum
|
|
|
|
// 4. 32-bit
|
|
uint32_t SourceIPAddr; ///< source IP-address
|
|
uint32_t DestIPAddr; ///< destination IP-address
|
|
} IPv4Props;
|
|
|
|
/**
|
|
* Parse raw IPv4 packets.
|
|
* @param hdr pointer to the IPv4 packet header
|
|
* @param size total packet size
|
|
* @param props pointer to property storage
|
|
* @return Protocol on success or -1 on failure
|
|
*/
|
|
int parse_ipv4(const uint8_t *hdr, uint32_t size, PcktProps * props);
|
|
|
|
#endif //ETHERLIB_IPV4_PACKET_H
|