?? ne2000.h.bak
字號:
/*==============================================*/
// CP220X net packet define
/*==============================================*/
#ifndef _ne2000_h_
#define _ne2000_h_
typedef unsigned char INT8U;
typedef unsigned int INT16U;
typedef unsigned long INT32U;
struct net_node // 本機(jī)節(jié)點信息
{
INT32U ip; // IP地址
INT32U mask; // 子網(wǎng)掩碼
INT32U gate; // 網(wǎng)關(guān)
INT16U port; // 端口號
INT8U mac[6]; // 以太網(wǎng)地址
};
struct net_nodebytes
{
INT8U ipbytes[4];
INT8U maskbytes[4];
INT8U gatebytes[4];
INT8U portbytes[2];
INT16U macwords[3];
};
union NetNode{
struct net_node node;
struct net_nodebytes nodebytes;
};
#define IP4_ADDR(a,b,c,d) ((INT32U)(a & 0xff) << 24) | ((INT32U)(b & 0xff) << 16) | \
((INT32U)(c & 0xff) << 8) | (INT32U)(d & 0xff)
union ethernet_address_type{
INT16U words[3];
INT8U bytes[6];
};
union ip_address_type{
INT32U dwords;
INT16U words[2];
INT8U bytes[4];
};
union arp_table_type{
INT8U bytes[12];
INT16U words[6];
struct{
INT8U status;
INT8U ttl;
union ip_address_type ip_address;
union ethernet_address_type ethernet_address;
}arp; //狀態(tài),生存時間,ip地址,以太網(wǎng)地址
}; //12
//以太網(wǎng)幀
struct ethernet{
//INT8U status; //接收狀態(tài) 0
//INT8U nextpage; //下一個頁1
//INT16U length; //以太網(wǎng)長度,以字節(jié)為單位 2-3
INT8U destnodeid[6]; //目的網(wǎng)卡地址4-9
INT8U sourcenodeid[6]; //源網(wǎng)卡地址10-15
INT16U protocal; //下一層協(xié)議 16-17
INT8U packet[300]; //包的內(nèi)容 18-318
}; //318
typedef struct{
//INT8U status; //接收狀態(tài) 0
//INT8U nextpage; //下一個頁1
//INT16U length; //以太網(wǎng)長度,以字節(jié)為單位 2-3
INT8U destnodeid[6]; //目的網(wǎng)卡地址4-9
INT8U sourcenodeid[6]; //源網(wǎng)卡地址10-15
INT16U protocal; //下一層協(xié)議 16-17
//INT8U packet[300]; //包的內(nèi)容 18-318
}ethernet_head; //318
struct ip{
INT16U head[7]; //以太網(wǎng)包頭 18 0-17
INT8U verandihl; //版本與頭長度 1
INT8U typeofserver; //服務(wù)類型 1
INT16U totallength; //總長度 2
INT16U frameindex; //IP幀序號 2
INT16U segment; //分段標(biāo)志 2
INT8U ttl; //生存時間 1
INT8U protocal; //下一層協(xié)議 1
INT16U crc; //校驗和 2
INT8U sourceip[4]; //源IP 4
INT8U destip[4]; //目的IP 4
INT8U packet[280]; //IP包的內(nèi)容 280
}; //318
typedef struct{
//INT16U head[7]; //以太網(wǎng)包頭 18 0-17
INT8U verandihl; //版本與頭長度 1
INT8U typeofserver; //服務(wù)類型 1
INT16U totallength; //總長度 2
INT16U frameindex; //IP幀序號 2
INT16U segment; //分段標(biāo)志 2
INT8U ttl; //生存時間 1
INT8U protocal; //下一層協(xié)議 1
INT16U crc; //校驗和 2
INT8U sourceip[4]; //源IP 4
INT8U destip[4]; //目的IP 4
//INT8U packet[280]; //IP包的內(nèi)容 280
}ip_head;
struct ippacket{
INT16U head[7]; //以太網(wǎng)包頭
INT8U ippacket[300]; //IP包的內(nèi)容
};
struct arp{ //arp報文的內(nèi)容總長28字節(jié)
INT16U head[7]; //以太網(wǎng)頭 0-13
INT16U harewaretype; //以太網(wǎng)為0x0001 14-15
INT16U protocaltype; //ip 為0X0800 16-17
INT8U halength; //=0X06 18
INT8U palength; //=0X041 19
INT16U operation; //操作 20-21 2 0X0001為請求 0X0002為應(yīng)答 0X0003為反向地址請求 0X0004為反向地址應(yīng)答
INT8U sourcenodeid[6]; //源網(wǎng)卡地址 22-27
INT8U sourceip[4]; //源IP地址4 28-31
INT8U destnodeid[6]; //目的網(wǎng)卡地址6 32-37
INT8U destip[4]; //目的IP地址4 38-41
};
typedef struct{ //arp報文的內(nèi)容總長28字節(jié)
//INT16U head[7]; //以太網(wǎng)頭 18
INT16U harewaretype; //以太網(wǎng)為0x0001 0-1
INT16U protocaltype; //ip 為0X0800 2-3
INT8U halength; //=0X06 4
INT8U palength; //=0X041 5
INT16U operation; //操作 2 0X0001為請求 0X0002為應(yīng)答 0X0003為反向地址請求 0X0004為反向地址應(yīng)答 6-7
INT8U sourcenodeid[6]; //源網(wǎng)卡地址6 8-13
INT8U sourceip[4]; //源IP地址4 14-17
INT8U destnodeid[6]; //目的網(wǎng)卡地址6 18-23
INT8U destip[4]; //目的IP地址4 24-27
}arp_head;
struct icmp{ //包含在IP包中,是IP的上層為0X01的應(yīng)用
INT16U head[7]; //以太網(wǎng)頭0-13
INT16U iphead[10]; //IP頭14-33
INT8U type; //0X08 PING請求 0X00 PING應(yīng)答42 34
INT8U option; //0X00 PING 35
INT16U crc; //36-37
INT16U id; //38-39
INT16U seq; //40-41
INT8U icmpdata[272];
}; //318
typedef struct{ //包含在IP包中,是IP的上層為0X01的應(yīng)用
//INT16U head[7]; //以太網(wǎng)頭0-13
//INT16U iphead[10]; //IP頭14-41
INT8U type; //0X08 PING請求 0X00 PING應(yīng)答42 0
INT8U option; //0X00 PING 1
INT16U crc; //2-3
INT16U id; //4-5
INT16U seq; //6-7
//INT8U icmpdata[272];
}icmp_head; //318
struct tcp{
INT16U head[7]; //18
INT16U iphead[10];//20
INT16U sourceport; //2 //源端口
INT16U destport; //2 //目的端口
INT16U seqnumberH; //2 //順序號
INT16U seqnumberL; //2
INT16U acknumberH; //2
INT16U acknumberL; //2 //確認(rèn)號
INT8U offset; //1 //數(shù)據(jù)偏移量
INT8U control; //1 //連接控制
INT16U window; //2 //流控
INT16U crc; //2 //校驗和 ,包括偽頭部,TCP頭部,數(shù)據(jù)
INT16U urg; //2 //緊急指針
INT8U tcpdata[260]; //TCP數(shù)據(jù)
}; //318
struct udp{
INT16U head[7]; //18 以太網(wǎng)頭 0-17
INT16U iphead[10]; //20 IP報頭 18-37
INT16U sourceport; //2 //源端口38-39
INT16U destport; //2 //目的端口4
INT16U length; //2
INT16U crc; //2 //校驗和 ,包括偽頭部,udp頭部,數(shù)據(jù)
INT8U udpdata[272]; //udp數(shù)據(jù)
}; //318
typedef struct{
//INT16U head[7]; //18 以太網(wǎng)頭 0-17
//INT16U iphead[10]; //20 IP報頭 18-37
INT16U sourceport; //2 //源端口38-39
INT16U destport; //2 //目的端口4
INT16U length; //2
INT16U crc; //2 //校驗和 ,包括偽頭部,udp頭部,數(shù)據(jù)
//INT8U udpdata[272]; //udp數(shù)據(jù)
}udp_head; //318
struct tftprw{
INT16U head[9]; //18
INT16U iphead[10]; //20
INT16U udphead[4]; //8
INT16U opencode; //2 // 讀寫代碼標(biāo)志
INT8U fileandmode[270]; // 文件名和操作類型
};// 318
struct tftpd{
INT16U head[7]; //18
INT16U iphead[10]; //20
INT16U udphead[4]; //8
INT16U opencode; //2 讀寫代碼標(biāo)志
INT16U number; //2 塊編號或者差錯碼
INT8U tftpdata[268]; // 數(shù)據(jù)或者差錯信息
}; //318
struct bytes{
INT8U bytebuf[336];
}; //336
//所有協(xié)議的共用體
typedef union {
struct bytes bytedata;
struct ethernet etherframe;
struct arp arpframe;
struct icmp icmpframe;
struct tcp tcpframe;
struct ip ipframe;
struct udp udpframe;
struct ippacket ippacket;
struct tftprw tftprwframe;
struct tftpd tftpdataframe;
} netcard;
typedef struct
{
union ip_address_type ipaddr;
union ip_address_type his_sequence;
union ip_address_type my_sequence;
union ip_address_type old_sequence;
union ip_address_type his_ack;
INT16U port;
INT8U timer;
INT8U inactivity;
INT8U state;
INT8U query[23];
}tcpconnection;
typedef struct
{
INT8U xdata * buf;
INT32U ipaddr;
INT8U proto_id;
INT16U len;
} WAIT;
#define IP_PACKET 0x0800 // 0x0008
#define ARP_PACKET 0x0806 //0x0608
#define RARP_PACKET 0x8035 //0x3580
#define MaxLenARPtable 0x02
#endif
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -