ethernet.h
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:3k
- //#include <word.h>
- //#include <absacc.h>
- //#include <inettype.h>
- #define reg00 XBYTE[0xFF00] //reg00- 10为isa网卡接口的寄存器地址300-310;
- #define reg01 XBYTE[0xFF01]
- #define reg02 XBYTE[0xFF02]
- #define reg03 XBYTE[0xFF03]
- #define reg04 XBYTE[0xFF04]
- #define reg05 XBYTE[0xFF05]
- #define reg06 XBYTE[0xFF06]
- #define reg07 XBYTE[0xFF07]
- #define reg08 XBYTE[0xFF08]
- #define reg09 XBYTE[0xFF09]
- #define reg0a XBYTE[0xFF0A]
- #define reg0b XBYTE[0xFF0B]
- #define reg0c XBYTE[0xFF0C]
- #define reg0d XBYTE[0xFF0D]
- #define reg0e XBYTE[0xFF0E]
- #define reg0f XBYTE[0xFF0F]
- #define reg10 XBYTE[0xFF10]
- #define reg1f XBYTE[0xFF1F]
- //EtherNet
- #define MaxLenARPtable 30
- #define MaxLenTxBuf 10
- #define PINGTYPE 1
- #define UDPTYPE 2
- #define HOST 6
- #define GATEWAY 14
- #define MASK 10
- #define SNMPHOST 18
- #define MACADR 0
- //EtherNet
- void page(unsigned char pagenumber);//ne2000页选择
- void getadr(unsigned char id,unsigned char *bytes);//读取MAC地址参数
- void setadr(unsigned char id,unsigned char *bytes);//设置MAC地址参数
- void initNIC(void);//初始化网卡配置参数
- void delay_ms(unsigned char ms_number);//延时
- void rtl8019as_rst();//RTL8019AS复位
- void ne2000init();//ne2000网卡初始化
- void send_packet(union netcard *txdnet,unsigned int length);//ne2000发包子程序
- bit recv_packet(union netcard *rxdnet);//ne2000收包子程序
- void trans_pack(union netcard *txdnet,union ip_address_type destip,unsigned int length,unsigned char type);//发包至缓冲区
- void process_trans_pack();//发包缓冲区发送处理
- void arp_request(unsigned long ip_address);//ARP请求
- void arp_answer();//ARP应答
- void arp_process();//???????????????chang//ARP应答处理
- void ping_request();//????????????????????????//PING请求
- void ping_answer();//????????????????????????//PING应答
- void ping_echo();//PING应答收到后回显
- void CfgHost(WORDTABLE *WordTable);//配置主机IP
- void CfgGateway(WORDTABLE *WordTable);//配置网关IP
- void CfgMask(WORDTABLE *WordTable);//配置子网掩码
- void CfgSnmpHost(WORDTABLE *WordTable);//配置SNMP主机IP
- void PrintARPtable(WORDTABLE *WordTable);//显示ARP缓存
- void PrintConfig(WORDTABLE *WordTable);//显示配置信息
- void PingCommand(WORDTABLE *WordTable);//PING命令处理
- void make_udp(union netcard *txdnet,union ip_address_type udpdestip,unsigned char *dat,unsigned int length,unsigned int portnumber);//封装UDP包
- void UDPCommand(WORDTABLE *WordTable);//UDP命令处理
- void CfgMacAddress(WORDTABLE *WordTable);//配置MAC地址
- void ListTxBuf(WORDTABLE *WordTable);//显示发送缓冲区
- void InitArpTable(void);//初始化ARP缓存
- void InitTxBuf(void);//初始化发送缓冲区
- void process_tcp();//TCP处理
- unsigned int createipheadcrc();//生成IP包头CRC校验
- unsigned int createicmpcrc();//生成ICMP包CRC校验
- unsigned int checksum(unsigned int xdata *check,unsigned int length);//计算校验和
- unsigned int createtcpcrc();//生成TCP包CRC校验
- bit verifyipheadcrc();//对ip头进行校验,错误返回0,正确返回1
- unsigned char verifytcpcrc();//对tcp头进行校验,错误返回0,正确返回1
- bit verifyudpcrc();//对udp头进行校验,错误返回0,正确返回1
- void process_udp();//UDP处理进程
- void updatearptab(void);//更新ARP缓存
- bit findmacadr(union ip_address_type ip,union ethernet_address_type *macadr);//在ARP缓存中查找指定IP/MAC映射对
- void maincycle(void);//主循环