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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? axsock.c

?? 這是新華龍(www.xhl.xom.xn)開發(fā)的
?? 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;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品每日更新| 亚洲精品日日夜夜| 91视频xxxx| 日本成人在线不卡视频| **性色生活片久久毛片| 久久综合色鬼综合色| 欧美日韩一二三| 91影院在线免费观看| 国产一区亚洲一区| 日韩高清一区在线| 亚洲一级二级三级| 亚洲欧美影音先锋| 国产欧美视频一区二区三区| 91精品在线麻豆| 在线观看日韩高清av| 99这里只有久久精品视频| 国产露脸91国语对白| 久久99精品久久久久久| 午夜精品福利视频网站 | 国产欧美综合在线观看第十页| 欧美日韩在线播| 色欧美88888久久久久久影院| 国产精品夜夜嗨| 欧美亚洲一区三区| 国产很黄免费观看久久| 日韩欧美在线综合网| 色综合久久久久久久| www.日韩大片| 国产91精品入口| 国产精品综合视频| 国产在线播放一区三区四| 奇米精品一区二区三区四区| 亚洲成人精品影院| 亚洲香蕉伊在人在线观| 亚洲免费色视频| 亚洲日本青草视频在线怡红院| 国产亚洲短视频| 久久久激情视频| 国产午夜精品久久久久久免费视| 精品欧美一区二区在线观看| 欧美一区二区三区四区高清| 欧美一级欧美三级在线观看| 欧美一区二区三区免费视频| 日韩限制级电影在线观看| 欧美大尺度电影在线| 日韩欧美精品在线| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 麻豆极品一区二区三区| 麻豆中文一区二区| 国产精品一区久久久久| 粉嫩av一区二区三区粉嫩| 成人高清伦理免费影院在线观看| 成人av资源网站| 91国模大尺度私拍在线视频| 国产精品美女一区二区| 中文字幕在线观看不卡视频| 亚洲欧美日韩人成在线播放| 亚洲一区二区三区自拍| 亚洲成av人片| 精品一区二区三区在线播放视频| 美女国产一区二区| 国产99一区视频免费 | 欧美午夜不卡在线观看免费| 欧美丰满美乳xxx高潮www| 日韩免费视频线观看| 国产视频一区二区三区在线观看| 中文字幕亚洲在| 亚洲成年人网站在线观看| 麻豆成人综合网| av亚洲精华国产精华精华| 欧美唯美清纯偷拍| 精品国产3级a| 怡红院av一区二区三区| 蜜臀av一区二区在线免费观看| 国内精品久久久久影院色| 成人h版在线观看| 91精品黄色片免费大全| 国产婷婷色一区二区三区四区 | 亚洲综合免费观看高清完整版| 午夜在线电影亚洲一区| 国产酒店精品激情| 在线观看日韩av先锋影音电影院| 日韩午夜激情av| 中文字幕一区二区三区不卡 | www.日韩av| 欧美一区二区久久久| 中文字幕不卡在线观看| 亚洲第一久久影院| 日韩一区二区免费在线观看| 中文文精品字幕一区二区| 无码av免费一区二区三区试看 | 国产精品自拍三区| 欧美天堂一区二区三区| 久久久久久综合| 午夜精品久久久久久久久久| 波多野结衣在线一区| 欧美电影免费观看高清完整版| 亚洲天堂福利av| 国产精品18久久久久久久网站| 欧美色图第一页| 国产精品国模大尺度视频| 久久精品国产在热久久| 欧美午夜一区二区三区| 亚洲婷婷国产精品电影人久久| 国产最新精品免费| 3751色影院一区二区三区| 亚洲男同性恋视频| 成人精品视频.| 久久久久久久免费视频了| 三级久久三级久久| 91国产免费看| 成人免费视频在线观看| 粉嫩欧美一区二区三区高清影视| 日韩精品中午字幕| 日本欧美一区二区| 欧美亚洲精品一区| 亚洲精品国产视频| 久久综合久久综合久久综合| 琪琪久久久久日韩精品| 欧美三区在线观看| 一二三区精品福利视频| 91啪在线观看| 亚洲人成7777| 91欧美一区二区| 最新国产成人在线观看| av午夜精品一区二区三区| 国产日韩欧美不卡| 国产成人av影院| 国产三级一区二区三区| 国产91露脸合集magnet| 久久久久久麻豆| 国产iv一区二区三区| 国产欧美一区二区三区在线老狼| 黄网站免费久久| 久久久精品国产免大香伊| 美女网站在线免费欧美精品| 日韩精品中午字幕| 韩国一区二区三区| 久久网站最新地址| 高清国产一区二区| 综合自拍亚洲综合图不卡区| 91视频观看免费| 亚洲午夜在线电影| 9191成人精品久久| 免费的国产精品| 精品99一区二区三区| 国产**成人网毛片九色| 中文字幕在线播放不卡一区| 91视频在线看| 亚洲一区二区不卡免费| 91精品国产免费| 国产又黄又大久久| 中文字幕视频一区| 欧美亚洲一区二区三区四区| 天堂一区二区在线| 欧美xxxxx牲另类人与| 国产精品一二三在| 国产精品一区二区久久精品爱涩| 国产日韩欧美精品综合| 91麻豆免费看片| 舔着乳尖日韩一区| 久久精品一区二区三区不卡| 91在线你懂得| 丝瓜av网站精品一区二区| 精品黑人一区二区三区久久 | 日韩av网站在线观看| 日韩免费看的电影| 成人一道本在线| 亚洲成人免费在线| 久久先锋资源网| 色呦呦一区二区三区| 亚洲成人午夜影院| 国产日韩欧美麻豆| 欧美日韩一二三区| 国产成a人亚洲| 亚洲国产一区二区视频| 久久综合九色综合久久久精品综合| 成人国产精品免费网站| 天天av天天翘天天综合网| 国产校园另类小说区| 欧美日韩一区小说| 国产.欧美.日韩| 丝袜美腿亚洲一区| 国产精品久久久久aaaa| 欧美精品九九99久久| thepron国产精品| 麻豆精品视频在线| 亚洲综合视频在线| 国产午夜精品理论片a级大结局| 欧美午夜精品久久久久久孕妇| 久久国产欧美日韩精品| 一区二区三区在线免费视频| 久久久久国产精品免费免费搜索| 日本精品视频一区二区三区| 国产一区二区0| 青青草97国产精品免费观看无弹窗版 | jlzzjlzz欧美大全| 韩国在线一区二区| 日韩黄色免费网站| 亚洲欧美乱综合|