📄 tinyip.h
字号:
} FTPCommand;
enum {
TOK_ABOR, /* TOK_BYE, */ TOK_QUIT,
TOK_PORT, TOK_USER, TOK_PASS,
TOK_HELP, /* TOK_SYST, */ TOK_PASV,
/* TOK_PASW, TOK_NLST, TOK_LIST, */
TOK_STOR, TOK_TYPE, TOK_RETR,
TOK_MEDIA, TOK_GETENV, TOK_SETENV,
TOK_UNSETENV, TOK_FIXENV, TOK_PRINTENV, TOK_REBOOT, TOK_ERROR
};
enum {
STATUS_NONE, STATUS_WELCOME,
STATUS_IDLE, STATUS_LOGIN,
STATUS_PASSIVE, STATUS_ACTIVE,
STATUS_LIST, STATUS_UPLOAD,
STATUS_DOWNLOAD
};
enum {
// MEDIA_NONE,
MEDIA_FLASH,
MEDIA_SDRAM
};
enum {
TYPE_NONE,
TYPE_BINARY,
TYPE_ASCII
};
#endif /* FTP_SERVER_SUPPORT */
typedef struct icmp_unused
{
UINT8 type;
UINT8 code;
word checksum;
longword unused;
in_Header ip;
UINT8 spares[8];
} icmp_unused;
typedef struct icmp_pointer
{
UINT8 type;
UINT8 code;
word checksum;
UINT8 pointer;
UINT8 unused[3];
in_Header ip;
} icmp_pointer;
typedef struct icmp_ip
{
UINT8 type;
UINT8 code;
word checksum;
longword ipaddr;
in_Header ip;
} icmp_ip ;
typedef struct icmp_echo
{
UINT8 type;
UINT8 code;
word checksum;
word identifier;
word sequence;
} icmp_echo;
typedef struct icmp_timestamp
{
UINT8 type;
UINT8 code;
word checksum;
word identifier;
word sequence;
longword original; /* original timestamp */
longword receive; /* receive timestamp */
longword transmit; /* transmit timestamp */
} icmp_timestamp;
typedef struct icmp_info
{
UINT8 type;
UINT8 code;
word checksum;
word identifier;
word sequence;
} icmp_info;
typedef union
{
struct icmp_unused unused;
struct icmp_pointer pointer;
struct icmp_ip ip;
struct icmp_echo echo;
struct icmp_timestamp timestamp;
struct icmp_info info;
} icmp_pkt;
typedef struct _pkt
{
in_Header in;
icmp_pkt icmp;
byte data[icmp_MaxBufSize];
} _pkt;
#define ICMPTYPE_ECHOREPLY 0
#define ICMPTYPE_UNREACHABLE 3
#define ICMPTYPE_TIMEEXCEEDED 11
typedef enum ICMP_UnreachableCodes
{
ICMP_UNREACH_NET = 0,
ICMP_UNREACH_HOST = 1,
ICMP_UNREACH_PROTO = 2,
ICMP_UNREACH_PORT = 3,
ICMP_UNREACH_FRAGNEEDED = 4,
ICMP_UNREACH_SRCROUTEFAILED = 5
} ICMP_UnreachableCodes;
typedef enum ICMP_TimeExceededCodes
{
ICMP_EXCEEDED_TTL = 0,
ICMP_EXCEEDED_FRAGREASM = 1
} ICMP_TimeExceededCodes;
typedef struct _dhcpMessage
{
UINT8 op;
UINT8 htype;
UINT8 hlen;
UINT8 hops;
UINT32 xid;
UINT16 secs;
UINT16 flags;
UINT32 ciaddr;
UINT32 yiaddr;
UINT32 siaddr;
UINT32 giaddr;
UINT8 chaddr[16];
UINT8 sname[64];
UINT8 file[128];
UINT32 cookie;
UINT8 options[308];
} dhcpMessage;
typedef struct _dhcpPacket
{
in_Header in;
udp_Header udp;
dhcpMessage data;
}dhcpPacket;
enum {
OPTION_IP=1,
OPTION_IP_PAIR,
OPTION_STRING,
OPTION_BOOLEAN,
OPTION_U8,
OPTION_U16,
OPTION_S16,
OPTION_U32,
OPTION_S32
};
struct dhcp_option
{
char name[10];
char flags;
unsigned char code;
};
typedef struct _autodetectPacket
{
/* ((MonitorMajorRev & 0xFF) << 16) + ((MonitorMinorRev & 0xFF) << 8) +
* (TelogyMonitorRev & 0xFF)
* (2nd Byte, 1st Byte and 0th Byte) */
UINT32 version;
int type; /* REQUEST = 1, RESPONSE = 2 */
UINT32 data;
UINT32 reserved;
} autodetectPacket;
enum
{
TYPE_REQUEST = 1,
TYPE_RESPONSE
};
enum
{
CRASH_NONE = 0,
CRASH_KERNEL,
CRASH_FS
};
/* *************************** Function Prototypes ************************** */
extern void reboot(void);
/* sed.c */
/* Ethernet interface:
* sed_WaitPacket(0) => ptr to packet (beyond eth header)
* or NIL if no packet ready.
* sed_Receive(ptr) - reenables receive on input buffer
* sed_FormatPacket(ðdest, ethtype) => ptr to packet buffer
* sed_Send(packet_length) - send the buffer last formatted.
*/
int sed_Init(int diag);
byte *sed_IsPacket(void),
*sed_FormatPacket();
int sed_Send(int), sed_CheckPacket();
void sed_shutdown(void);
int demac(void);
/* arp.c */
int sar_CheckPacket(arp_Header *ap);
int sar_MapIn2Eth(longword ina, eth_HwAddress *ethap);
void sar_initTable(void);
int sar_addEntry(in_HwAddress ip, eth_HwAddress eth);
int sar_deleteEntry(in_HwAddress ip);
int sar_FindEntry(in_HwAddress ip, eth_HwAddress *eth);
int checksum(void *dp, int length);
void Move( void *src, void *dest, int numbytes );
/* tinyip.c */
int ip_init(void);
int ip_deinit(void);
int ip_Handler(void);
void leds_init(void);
void toggle_leds(int bitFlag);
#if defined(AR7DB) || defined(AR7RD) || defined(AR7WRD)
void red_led(void); //By Charles addition For compile 08-13-2004
void green_led(void); //By Charles addition For compile 08-13-2004
#endif
/* tinytcp.c */
int tcp_Init(void);
void tcp_Open(tcp_Socket *s, word lport, in_HwAddress ina, word port, procref datahandler);
void tcp_Listen(tcp_Socket *s, word port, procref datahandler, int timeout);
void tcp_Close(tcp_Socket *s);
void tcp_Abort(tcp_Socket *s);
void tcp_Retransmitter(void);
void tcp_Unthread(tcp_Socket *ds);
#ifndef DHCP_SUPPORT
int tcp(procref application);
#else
int tcp_receive(procref application);
#endif
int tcp_Write(tcp_Socket *s, byte *dp, int len);
void tcp_Flush(tcp_Socket *s);
void tcp_Handler(in_Header *ip);
void tcp_ProcessData(tcp_Socket *s, tcp_Header *tp, int len);
void tcp_Send(tcp_Socket *s);
/* tinyudp.c */
int udplib_init(in_HwAddress my_ip);
int udplib_deinit(void);
int udplib_open(word srcport, word dstport, procref application);
int udplib_close(void);
int udp_open(udp_Socket *s, word srcport, longword ina, word dstport, procref dataHandler, procref application);
int udp_close(udp_Socket *ds);
int udp_receive(unsigned int *ipaddress, void *data, int len, int Client);
void udp_Handler(in_Header *ip);
void udp_dataHandler (udp_Socket *s, byte *dp, int len, void *ph, void *up);
int udp_send(unsigned int ipaddr, int len, void * data);
int udp_write(udp_Socket *s, byte *datap, int len, word offset);
/* tinyftp.c */
#ifdef FTP_CLIENT_SUPPORT
void ftp_ctlHandler(tcp_Socket *s, byte *dp, int len, int state);
void ftp_commandLine(void);
void ftp_Abort(void);
void ftp_application(void);
void ftp(in_HwAddress host, in_HwAddress myip, char *user, char *pass, char *cwd, char *fn, procref dataHandler);
void GotData(tcp_Socket *s, byte *dp, int len, int state);
void getpass(char *str,char *rpass,int len);
int encrypt(char *inp,char *outp);
int decrypt(char *inp,char *outp);
int newpass(void);
#endif /* FTP_CLIENT_SUPPORT */
#ifdef FTP_SERVER_SUPPORT
int FTPServer(void);
int adam2Autodetect(void);
#endif
/* tinyicmp.c */
void icmp_Handler(in_Header *ip);
void icmp_Reply (struct _pkt *p, longword src, longword dest, int icmp_length);
int send_ping(longword host, longword count, longword size);
/* tinydhcp.c */
int dhcpclient(void);
/* options.c */
int add_simple_option(unsigned char *optionptr, unsigned char code, UINT32 data);
int add_option_string(unsigned char *optionptr, unsigned char *string);
unsigned char *get_option(dhcpMessage *packet, int code);
void add_requests(dhcpMessage *packet);
#endif /* _TINYIP_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -