?? globals.h
字號(hào):
//延時(shí)常數(shù)定義
#define TRUE 1
#define FALSE 0
#define SPACE 0x20
#define DY1MS 228
#define DY10MS 2288
#define DY100MS 22893
#define DY200MS 45788
#define MAXBUF 1500
//以太網(wǎng)幀類型
#define IP_PACKET 0x0800
#define ARP_PACKET 0x0806
#define RARP_PACKET 0x8035
//端口
#define ECHO_PORT 7
#define DAYTIME_PORT 13
#define CHARGEN_PORT 19
#define TIME_PORT 37
#define HTTP_PORT 80
#define CUSTOM_PORT 2518
//IP包協(xié)議類型
#define ICMP_TYPE 1
#define IGMP_TYPE 2
#define TCP_TYPE 6
#define UDP_TYPE 17
#define CACHESIZE 5
#define NULL ((void *) 0L)
#define CP (uchar *)
#ifdef OSCAR_DEBUG
#define TRACE(a, b, c, d) print(a,b,c,d)
#else
#define TRACE(a, b, c, d)
#endif
/*************************************************************************
數(shù)據(jù)類型定義
***************************************************************************/
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef struct
{
uchar dest_macaddr[6];
uchar source_macaddr[6];
uint frame_type;
} Eth_Header;
//ARP消息類型
typedef enum
{
ARP_REQUEST = 1, // ARP請(qǐng)求
ARP_RESPONSE = 2, // ARP應(yīng)答
RARP_REQUEST = 3, // RARP請(qǐng)求
RARP_RESPONSE = 4
} ArpMsg_Type;
typedef struct
{
uint hardware_type;
uint protocol_type;
uchar macaddr_len;
uchar ipaddr_len;
uint message_type;
uchar source_macaddr[6];
ulong source_ipaddr;
uchar dest_macaddr[6];
ulong dest_ipaddr;
} Arp_Header;
//ARP緩存
typedef struct
{
ulong ipaddr;
uchar macaddr[6];
uchar timer;
uchar type;
} Arp_Cache;
typedef struct
{
uchar xdata * buf;
ulong ipaddr;
uchar proto_id;
uint len;
uchar timer;
} Arp_Wait;
typedef struct
{
uchar ver_len;
uchar tos;
uint total_len;
uint id;
uint fragment_info;
uchar ttl;
uchar protocol_id;
uint hd_cksum;
ulong source_ipaddr;
ulong dest_ipaddr;
} Ip_Header;
typedef struct
{
uint source_port;
uint dest_port;
uint len;
uint checksum;
uchar msg_data;
} Udp_Header;
typedef struct
{
uchar msg_type;
uchar msg_code;
uint checksum;
uint identifier;
uint sequence;
uchar echo_data;
} Ping_Header;
typedef struct
{
uchar msg_type;
uchar msg_code;
uint checksum;
ulong msg_data;
uchar echo_data;
} Icmp_Err_Header;
typedef struct
{
uint source_port;
uint dest_port;
ulong sn;
ulong ack_sn;
uint flags;
uint window;
uint checksum;
uint urgent_ptr;
uchar options;
} Tcp_Header;
typedef struct
{
ulong ipaddr;
uint port;
ulong his_sn;
ulong my_sn;
ulong old_sn;
ulong his_ack;
uchar timer;
uchar inactivity;
uchar state;
char query[20];
} TCB;
/*************************************************************************
全局變量
***************************************************************************/
#ifdef GLOBALS
#define GEXT
#else
#define GEXT extern
#endif
GEXT uchar xdata outbuf[MAXBUF];
GEXT uchar xdata inbuf[MAXBUF];
GEXT uchar xdata bakbuf[MAXBUF];
// GEXT uchar xdata urxbuf[MAXBUF];
GEXT uchar xdata urxbuf[200];
GEXT Arp_Wait wait;
GEXT uchar waiting_for_arp;
GEXT Arp_Cache idata arp_cache[CACHESIZE];
GEXT ulong myipaddr;
GEXT ulong mysubnet;
GEXT ulong mygateway;
GEXT uchar mymac[6];
/*************************************************************************
函數(shù)列表
***************************************************************************/
void delay_us(uint us);
void clean_buf(uchar *buf,uint len);
uint cksum(uchar *check,uint len);
uchar * strfind(uchar * s1, uchar * set);
itoa(uint value, char * buf, uchar radix);
void replace_tag(uchar * start, char * tag, char * sub,unsigned char Replacelength);
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -