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

📄 netudp.h

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 H
字号:
#ifndef _NETUDP_H_

#define _NETUDP_H_

#include "netbuf.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;





/**

 * Queue of incoming datagrams.

 * This maintains a list of nBuf chains, along with the source address and port they came from

 * to allow reponses to be sent to multiple peers from one unconnected socket

 */

typedef struct _udp_queue {

    /** Pointer to next chain */

    struct _udp_queue* next;

    /** Source address for this chain (machine byte order) */

    struct in_addr srcAddr;

    /** Source port for this chain (machine byte order) */

    u_int16_t srcPort;

    /** pointer to the head of the actual nBuf chain */

    NBuf* nBuf;

} UDP_QUEUE;







/**

 * UDP port control block

 */

typedef struct {

    unsigned long flags;

    /** incoming data semaphore (value is number of UDP_QUEUE's from head) */

//    OS_EVENT* sem;
    unsigned long sem;

    /** accept address (network byte order) */

    struct in_addr acceptFromAddr;

    /** send to address (network byte order) */

    struct in_addr theirAddr;

    /** sendto/recvfrom port (network byte order) */

    u_int16_t theirPort;

    /** port number on local machine (network byte order) */

    u_int16_t ourPort;

    /** type of service */

    u_int16_t tos;

    /** Head of the queue of incoming datagrams */

    UDP_QUEUE* head;

    /** Last incoming datagram in the queue */

    UDP_QUEUE* tail;



#if ONETASK_SUPPORT > 0

  // When running in a single task, we want to use callback functions...

  void (*receiveEvent)(int ud, u_int16_t bytes);               /* Called when new data has arrived */

#endif



} UDPCB;



/** Default time-to-live for UDP datagrams */

#define UDPTTL 0x3d



// Application Level functions



// 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 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -