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

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

?? ax25.c

?? uCLinux下的一個TCP/IP協議棧源碼
?? C
字號:
/* Low level AX.25 code:
 */
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "iface.h"
#include "arp.h"
#include "slip.h"
#include "ax25.h"
#include "lapb.h"
#include "netrom.h"
#include "ip.h"
#include "devparam.h"
#include <ctype.h>

/* List of AX.25 multicast addresses in network format (shifted ascii).
 * Only the first entry is used for transmission, but an incoming
 * packet with any one of these destination addresses is recognized
 * as a multicast.
 */
uint8 Ax25multi[][AXALEN] = {
	'Q'<<1, 'S'<<1, 'T'<<1, ' '<<1, ' '<<1, ' '<<1, '0'<<1,	/* QST */
	'M'<<1, 'A'<<1, 'I'<<1, 'L'<<1, ' '<<1, ' '<<1, '0'<<1,	/* MAIL */
	'N'<<1, 'O'<<1, 'D'<<1, 'E'<<1, 'S'<<1, ' '<<1, '0'<<1,	/* NODES */
	'I'<<1, 'D'<<1, ' '<<1, ' '<<1, ' '<<1, ' '<<1, '0'<<1,	/* ID */
	'O'<<1, 'P'<<1, 'E'<<1, 'N'<<1, ' '<<1, ' '<<1, '0'<<1,	/* OPEN */
	'C'<<1, 'Q'<<1, ' '<<1, ' '<<1, ' '<<1, ' '<<1, '0'<<1,	/* CQ */
	'B'<<1, 'E'<<1, 'A'<<1, 'C'<<1, 'O'<<1, 'N'<<1, '0'<<1,	/* BEACON */
	'R'<<1, 'M'<<1, 'N'<<1, 'C'<<1, ' '<<1, ' '<<1, '0'<<1,	/* RMNC */
	'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1, '0'<<1,	/* ALL */
	'\0',
};
uint8 Mycall[AXALEN];
struct ax_route *Ax_routes;	/* Routing table header */
int Digipeat = 1;	/* Controls digipeating */

int
axi_send(
struct mbuf **bpp,
struct iface *iface,
int32 gateway,
uint8 tos
){
	return axui_send(bpp,iface,gateway,tos);
}

/* Send IP datagrams across an AX.25 link */
int
axui_send(
struct mbuf **bpp,
struct iface *iface,
int32 gateway,
uint8 tos
){
	struct mbuf *tbp;
	uint8 *hw_addr;
	struct ax25_cb *axp;

	if((hw_addr = res_arp(iface,ARP_AX25,gateway,bpp)) == NULL)
		return 0;	/* Wait for address resolution */

	/* UI frames are used for any one of the following three conditions:
	 * 1. The "low delay" bit is set in the type-of-service field.
	 * 2. The "reliability" TOS bit is NOT set and the interface is in
	 *    datagram mode.
	 * 3. The destination is the broadcast address (this is helpful
	 *    when broadcasting on an interface that's in connected mode).
	 */
	if((tos & IP_COS) == DELAY
	 || ((tos & IP_COS) != RELIABILITY && (iface->send == axui_send))
	 || addreq(hw_addr,Ax25multi[0])){
		/* Use UI frame */
		return (*iface->output)(iface,hw_addr,iface->hwaddr,PID_IP,bpp);
	}
	/* Reliability is needed; use I-frames in AX.25 connection */
	if((axp = find_ax25(hw_addr)) == NULL){
		/* Open a new connection */
		axp = open_ax25(iface,iface->hwaddr,hw_addr,
		 AX_ACTIVE,Axwindow,s_arcall,s_atcall,s_ascall,-1);
		if(axp == NULL){
			free_p(bpp);
			return -1;
		}
	}
	if(axp->state == LAPB_DISCONNECTED){
		est_link(axp);
		lapbstate(axp,LAPB_SETUP);
	}
	/* Insert the PID */
	pushdown(bpp,NULL,1);
	(*bpp)->data[0] = PID_IP;
	if((tbp = segmenter(bpp,axp->paclen)) == NULL){
		free_p(bpp);
		return -1;
	}
	return send_ax25(axp,&tbp,-1);
}
/* Add header and send connectionless (UI) AX.25 packet.
 * Note that the calling order here must match enet_output
 * since ARP also uses it.
 */
