netudp.h

来自「一个tcp/ip协议栈,带有PPP、IP、TCP、UDP等协议」· C头文件 代码 · 共 43 行

H
43
字号
#ifndef _NETUDP_H_
#define _NETUDP_H_

/**
 * UDP header based on RFC768
 */
typedef struct udphdr{
	u_int16_t srcPort;		/* source port */
	u_int16_t dstPort;		/* destination port */
	u_int16_t length;
	u_int16_t checksum;
} UDPHdr;

/** Default time-to-live for UDP datagrams */
#define UDPTTL 0x3d

// Application Level functions
int udpPoll(int ud);
void udpUnblockRead(u_int ud);

// Added ONE TASK UDP support 
#if ONETASK_SUPPORT > 0
extern int udpOpen(void (*receiveEvent)(int ud, USHORT bytes));
#else
extern int udpOpen(void);
#endif

extern int udpClose(int ud);
extern int udpPoll(int ud);
extern int udpConnect(u_int ud, const struct sockaddr_in *remoteAddr, u_char tos);
extern int udpListen(u_int ud, int backLog);
extern int udpBind(u_int ud, struct sockaddr_in *peerAddr);
extern int udpRead(u_int ud, void *buf, long len);
extern int udpWrite(u_int ud, const void *buf, long len);
extern long udpRecvFrom(int ud, void  *buf, long len, struct sockaddr_in *from);
extern long udpSendTo(int ud, const void  *buf, long len, const struct sockaddr_in *to);

// Internal functions, used from within uC/IP
extern void udpInit(void);
extern void udpInput(NBuf *inBuf, u_int ipHeadLen);

#endif /* _NETUDP_H_ */

⌨️ 快捷键说明

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