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

📄 udp_in.c

📁 关于UDP方面的东西。。看不懂就算了。不适合基础者。
💻 C
字号:
/* udp_in.c - udp_in */#include <conf.h>#include <kernel.h>#include <proc.h>#include <network.h>#include <ports.h>/*------------------------------------------------------------------------ *  udp_in -  handle an inbound UDP datagram *------------------------------------------------------------------------ */intudp_in(struct netif *pni, struct ep *pep){	struct	ip	*pip = (struct ip *)pep->ep_data;	struct	udp	*pudp = (struct udp *)pip->ip_data;	struct	upq	*pup;	unsigned short	dst;	int		i;	if (pudp->u_cksum && udpcksum(pep, net2hs(pudp->u_len))) {		freebuf(pep);		return SYSERR;			/* checksum error */	}	udpnet2h(pudp);		/* convert UDP header to host order */	dst = pudp->u_dst;	wait(udpmutex);	for (i=0 ; i<UPPS ; i++) {		pup = &upqs[i];		if (pup->up_port == dst) {			/* drop instead of blocking on psend */ 			if (pcount(pup->up_xport) >= UPPLEN) {				signal(udpmutex);				freebuf(pep);				UdpInErrors++;				return SYSERR;			}			psend(pup->up_xport, (WORD)pep);			UdpInDatagrams++;			if (!isbadpid(pup->up_pid)) {				send(pup->up_pid, OK);				pup->up_pid = BADPID;			}			signal(udpmutex);			return OK;		}	}	signal(udpmutex);	UdpNoPorts++;	icmp(ICT_DESTUR, ICC_PORTUR, pip->ip_src, pep, 0);	return OK;}int	udpmutex;

⌨️ 快捷键说明

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