ip.h

来自「包括EPA协议栈」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef _IP_H
#define _IP_H

#include "global.h"

#ifdef IP_GLOBALS
	#define IP_EXTERN
#else
	#define IP_EXTERN extern
#endif	// IP_GLOBAL

#define ICMP_PROTOCOL (0x01)
#define IGMP_PROTOCOL (0x02)
#define TCP_PROTOCOL (0x06)
#define UDP_PROTOCOL (0x11)

typedef struct {
	uint8 version;
	uint8 services;
	uint16 length;
	uint16 identification;
	uint16 fragment;
	uint8 livetime;
	uint8 protocol;
	uint16 checksum;
	uint32 srcip;
	uint32 dstip;
} IPHeader, *PIPHeader;

/*------------------------------------------------------------------------------*
 *- Function name: inetaddr                                                    -*
 *- Parameter: a, 1st octet of ip address                                      -*
 *-            b, 2nd octet of ip address                                      -*
 *-            c, 3rd octet of ip address                                      -*
 *-            d, 4th octet of ip address                                      -*
 *- Return value: An ip address of 32 bit width number                         -*
 *- Brief: Compose 4 octect into a 32 bit ip address                           -*
 *------------------------------------------------------------------------------*/
__inline uint32 inetaddr(uint8 a, uint8 b, uint8 c, uint8 d) {
	return ((uint32)a << 24 |(uint32)b << 16 | (uint32)c << 8 | d);
}

uint8 IPInput(PInSock pisock);

uint8 IPOutput(POutSock posock, uint8 protocol);

uint16 ChkSum(uint8* payload, uint16 length);

#endif	// _IP_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?