亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? axsock.c

?? 很好的TCP_IP協議源代碼分析,很適用很好
?? C
字號:
#include <errno.h>
#include "global.h"
#include "mbuf.h"
#include "lapb.h"
#include "ax25.h"
#include "socket.h"
#include "usock.h"

char Ax25_eol[] = "\r";

static void autobind(struct usock *up);

/* The following two variables are needed because there can be only one
 * socket listening on each of the AX.25 modes (I and UI)
 */
int Axi_sock = -1;	/* Socket number listening for AX25 connections */
static int Axui_sock = -1;	/* Socket number listening for AX25 UI frames */
static struct mbuf *Bcq;	/* Queue of incoming UI frames */

/* Function that handles incoming UI frames from lapb.c */
void
beac_input(
struct iface *iface,
uint8 *src,
struct mbuf **bpp
){
	struct mbuf *hdr;
	struct sockaddr_ax *sax;

	if(Axui_sock == -1){
		/* Nobody there to read it */
		free_p(bpp);
	} else {
		pushdown(&hdr,NULL,sizeof(struct sockaddr_ax));
		sax = (struct sockaddr_ax *)hdr->data;
		sax->sax_family = AF_AX25;
		memcpy(sax->ax25_addr,src,AXALEN);
		strncpy(sax->iface,iface->name,ILEN);
		hdr->next = (*bpp);
		*bpp = NULL;
		enqueue(&Bcq,&hdr);
	}
}
int
so_ax_sock(
struct usock *up,
int protocol
){
	return 0;
}
int
so_axui_sock(
struct usock *up,
int protocol
){
	return 0;
}

int
so_axui_bind(
struct usock *up
){
	if(Axui_sock != -1){
		errno = EADDRINUSE;
		return -1;
	}
	Axui_sock = up->index;
	return 0;
}
int
so_ax_listen(
struct usock *up,
int backlog
){
	struct sockaddr_ax *local;

	if(up->name == NULL)
		autobind(up);
	if(up != itop(Axi_sock)){
		errno = EOPNOTSUPP;
		return -1;
	}
	local = (struct sockaddr_ax *)up->name;
	up->cb.ax25 = open_ax25(NULL,local->ax25_addr,NULL,
	 backlog ? AX_SERVER:AX_PASSIVE,0,
	 s_arcall,s_atcall,s_ascall,Axi_sock);
	return 0;
}
int
so_ax_conn(
struct usock *up
){
	struct sockaddr_ax *local,*remote,localtmp;
	struct ax25_cb *ax25;
	struct iface *iface;
	int s;

	s = up->index;
	remote = (struct sockaddr_ax *)up->peername;
	if((iface = if_lookup(remote->iface)) == NULL){
		errno = EINVAL;
		return -1;
	}
	local = (struct sockaddr_ax *)up->name;
	if(local == NULL){
		/* The local address was unspecified; set it from
		 * the interface we'll use
		 */
		localtmp.sax_family = AF_AX25;
		memcpy(localtmp.ax25_addr,iface->hwaddr,AXALEN);
		memcpy(localtmp.iface,remote->iface,ILEN);
		bind(s,(struct sockaddr *)&localtmp,sizeof(localtmp));
		local = (struct sockaddr_ax *)up->name;
	}
	/* If we already have an AX25 link we can use it */
	if((up->cb.ax25 = find_ax25(remote->ax25_addr)) != NULL
	   && up->cb.ax25->state != LAPB_DISCONNECTED &&
	   up->cb.ax25->user == -1) {
		up->cb.ax25->user = s;
		up->cb.ax25->r_upcall = s_arcall;
		up->cb.ax25->t_upcall = s_atcall;
		up->cb.ax25->s_upcall = s_ascall;
		if(up->cb.ax25->state == LAPB_CONNECTED
		   || up->cb.ax25->state == LAPB_RECOVERY)
		    	return 0;
	} else {
		up->cb.ax25 = open_ax25(iface,local->ax25_addr,
		 remote->ax25_addr,AX_ACTIVE,
		 Axwindow,s_arcall,s_atcall,s_ascall,s);
	}
	/* Wait for the connection to complete */
	while((ax25 = up->cb.ax25) != NULL && ax25->state != LAPB_CONNECTED){
		if(up->noblock){
			errno = EWOULDBLOCK;
			return -1;
		} else if((errno = kwait(up)) != 0){
			return -1;
		}
	}
	if(ax25 == NULL){
		/* Connection probably already exists */
		free(up->peername);
		up->peername = NULL;
		errno = ECONNREFUSED;
		return -1;
	}
	return 0;
}
int
so_axui_conn(
struct usock *up
){
	if(up->name == NULL)
		autobind(up);
	return 0;
}