int
ax_output(
struct iface *iface,	/* Interface to use; overrides routing table */
uint8 *dest,		/* Destination AX.25 address (7 bytes, shifted) */
uint8 *source,		/* Source AX.25 address (7 bytes, shifted) */
uint16 pid,		/* Protocol ID */
struct mbuf **bpp	/* Data field (follows PID) */
){
	/* Prepend pid to data */
	pushdown(bpp,NULL,1);
	(*bpp)->data[0] = (uint8)pid;
	return axsend(iface,dest,source,LAPB_COMMAND,UI,bpp);
}
/* Common subroutine for sendframe() and ax_output() */
int
axsend(
struct iface *iface,	/* Interface to use; overrides routing table */
uint8 *dest,		/* Destination AX.25 address (7 bytes, shifted) */
uint8 *source,		/* Source AX.25 address (7 bytes, shifted) */
int cmdrsp,		/* Command/response indication */
int ctl,		/* Control field */
struct mbuf **bpp	/* Data field (includes PID) */
){
	struct ax25 addr;
	struct ax_route *axr;
	uint8 *idest;
	int rval;

	/* If the source addr is unspecified, use the interface address */
	if(source[0] == '\0')
		source = iface->hwaddr;

	/* If there's a digipeater route, get it */
	axr = ax_lookup(dest);

	memcpy(addr.dest,dest,AXALEN);
	memcpy(addr.source,source,AXALEN);
	addr.cmdrsp = cmdrsp;

	if(axr != NULL){
		memcpy(addr.digis,axr->digis,axr->ndigis*AXALEN);
		addr.ndigis = axr->ndigis;
		idest = addr.digis[0];
	} else {
		addr.ndigis = 0;
		idest = dest;
	}
	addr.nextdigi = 0;

	/* Allocate mbuf for control field, and fill in */
	pushdown(bpp,NULL,1);
	(*bpp)->data[0] = ctl;

	htonax25(&addr,bpp);
	/* This shouldn't be necessary because redirection has already been
	 * done at the IP router layer, but just to be safe...
	 */
	if(iface->forw != NULL){
		logsrc(iface->forw,iface->forw->hwaddr);
		logdest(iface->forw,idest);
		rval = (*iface->forw->raw)(iface->forw,bpp);
	} else {
		logsrc(iface,iface->hwaddr);
		logdest(iface,idest);
		rval = (*iface->raw)(iface,bpp);
	}
	return rval;
}
/* Process incoming AX.25 packets.
 * After optional tracing, the address field is examined. If it is
 * directed to us as a digipeater, repeat it.  If it is addressed to
 * us or to QST-0, kick it upstairs depending on the protocol ID.
 */
