⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ls_net.h

📁 5402控制88796网卡的程序
💻 H
字号:
#ifndef word
 #define word unsigned int
#endif 
#ifndef lgwd
 #define lgwd unsigned long int
#endif
 
#define TEST_BUFF 0x4000
#define PAKET_LONG 1000

#define NCR    port0x8300
#define PSTART port0x8301
#define PSTOP  port0x8302
#define BNRY   port0x8303
#define TPSR   port0x8304
#define TBCR0  port0x8305
#define TBCR1  port0x8306
#define CPR    port0x8306
#define ISR    port0x8307
#define RSAR0  port0x8308
#define RSAR1  port0x8309
#define RBCR0  port0x830a
#define RBCR1  port0x830b
#define NRCR    port0x830c
#define NTCR    port0x830d
#define NDCR    port0x830e
#define PNIMR    port0x830f
//8019 pag1
#define PAR0   port0x8301
#define PAR1   port0x8302
#define PAR2   port0x8303
#define PAR3   port0x8304
#define PAR4   port0x8305
#define PAR5   port0x8306
#define CURR   port0x8307
#define MAR0   port0x8308
#define MAR1   port0x8309
#define MAR2   port0x830a
#define MAR3   port0x830b
#define MAR4   port0x830c
#define MAR5   port0x830d
#define MAR6   port0x830e
#define MAR7   port0x830f
// remote DMA addrress
#define DMA    port0x8310
//reset 8019
#define RESET  port0x831f
/*page 3  */             
#define CR9346 port0x8001
#define BPAGE  port0x8002
#define CONFIG0 port0x8003
#define CONFIG1 port0x8004
#define CONFIG2 port0x8005
#define CONFIG3 port0x8006  
/*AX88796l */
#define IFGS1    port0x8312
#define IFGS2    port0x8313
#define EEPROM   port0x8314
#define TEST_REG port0x8315
#define IFG      port0x8316
#define GPI      port0x8316
#define SPP      port0x8318

ioport unsigned int NCR;
ioport unsigned int PSTART; 
ioport unsigned int PSTOP;
ioport unsigned int BNRY;
ioport unsigned int TPSR;
ioport unsigned int TBCR0;
ioport unsigned int TBCR1;
ioport unsigned int ISR;
ioport unsigned int RSAR0;
ioport unsigned int RSAR1;
ioport unsigned int RBCR0;
ioport unsigned int RBCR1;
ioport unsigned int NRCR;
ioport unsigned int NTCR;
ioport unsigned int NDCR;
ioport unsigned int PNIMR;
ioport unsigned int CPR;
//8019 pag1
ioport unsigned int PAR0;
ioport unsigned int PAR1;
ioport unsigned int PAR2;
ioport unsigned int PAR3;
ioport unsigned int PAR4;
ioport unsigned int PAR5;
ioport unsigned int CURR;
ioport unsigned int MAR0;
ioport unsigned int MAR1;
ioport unsigned int MAR2;
ioport unsigned int MAR3;
ioport unsigned int MAR4;
ioport unsigned int MAR5;
ioport unsigned int MAR6;
ioport unsigned int MAR7;
/*page 2  */
ioport unsigned int  CR9346;
ioport unsigned int  BPAGE;
ioport unsigned int  CONFIG0;
ioport unsigned int  CONFIG1;
ioport unsigned int  CONFIG2;
ioport unsigned int  CONFIG3;
/*page 3  */
ioport unsigned int IFGS1;
ioport unsigned int IFGS2;
ioport unsigned int EEPROM;
ioport unsigned int TEST_REG;
ioport unsigned int IFG;
ioport unsigned int GPI;
ioport unsigned int SPP;

// remote DMA addrress
ioport unsigned int DMA;
//reset 8019
ioport unsigned int RESET;  
///define ISR constan
#define ISR_RST 0x80
#define ISR_RDC 0x40
#define ISR_CNT 0x20
#define ISR_OVW 0x10
#define ISR_TXE 0x08
#define ISR_RXE 0x04
#define ISR_PTX 0x02
#define ISR_PRX 0x01
/*  define  data type  */
//////type pake///////////////////
#define ARP  0x0608
#define IP   0x0008
#define ICMP 0x0100
#define IGMP 0x0200
#define TCP  0x0000
#define UDP  0x1100

#define ARP_REQ  0x0100
#define ARP_ACK  0x0200
#define ICMP_REQ 0x0008
#define ICMP_ACK 0x0000


/////////IP地址数据结构////////////////
typedef struct 
{word ip_address[2];     //ip地址
 word hd_address[3];     //硬件地址
}ip_table;                      
////////保存的IP地址数据结构
typedef struct
{
word sip[2];      //本机IP地址
word dip[2];   //主机IP地址
word sevip[2]; //服务器IP地址
word tip[2];      //教室终端IP地址
}ip_add_table;
////////物理层接收数据地址///////////////
typedef struct 
{
word state[2];          //网卡状态
word dhd_address[3]; //目的网卡地质
word shd_address[3]; //源网卡地质
word type;              //数据报类型
}hd_type;

///////IP数据包///////////////////////////
typedef struct 
{
word ver;              //版本(4bit).首部长度4bit(low byte)/tos
word lg;               //ip报总长度
word flag;             //标志
word off;              //分片
word ttl;              //生存时间low byte/协议类型hi byte
word sum;              //头部校验和
word sip_address[2];   //源ip地址
word dip_address[2];   //目的ip地址
}ip_type;

///////////ARP数据包结构////////////////////////////////
typedef struct 
{
word hd_type;        //硬件类型0x0001
word pr_type;        //协议类型0x0800
word pr_long;        //协议长度 4byte hd_long;        //网卡地质长度6
word option;         //操作码
word shd_address[3]; //源网卡地质
word sip_address[2]; //源ip地址
//ip_table sip;
word dhd_address[3]; //目的网卡地质
word dip_address[2]; //目的ip地址
//ip_table dip;
}arp_type;

//////////ICMP数据包结构///////////////////////////////
typedef struct 
{ word option;     //操作码
  word sum;        //校验和
  word flag;       //标识
  word sn;         //序列号
}icmp_type;

////////UDP数据包结构///////////////////////////////
typedef struct 
{
 word snumber;      //源端口号
 word dnumber;      //目的端口号
 word lg;     //UDP长度
 word sum;      //校验和
}udp_type;     
             
typedef union 
{
 udp_type udp;
 icmp_type icmp;
 }my_type;
 
typedef struct {
     ip_type ip;
     my_type pr;
 }ip_head_type;

typedef union {
ip_head_type ip_head;
arp_type  arp;
}thd_type;

typedef struct 
{
hd_type  hd;
thd_type thd;
}sum_type;             


typedef struct 
{             
word ip_address[2];
word *buff;
word lg;
word enable;
}rip_type;   
///////发送数据届共类型/////////////////
typedef struct
{         
word ip_address[2]; //发送的IP地址
word snumber;       //发送的远端口号
word dnumber;       //发送的目的端口号
}xip_type;
//////命令结构类型///////////////////////
typedef struct
{
word flag1;       //命令标志1
word flag2;       //命令标志2
word sip[2];      //发送端IP地址
word state[2];    //发送的命令
}command_type;
                     
/////////发送资源结构
typedef struct 
{
         
word save_des;       //主机已得到硬件地址
}set_type;




⌨️ 快捷键说明

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