int
so_ax_recv(
struct usock *up,
struct mbuf **bpp,
struct sockaddr *from,
int *fromlen
){
	struct ax25_cb *ax25;
	int cnt;
	
	while((ax25 = up->cb.ax25) != NULL
	 && (*bpp = recv_ax25(ax25,(uint16)0)) == NULL){
		if(up->noblock){
			errno = EWOULDBLOCK;
			return -1;
		} else if((errno = kwait(up)) != 0){
			return -1;
		}
	}
	if(ax25 == NULL){
		/* Connection went away */
		errno = ENOTCONN;
		return -1;
	}
	cnt = (*bpp)->cnt;
	return cnt;
}
int
so_axui_recv(
struct usock *up,
struct mbuf **bpp,
struct sockaddr *from,
int *fromlen
){
	int s;

	s = up->index;

	while(s == Axui_sock && Bcq == NULL){
		if(up->noblock){
			errno = EWOULDBLOCK;
			return -1;
		} else if((errno = kwait(&Bcq)) != 0){
			return -1;
		}
	}
	if(s != Axui_sock){
		errno = ENOTCONN;
		return -1;
	}
	*bpp = dequeue(&Bcq);

	if(from != NULL && fromlen != NULL
	   && *fromlen >= sizeof(struct sockaddr_ax)){
		pullup(bpp,from,sizeof(struct sockaddr_ax));
		*fromlen = sizeof(struct sockaddr_ax);
	} else {
		pullup(bpp,NULL,sizeof(struct sockaddr_ax));
	}
	return len_p(*bpp);
}
int	
so_ax_send(
struct usock *up,
struct mbuf **bpp,
struct sockaddr *to
){
	struct ax25_cb *ax25;

	if((ax25 = up->cb.ax25) == NULL){
		free_p(bpp);
		errno = ENOTCONN;
		return -1;
	}
	send_ax25(ax25,bpp,PID_NO_L3);

	while((ax25 = up->cb.ax25) != NULL &&
	 len_q(ax25->txq) * ax25->paclen > ax25->window){
		if(up->noblock){
			errno = EWOULDBLOCK;
			return -1;
		} else if((errno = kwait(up)) != 0){
			return -1;
		}
	}
	if(ax25 == NULL){
		errno = EBADF;
		return -1;
	}
	return 0;
}
int	
so_axui_send(
struct usock *up,
struct mbuf **bpp,
struct sockaddr *to
){
	struct sockaddr_ax *local,*remote;

	local = (struct sockaddr_ax *)up->name;
	if(to != NULL)
		remote = (struct sockaddr_ax *)to;
	else if(up->peername != NULL){
		remote = (struct sockaddr_ax *)up->peername;
	} else {
		free_p(bpp);
		errno = ENOTCONN;
		return -1;
	}
	ax_output(if_lookup(remote->iface),remote->ax25_addr,
	  local->ax25_addr,PID_NO_L3,bpp);
	return 0;
}