void
ax_recv(
struct iface *iface,
struct mbuf **bpp
){
	uint8 control;
	struct ax25 hdr;
	struct ax25_cb *axp;
	struct ax_route *axr;
	uint8 (*mpp)[AXALEN];
	int mcast;
	uint8 *isrc,*idest;	/* "immediate" source and destination */

	/* Pull header off packet and convert to host structure */
	if(ntohax25(&hdr,bpp) < 0){
		/* Something wrong with the header */
		free_p(bpp);
		return;
	}
	/* If there were digis in this packet and at least one has
	 * been passed, then the last passed digi is the immediate source.
	 * Otherwise it is the original source.
	 */
	if(hdr.ndigis != 0 && hdr.nextdigi != 0)
		isrc = hdr.digis[hdr.nextdigi-1];
	else
		isrc = hdr.source;

	/* If there are digis in this packet and not all have been passed,
	 * then the immediate destination is the next digi. Otherwise it
	 * is the final destination.
	 */
	if(hdr.ndigis != 0 && hdr.nextdigi != hdr.ndigis)
		idest = hdr.digis[hdr.nextdigi];
	else
		idest = hdr.dest;

	/* Don't log our own packets if we overhear them, as they're
	 * already logged by axsend() and by the digipeater code.
	 */
	if(!addreq(isrc,iface->hwaddr)){
		logsrc(iface,isrc);
		logdest(iface,idest);
	}
	/* Examine immediate destination for a multicast address */
	mcast = 0;
	for(mpp = Ax25multi;(*mpp)[0] != '\0';mpp++){
		if(addreq(idest,*mpp)){
			mcast = 1;
			break;
		}
	}
	if(!mcast && !addreq(idest,iface->hwaddr)){
		/* Not a broadcast, and not addressed to us. Inhibit
		 * transmitter to avoid colliding with addressed station's
		 * response, and discard packet.
		 */
		if(iface->ioctl != NULL)
			(*iface->ioctl)(iface,PARAM_MUTE,1,-1);
		free_p(bpp);
		return;
	}
	if(!mcast && iface->ioctl != NULL){
		/* Packet was sent to us; abort transmit inhibit */
		(*iface->ioctl)(iface,PARAM_MUTE,1,0);
	}
	/* At this point, packet is either addressed to us, or is
	 * a multicast.
	 */
	if(hdr.nextdigi < hdr.ndigis){
		/* Packet requests digipeating. See if we can repeat it. */
		if(Digipeat && !mcast){
			/* Yes, kick it back out. htonax25 will set the
			 * repeated bit.
			 */
			hdr.nextdigi++;
			htonax25(&hdr,bpp);
			if(iface->forw != NULL){
				logsrc(iface->forw,iface->forw->hwaddr);
				logdest(iface->forw,hdr.digis[hdr.nextdigi]);
				(*iface->forw->raw)(iface->forw,bpp);
			} else {
				logsrc(iface,iface->hwaddr);
				logdest(iface,hdr.digis[hdr.nextdigi]);
				(*iface->raw)(iface,bpp);
			}
		}
		free_p(bpp);	/* Dispose if not forwarded */
		return;
	}
	/* If we reach this point, then the packet has passed all digis,
	 * and is either addressed to us or is a multicast.
	 */
	if(*bpp == NULL)
		return;		/* Nothing left */

	/* If there's no locally-set entry in the routing table and
	 * this packet has digipeaters, create or update it. Leave
	 * local routes alone.
	 */
	if(((axr = ax_lookup(hdr.source)) == NULL || axr->type == AX_AUTO)
	 && hdr.ndigis > 0){
		uint8 digis[MAXDIGIS][AXALEN];
		int i,j;

		/* Construct reverse digipeater path */
		for(i=hdr.ndigis-1,j=0;i >= 0;i--,j++){
			memcpy(digis[j],hdr.digis[i],AXALEN);
			digis[j][ALEN] &= ~(E|REPEATED);
		}
		ax_add(hdr.source,AX_AUTO,digis,hdr.ndigis);
	}
	/* Sneak a peek at the control field. This kludge is necessary because
	 * AX.25 lacks a proper protocol ID field between the address and LAPB
	 * sublayers; a control value of UI indicates that LAPB is to be
	 * bypassed.
	 */
	control = *(*bpp)->data & ~PF;

	if(control == UI){
		int pid;
		struct axlink *ipp;

		(void) PULLCHAR(bpp);
		if((pid = PULLCHAR(bpp)) == -1)
			return;		/* No PID */
		/* Find network level protocol and hand it off */
		for(ipp = Axlink;ipp->funct != NULL;ipp++){
			if(ipp->pid == pid)
				break;
		}
		if(ipp->funct != NULL)
			(*ipp->funct)(iface,NULL,hdr.source,hdr.dest,bpp,mcast);
		else
			free_p(bpp);
		return;
	}
	/* Everything from here down is connected-mode LAPB, so ignore
	 * multicasts
	 */
	if(mcast){
		free_p(bpp);
		return;
	}
	/* Find the source address in hash table */
	if((axp = find_ax25(hdr.source)) == NULL){
		/* Create a new ax25 entry for this guy,
		 * insert into hash table keyed on his address,
		 * and initialize table entries
		 */
		if((axp = cr_ax25(hdr.source)) == NULL){
			free_p(bpp);
			return;
		}
		/* Swap source and destination */
		memcpy(axp->remote,hdr.source,AXALEN);
		memcpy(axp->local,hdr.dest,AXALEN);
		axp->iface = iface;
	}
	if(hdr.cmdrsp == LAPB_UNKNOWN)
		axp->proto = V1;	/* Old protocol in use */

	lapb_input(axp,hdr.cmdrsp,bpp);
}
/* Find a route for an AX.25 address */
struct ax_route *
ax_lookup(
uint8 *target
){
	register struct ax_route *axr;
	struct ax_route *axlast = NULL;

	for(axr = Ax_routes; axr != NULL; axlast=axr,axr = axr->next){
		if(addreq(axr->target,target)){
			if(axr != Ax_routes){
				/* Move entry to top of list to speed
				 * future searches
				 */
				axlast->next = axr->next;
				axr->next = Ax_routes;
				Ax_routes = axr;

			}
			return axr;
		}
	}
	return axr;
}
/* Add an entry to the AX.25 routing table */
struct ax_route *
ax_add(
uint8 *target,
int type,
uint8 digis[][AXALEN],
int ndigis
){
	register struct ax_route *axr;

	if(ndigis < 0 || ndigis > MAXDIGIS)
		return NULL;

	if((axr = ax_lookup(target)) == NULL){
		axr = (struct ax_route *)callocw(1,sizeof(struct ax_route));
		axr->next = Ax_routes;
		Ax_routes = axr;
		memcpy(axr->target,target,AXALEN);
		axr->ndigis = ndigis;
	}
	axr->type = type;
	if(axr->ndigis != ndigis)
		axr->ndigis = ndigis;

	memcpy(axr->digis,digis[0],ndigis*AXALEN);
	return axr;
}
int
ax_drop(
uint8 *target
){
	register struct ax_route *axr;
	struct ax_route *axlast = NULL;

	for(axr = Ax_routes;axr != NULL;axlast=axr,axr=axr->next)
		if(memcmp(axr->target,target,AXALEN) == 0)
			break;
	if(axr == NULL)
		return -1;	/* Not in table! */
	if(axlast != NULL)
		axlast->next = axr->next;
	else
		Ax_routes = axr->next;
	
	free(axr);
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩和欧美一区二区| 久久精品国产色蜜蜜麻豆| 136国产福利精品导航| 一区二区三区蜜桃网| 一区二区三区在线免费观看| 亚洲激情av在线| 麻豆传媒一区二区三区| 一本色道久久综合狠狠躁的推荐| 日韩视频中午一区| 天堂蜜桃一区二区三区| 91蝌蚪国产九色| 国产精品网站导航| 久久福利资源站| 在线播放亚洲一区| 亚洲一区二区三区不卡国产欧美| 成人免费视频视频在线观看免费| 日韩一级视频免费观看在线| 亚洲国产日日夜夜| 欧美最新大片在线看| 亚洲欧美一区二区久久| 成人18精品视频| 亚洲国产成人午夜在线一区| 寂寞少妇一区二区三区| 91精品国产aⅴ一区二区| 亚洲成在线观看| 欧美午夜一区二区| 一区二区不卡在线视频 午夜欧美不卡在| 国产成人综合自拍| 国产女人aaa级久久久级| 国产精品一区二区久激情瑜伽| 日韩美女视频一区二区在线观看| 日韩电影一区二区三区四区| 911精品国产一区二区在线| 天堂在线亚洲视频| 日韩免费看网站| 国产中文字幕精品| 久久久精品天堂| 成人免费va视频| √…a在线天堂一区| 91免费看片在线观看| 亚洲美女屁股眼交| 欧美日韩一区中文字幕| 日产精品久久久久久久性色| 日韩精品一区二区三区中文不卡| 美女网站色91| 欧美激情中文字幕一区二区| 99国产精品久久久| 香蕉久久一区二区不卡无毒影院| 欧美福利视频一区| 狠狠狠色丁香婷婷综合激情 | 91年精品国产| 亚洲午夜一区二区| 91精品国产综合久久久蜜臀粉嫩| 精品一区二区三区免费毛片爱| 久久亚洲一区二区三区四区| 99re热这里只有精品视频| 亚洲中国最大av网站| 日韩精品一区二区三区在线播放| 国产成人精品影视| 亚洲色欲色欲www在线观看| 日本精品裸体写真集在线观看 | 欧美三级一区二区| 日本中文字幕一区二区视频| 国产欧美一区二区精品性| 色一情一乱一乱一91av| 视频一区视频二区中文字幕| 久久久777精品电影网影网| 99国产精品视频免费观看| 天天综合网 天天综合色| 国产日韩欧美一区二区三区综合| 91视频观看视频| 日本不卡一区二区| 亚洲人成精品久久久久| 日韩一区二区三区高清免费看看| 国产 欧美在线| 日本免费在线视频不卡一不卡二| 日本一区二区免费在线 | 国产精品99久久久久久久女警| 国产精品另类一区| 日韩欧美激情四射| 91在线观看一区二区| 蜜臀av一区二区| 一区二区三区在线视频免费| 久久影视一区二区| 欧美探花视频资源| 97久久人人超碰| 国产精品亚洲成人| 久久aⅴ国产欧美74aaa| 亚洲制服丝袜av| 国产精品三级久久久久三级| 日韩一区二区高清| 精品污污网站免费看| 99久久精品免费看| 狠狠色综合日日| 麻豆精品新av中文字幕| 天天爽夜夜爽夜夜爽精品视频| 亚洲欧洲成人精品av97| 国产欧美精品在线观看| 日韩一区二区电影在线| 欧美日韩一级黄| 在线精品视频免费观看| 色先锋资源久久综合| 99久久久久免费精品国产 | 激情深爱一区二区| 五月天亚洲精品| 亚洲小说欧美激情另类| 亚洲免费三区一区二区| 欧美激情在线一区二区三区| 欧美精品一区二区三区四区| 日韩欧美中文字幕精品| 欧美一区二区视频网站| 日韩一区二区在线免费观看| 91精品国产综合久久精品麻豆 | 日本一不卡视频| 日韩不卡手机在线v区| 日本视频一区二区| 免费在线成人网| 老鸭窝一区二区久久精品| 男人的天堂久久精品| 免费观看一级欧美片| 久久精品国产99久久6| 久草精品在线观看| 国产精品一级在线| 99riav久久精品riav| 91农村精品一区二区在线| 欧美在线观看视频一区二区三区| 在线看国产一区二区| 在线不卡中文字幕| 26uuu久久天堂性欧美| 国产精品色婷婷| 中文字幕综合网| 亚洲成人免费观看| 另类综合日韩欧美亚洲| 国产999精品久久久久久绿帽| av网站免费线看精品| 91福利国产精品| 欧美一区二区人人喊爽| 久久久久久电影| 一区二区三区中文字幕在线观看| 午夜精品久久久久影视| 精品一区二区三区视频| 97se亚洲国产综合在线| 欧美色区777第一页| 欧美videofree性高清杂交| 国产精品午夜电影| 亚洲一区自拍偷拍| 极品少妇一区二区| 色婷婷精品大在线视频 | 在线亚洲免费视频| 日韩午夜小视频| 亚洲欧美综合在线精品| 日本伊人精品一区二区三区观看方式| 国产精品一区二区果冻传媒| 欧美日韩中文字幕一区二区| 久久这里只精品最新地址| 亚洲久本草在线中文字幕| 久久福利视频一区二区| 色综合久久九月婷婷色综合| 日韩免费看的电影| 亚洲男同性恋视频| 狠狠色狠狠色综合日日91app| 日本道精品一区二区三区| 久久亚洲一区二区三区明星换脸| 亚洲一区二区成人在线观看| 国产乱码精品一区二区三区五月婷| 色噜噜狠狠成人中文综合| 久久久久久99久久久精品网站| 亚洲高清免费在线| 成+人+亚洲+综合天堂| 精品国产123| 日韩精品视频网站| 在线精品视频一区二区三四| 国产精品丝袜久久久久久app| 日本不卡的三区四区五区| 色八戒一区二区三区| 久久精品网站免费观看| 欧美aaaaa成人免费观看视频| 在线观看www91| 综合久久综合久久| 国产白丝精品91爽爽久久| 日韩亚洲欧美综合| 亚洲成人动漫在线免费观看| 一本久久a久久免费精品不卡| 久久精品一区二区| 国产在线视频精品一区| 精品国产第一区二区三区观看体验 | 日韩欧美色电影| 舔着乳尖日韩一区| 欧美三级电影精品| 亚洲一区二区免费视频| 一本久久a久久精品亚洲| 国产精品美日韩| av影院午夜一区| 亚洲欧洲av色图| 97国产精品videossex| 成人欧美一区二区三区视频网页| 成人免费三级在线| 国产精品久久毛片a| 成人18视频日本| 亚洲精品国产精品乱码不99|