59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
// -------------------------------------------------------------------------
|
|
// ipv4.h
|
|
//
|
|
// 21.12.2003, J. Ahrensfeld
|
|
//
|
|
// -------------------------------------------------------------------------
|
|
#ifndef IPV4_H
|
|
#define IPV4_H
|
|
|
|
#include "libsys.h"
|
|
#include "ethernet.h"
|
|
|
|
// -------------------------------------------------------------------------
|
|
typedef struct _sIPV4
|
|
{
|
|
uint8_t ver_ihl;
|
|
uint8_t tos;
|
|
uint16_t len;
|
|
uint16_t id;
|
|
uint16_t flag_foff;
|
|
uint8_t ttl;
|
|
uint8_t proto;
|
|
uint16_t hdr_chksum;
|
|
uint8_t inet_addr_src[4];
|
|
uint8_t inet_addr_dst[4];
|
|
|
|
} __attribute__ ((__packed__)) IPV4;
|
|
|
|
#define IP_TYPE_ICMP 0x01
|
|
#define IP_TYPE_TCP 0x06
|
|
#define IP_TYPE_UDP 0x11
|
|
|
|
#define IPV4_AMSK_PRECEDENCE 0x07
|
|
#define IPV4_TOS_LOW_DELAY 0x08
|
|
#define IPV4_TOS_HIGH_THRUPUT 0x10
|
|
#define IPV4_TOS_HIGH_REL 0x20
|
|
#define IPV4_AMSK_FLAG 0xE000
|
|
#define IPV4_AMSK_FOFF 0x1FFF
|
|
#define IPV4_FLAG_RES 0x8000
|
|
#define IPV4_FLAG_DF 0x4000
|
|
#define IPV4_FLAG_MF 0x2000
|
|
|
|
|
|
#define IPV4_PRECENCE_NETWORK_CTRL 0x07 // 111 - Network Control
|
|
#define IPV4_PRECENCE_INTERNET_CTRL 0x06 // 110 - Internetwork Control
|
|
#define IPV4_PRECENCE_CRITIC_ECP 0x05 // 101 - CRITIC/ECP
|
|
#define IPV4_PRECENCE_FLASH_OVERRIDE 0x04 // 100 - Flash Override
|
|
#define IPV4_PRECENCE_FLASH 0x03 // 011 - Flash
|
|
#define IPV4_PRECENCE_IMMEDIATE 0x02 // 010 - Immediate
|
|
#define IPV4_PRECENCE_PRIORITY 0x01 // 001 - Priority
|
|
#define IPV4_PRECENCE_ROUTINE 0x00 // 000 - Routine
|
|
|
|
// -------------------------------------------------------------------------
|
|
uint16_t IPv4ChkSum(uint16_t *pBuf, uint16_t acc, uint16_t len);
|
|
uint8_t *IPV4_create(packet_t *pPacket, uint16_t proto, uint16_t len, uint8_t *inet_addr_src, uint8_t *inet_addr_dst);
|
|
|
|
// -------------------------------------------------------------------------
|
|
#endif // IPV4_H
|