int
so_ax_qlen(
struct usock *up,
int rtx
){
	int len;

	if(up->cb.ax25 == NULL){
		errno = ENOTCONN;
		return -1;
	}
	switch(rtx){
	case 0:
		len = len_p(up->cb.ax25->rxq);
		break;
	case 1:	/* Number of packets, not bytes */
		len = len_q(up->cb.ax25->txq);
	}
	return len;
}
int
so_axui_qlen(
struct usock *up,
int rtx
){
	int len;

	switch(rtx){	
	case 0:
		len = len_q(Bcq);
		break;
	case 1:
		len = 0;		
		break;
	}
	return len;
}
int
so_ax_kick(
struct usock *up
){
	if(up->cb.ax25 != NULL)
		kick_ax25(up->cb.ax25);
	return 0;
}
int
so_ax_shut(
struct usock *up,
int how
){
	if(up->cb.ax25 == NULL)
		return 0;
	switch(how){
	case 0:
	case 1:	/* Attempt regular disconnect */
		disc_ax25(up->cb.ax25);
		break;
	case 2: /* Blow it away */
		reset_ax25(up->cb.ax25);
		up->cb.ax25 = NULL;
		break;
	}
	return 0;	
}
int
so_ax_close(
struct usock *up
){
	if(up->cb.ax25 != NULL){
		/* Tell the CLOSED upcall there's no more socket */
		up->cb.ax25->user = -1;
		disc_ax25(up->cb.ax25);
	}
	return 0;
}
int
so_axui_close(
struct usock *up
){
	Axui_sock = -1;
	free_q(&Bcq);
	ksignal(&Bcq,0);	/* Unblock any reads */
	return 0;
}
/* AX.25 receive upcall */
void
s_arcall(
struct ax25_cb *axp,
int cnt
){
	int ns;
	struct usock *up,*nup,*oup;
	union sp sp;

	up = itop(axp->user);
	/* When AX.25 data arrives for the first time the AX.25 listener
	   is notified, if active. If the AX.25 listener is a server its
	   socket is duplicated in the same manner as in s_tscall().
	 */
	if (Axi_sock != -1 && axp->user == -1) {
		oup = up = itop(Axi_sock);
		/* From now on, use the same upcalls as the listener */
		axp->t_upcall = up->cb.ax25->t_upcall;
		axp->r_upcall = up->cb.ax25->r_upcall;
		axp->s_upcall = up->cb.ax25->s_upcall;
		if (up->cb.ax25->flags.clone) {
			/* Clone the socket */
			ns = socket(AF_AX25,SOCK_STREAM,0);
			nup = itop(ns);
			ASSIGN(*nup,*up);
			axp->user = ns;
			nup->cb.ax25 = axp;
			/* Allocate new memory for the name areas */
			nup->name = mallocw(sizeof(struct sockaddr_ax));
			nup->peername = mallocw(sizeof(struct sockaddr_ax));
			/* Store the new socket # in the old one */
			up->rdysock = ns;
			up = nup;
		} else {
			axp->user = Axi_sock;
			del_ax25(up->cb.ax25);
			up->cb.ax25 = axp;
			/* Allocate space for the peer's name */
			up->peername = mallocw(sizeof(struct sockaddr_ax));
			/* Store the old socket # in the old socket */
			up->rdysock = Axi_sock;
		}
		/* Load the addresses. Memory for the name has already
		 * been allocated, either above or in the original bind.
		 */
		sp.ax = (struct sockaddr_ax *)up->name;
		sp.ax->sax_family = AF_AX25;
		memcpy(sp.ax->ax25_addr,axp->local,AXALEN);
		memcpy(sp.ax->iface,axp->iface->name,ILEN);
		up->namelen = sizeof(struct sockaddr_ax);

		sp.ax = (struct sockaddr_ax *)up->peername;
		sp.ax->sax_family = AF_AX25;
		memcpy(sp.ax->ax25_addr,axp->remote,AXALEN);
		memcpy(sp.ax->iface,axp->iface->name,ILEN);
		up->peernamelen = sizeof(struct sockaddr_ax);
		/* Wake up the guy accepting it, and let him run */
		ksignal(oup,1);
		kwait(NULL);
		return;
	}
	/* Wake up anyone waiting, and let them run */
	ksignal(up,1);
	kwait(NULL);
}
/* AX.25 transmit upcall */
void
s_atcall(
struct ax25_cb *axp,
int cnt
){
	/* Wake up anyone waiting, and let them run */
	ksignal(itop(axp->user),1);
	kwait(NULL);
}
/* AX25 state change upcall routine */
void
s_ascall(
register struct ax25_cb *axp,
int old,
int new
){
	int s;
	struct usock *up;

	s = axp->user;
	up = itop(s);

	switch(new){
	case LAPB_DISCONNECTED:
		/* Clean up. If the user has already closed the socket,
		 * then up will be null (s was set to -1 by the close routine).
		 * If not, then this is an abnormal close (e.g., a reset)
		 * and clearing out the pointer in the socket structure will
		 * prevent any further operations on what will be a freed
		 * control block. Also wake up anybody waiting on events
		 * related to this block so they will notice it disappearing.
		 */
		if(up != NULL){
			up->errcodes[0] = axp->reason;
			up->cb.ax25 = NULL;
		}
		del_ax25(axp);
		break;
	default:	/* Other transitions are ignored */
		break;
	}
	ksignal(up,0);	/* In case anybody's waiting */
}

