tcpip.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:2k
- #ifndef __TCPIP_H
- #define __TCPIP_H
- #define u8 unsigned char
- #define u16 unsigned short
- #define u32 unsigned int
- #define IP_ANY 0xffffffff
- #define PORT_ANY 0xffff
- #define SOCK_STREAM 1
- #define SOCK_DGRAM 2
- #define SOCK_RAW 3
- int netif_init(unsigned int ipaddr,unsigned int netmask, unsigned int gw, unsigned char *hwaddr);
- int set_ip(unsigned int ipaddr,unsigned int netmask, unsigned int gw); /* */
- int DM_socket_init(unsigned char type, unsigned int remote_port, unsigned int local_port, unsigned long remote_address, unsigned char conn_type);
- u16 htons(u16 n);
- u16 ntohs(u16 n);
- u32 htonl(u32 n);
- u32 ntohl(u32 n);
- /* socket */
- #define INADDR_ANY ((unsigned long int) 0x00000000)
- #define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
- #define INADDR_NONE ((unsigned long int) 0xffffffff)
- #define AF_UNSPEC 0
- #define AF_INET 2
- #define PF_INET AF_INET
- #define PF_UNSPEC AF_UNSPEC
- struct in_addr {
- u32 s_addr; /* 32 bit ip address,net byte order */
- };
- struct sockaddr_in {
- u8 sin_len; /* size of (struct sockaddr_in) = 16 */
- u8 sin_family; /* AF_INET */
- u16 sin_port; /* 16 bit port number,net byte order */
- struct in_addr sin_addr;
- char sin_zero[8]; /* unused */
- };
- struct sockaddr {
- u8 sa_len;
- u8 sa_family;
- char sa_data[14];
- };
- int socket(int domain, int type, int protocol);
- int connect(int s, struct sockaddr *name, int namelen);
- int bind(int, struct sockaddr *, int );
- int listen(int s, int backlog);
- int accept(int s, struct sockaddr *addr, int *addrlen);
- int close(int s);
- int recv(int s, void *mem, int len, unsigned int flags);
- int recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, int *fromlen);
- int send(int s, void *data, int size, unsigned int flags);
- int shutdown(int s, int how);
- int getsockopt (int s, int level, int optname, void *optval, int *optlen);
- int getpeername (int s, struct sockaddr *name, int *namelen);
- int getsockname (int s, struct sockaddr *name, int *namelen);
- int ioctl(int s, long cmd, void *argp);
- int write(int s, void *data, int size);
- int read(int s, void *mem, int len);
- /* socket end */
- int dhcpc_start(void);
- int dhcpc_init(void);
- int fcntl (int socketd, int command, int arguement);
- u32 getip(void);
- u32 getnetmask(void);
- u32 getgw(void);
- #endif