/* Issue an automatic bind of a local AX25 address */
static void
autobind(
struct usock *up
){
	struct sockaddr_ax local;
	int s;

	s = up->index;
	local.sax_family = AF_AX25;
	memcpy(local.ax25_addr,Mycall,AXALEN);
	bind(s,(struct sockaddr *)&local,sizeof(struct sockaddr_ax));
}
int
checkaxaddr(
struct sockaddr *name,
int namelen
){
	struct sockaddr_ax *sock;

	sock = (struct sockaddr_ax *)name;
	if(sock->sax_family != AF_AX25 || namelen != sizeof(struct sockaddr_ax))
		return -1;
	return 0;
}
char *
axpsocket(
struct sockaddr *p
){
	struct sockaddr_ax *axp;
	static char buf[30];
	char tmp[11];

	axp = (struct sockaddr_ax *)p;
	pax25(tmp,axp->ax25_addr);
	if(strlen(axp->iface) != 0)
		sprintf(buf,"%s on %s",tmp,axp->iface);
	else
		strcpy(buf,tmp);
	return buf;
}
char *
axstate(
struct usock *up
){
	return Ax25states[up->cb.ax25->state];	
}
so_ax_stat(
struct usock *up
){
	st_ax25(up->cb.ax25);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
9久草视频在线视频精品| 91福利在线播放| 精品一区二区三区视频在线观看| 日韩主播视频在线| 日本成人在线不卡视频| 日韩和欧美的一区| 麻豆精品久久精品色综合| 毛片不卡一区二区| 国产电影一区二区三区| 成人激情开心网| 99久久精品国产毛片| 色婷婷亚洲综合| 欧美日韩国产三级| 日韩欧美成人午夜| 中文字幕高清一区| 亚洲免费观看高清完整版在线观看 | 亚洲一区二区欧美| 日韩精品一级中文字幕精品视频免费观看 | 国产一区二区三区免费在线观看| 国产精品综合网| 99国产精品久久久| 欧美色成人综合| 精品免费视频.| 国产精品理论片在线观看| 亚洲精品免费在线| 日韩中文字幕区一区有砖一区 | 欧美成人女星排名| 国产日产亚洲精品系列| 亚洲免费在线电影| 婷婷久久综合九色综合伊人色| 久久草av在线| 99久久国产综合精品女不卡| 欧美精品一级二级| 国产日韩欧美电影| 亚洲成人午夜影院| 国产激情视频一区二区三区欧美| 91丨porny丨户外露出| 91精品国产色综合久久ai换脸 | 国产日本欧美一区二区| 一区二区在线观看av| 奇米影视一区二区三区| 成人精品一区二区三区四区| 欧美精品99久久久**| 国产亚洲精品福利| 五月激情综合婷婷| 丁香网亚洲国际| 欧美日韩高清影院| 国产亚洲精品7777| 婷婷成人激情在线网| 国产99精品国产| 3d成人动漫网站| 亚洲丝袜自拍清纯另类| 韩国中文字幕2020精品| 色婷婷综合久久久久中文| 亚洲精品一线二线三线| 亚洲bt欧美bt精品| 不卡免费追剧大全电视剧网站| 91精品久久久久久久久99蜜臂| 中文字幕一区不卡| 国产综合一区二区| 欧美美女喷水视频| 亚洲乱码中文字幕| 国产成人精品影院| 日韩三级免费观看| 亚洲国产成人tv| www.色精品| 久久视频一区二区| 日韩vs国产vs欧美| 色噜噜狠狠成人网p站| 久久久国产综合精品女国产盗摄| 日本在线不卡视频| 欧美图片一区二区三区| 亚洲欧洲www| 国产福利不卡视频| 精品国产91乱码一区二区三区| 亚洲电影在线播放| 91麻豆国产福利精品| 中文字幕av一区二区三区| 韩国在线一区二区| 日韩欧美一区中文| 丝袜诱惑亚洲看片| 欧美视频在线一区二区三区 | 国产精品18久久久久久久久久久久 | 欧美系列一区二区| 亚洲精品国产第一综合99久久| 成人一区二区三区在线观看| 久久日韩粉嫩一区二区三区| 另类小说视频一区二区| 91精品国产免费久久综合| 亚洲国产欧美在线| 欧美日韩国产经典色站一区二区三区| 亚洲另类在线制服丝袜| 色国产综合视频| 亚洲狼人国产精品| 91福利视频在线| 亚洲一二三区在线观看| 欧美日韩国产美| 日日夜夜免费精品| 欧美精品乱码久久久久久| 亚洲国产精品久久人人爱 | 午夜av区久久| 欧美精品视频www在线观看 | 欧美亚洲日本国产| 亚洲一区在线播放| 欧美日韩日本视频| 日本一区中文字幕| 日韩欧美你懂的| 国产麻豆精品久久一二三| 久久免费的精品国产v∧| 韩国三级在线一区| 中文av一区特黄| 97久久精品人人做人人爽| 成人欧美一区二区三区小说| 日本乱人伦aⅴ精品| 午夜免费久久看| 日韩精品一区二区三区蜜臀| 加勒比av一区二区| 日本一区二区三区在线观看| 91在线视频18| 亚洲第一主播视频| 精品国产乱码久久久久久浪潮 | 久久精子c满五个校花| 成人毛片视频在线观看| 一区二区不卡在线播放| 欧美一区二区视频在线观看2022| 黄色精品一二区| 国产精品第13页| 欧美视频精品在线| 国产最新精品精品你懂的| 国产精品国产三级国产a| 欧美视频精品在线| 狠狠色丁香久久婷婷综合_中| 欧美国产日韩精品免费观看| 欧美在线啊v一区| 免费成人av资源网| 国产精品美女久久久久久| 欧美自拍偷拍午夜视频| 极品销魂美女一区二区三区| 中文字幕日本乱码精品影院| 欧美久久一二三四区| 国产美女一区二区三区| 亚洲精品欧美二区三区中文字幕| 欧美一个色资源| 成人精品免费看| 天堂久久一区二区三区| 国产精品视频yy9299一区| 91福利视频久久久久| 国产综合久久久久影院| 亚洲一区二区三区免费视频| 久久日一线二线三线suv| 欧美亚洲高清一区| 粉嫩av亚洲一区二区图片| 日韩经典一区二区| 国产精品久久久久一区二区三区 | 免费看黄色91| 亚洲欧美日韩成人高清在线一区| 欧美tickling网站挠脚心| 91蜜桃传媒精品久久久一区二区| 久久精品国产精品亚洲精品| 亚洲精品乱码久久久久久黑人| 欧美va在线播放| 欧美三级电影网| thepron国产精品| 韩国精品一区二区| 丝袜国产日韩另类美女| 18涩涩午夜精品.www| 久久一留热品黄| 欧美一区二区美女| 欧美三级电影一区| 91香蕉视频mp4| 国产精品77777竹菊影视小说| 日本视频在线一区| 一区二区日韩av| 一区免费观看视频| 日本一区二区三区在线不卡| 日韩免费电影一区| 欧美精品自拍偷拍动漫精品| 色老汉一区二区三区| 成a人片国产精品| 国产裸体歌舞团一区二区| 日本一道高清亚洲日美韩| 亚洲国产精品嫩草影院| 亚洲美女电影在线| 综合久久久久综合| 国产精品理论在线观看| 国产亚洲一区二区在线观看| 日韩美女天天操| 日韩一区二区三区电影| 884aa四虎影成人精品一区| 欧美日韩一区二区三区四区五区| 99精品欧美一区| 99国产精品久| 成人v精品蜜桃久久一区| 大胆亚洲人体视频| 高清在线成人网| 国产精品一二二区| 国产成人综合在线观看| 国产精品影视在线观看| 国产一区二区三区四区在线观看| 久久99精品久久只有精品|