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

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

?? irdaspray.c

?? linux操作系統下的紅外驅動的測試程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/********************************************************************* *                 * Filename:      irdaspray.c * Version:        * Description:    * Status:        Experimental. * Author:        Dag Brattli <dagb@cs.uit.no> *		  Jean Tourrilhes <jt@hpl.hp.com> * Created at:    10/12/99 * Modified at:   Mon May 10 18:31:35 1999 * Modified by:   Dag Brattli <dagb@cs.uit.no> *  *     Copyright (c) 1999 Dag Brattli, All Rights Reserved. *     Copyright (c) 2001 Jean Tourrilhes, All Rights Reserved. *      *     This program is free software; you can redistribute it and/or  *     modify it under the terms of the GNU General Public License as  *     published by the Free Software Foundation; either version 2 of  *     the License, or (at your option) any later version. *  *     This program is distributed in the hope that it will be useful, *     but WITHOUT ANY WARRANTY; without even the implied warranty of *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *     GNU General Public License for more details. *  *     You should have received a copy of the GNU General Public License  *     along with this program; if not, write to the Free Software  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,  *     MA 02111-1307 USA *      ********************************************************************//*gcc -O2 -Wall -o irdaspray irdaspray.c*//* * This program demonstrate the use of auto-connect (connect to a service * without having to discover/specify an address) and how a program * can report discovery results to the user in case the service is not * unique on the network. * Of course, you need both auto-connect and query-ias in the kernel, and * a few bugs sorted out... * * Then, we show a cleaner way to perform discovery, by having better * memory allocation strategy, better handling of errors and setting the * hint mask in the kernel... * * Also, we include a nice feature which is a blocking discovery. Basically, * we ask the kernel to wake us up when it discover a device. This reduces * CPU usage (to zero) and decrease latency (to almost zero). This is * geared toward mobile devices (or to serve those mobile devices), but * also to implement "irmanager/irmonitor" kind of functionality... * * Also, everything about manipulating the IAS database and making query * is explained. That allow you to play with non-standard fields. * * Note that each feature require specific kernel support in the IrDA stack * so please check if your IrDA stack support that... In fact, this was * mostly written to test those kernel features. * * Jean Tourrilhes *//* CONFIGURATION */#define WAITFORDEVICE	1#define CHECKBEFOREWAIT	1#define SETHINTMASK	1#define AUTOCONNECT	1#define GETSOCKNAME	1#define SETIAS		0#define DELIAS		0#include <sys/socket.h>#include <sys/types.h>#include <sys/time.h>#include <sys/ioctl.h>#include <sys/stat.h>#include <sys/wait.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <string.h>#include <fcntl.h>#include <errno.h>#include <linux/types.h>#include <linux/irda.h>#ifndef AF_IRDA#define AF_IRDA 23#endif /* AF_IRDA *//* Memory allocation for discovery */#define DISC_MAX_DEVICES 10#define DISC_BUF_LEN	sizeof(struct irda_device_list) + \			sizeof(struct irda_device_info) * DISC_MAX_DEVICESint frame_size = 1024;int frame_number = 100;unsigned char buf[8200];int echo = 1;		/* Use echo service by default (0 = discard) */int server = 0;		/* Act as a client by default (1 = server) */int two = 0;		/* Open only one client sockets (1 = two) *//* * Function irdaspray_sethintmask (fd) * *    Set the hint mask in the kernel to filter discoveries * * Note : Unless explicitely changed, this setting will remain valid * for any subsequent discoveries on this socket, such as : *	o Waiting for device -> getsockopt(IRLMP_WAITDEVICE) *	o Auto-connect -> connect(daddr = 0x0) *	o Standard discovery -> getsockopt(IRLMP_ENUMDEVICES) */void irdaspray_sethintmask(int fd){	unsigned char	hints[4];	/*	 * The hint mask we use is set to catch any device that potentially	 * support things outside IrComm/IrLAN/IrLPT, so most device	 * worth connecting to via IrTTP.	 * Setting the hint mask with IrComm or IrObex could be usefull	 * for some apps...	 */	hints[0] = HINT_COMPUTER | HINT_PDA;	hints[1] = 0;	/* Set the filter used for performing discovery */	if (setsockopt(fd, SOL_IRLMP, IRLMP_HINT_MASK_SET,		       hints, sizeof(hints))) 	{		perror("setsockopt");		exit(-1);	}}/* * Function irdaspray_check_discovery (fd) * *    Check the state of the discovery log * * See irdaspray_discover_devices() for details */int irdaspray_check_discovery(int fd){	struct irda_device_list *	list;	unsigned char		buf[DISC_BUF_LEN];	int len;	/* Set the list to point to the correct place */	list = (struct irda_device_list *) buf;	len = DISC_BUF_LEN;	/* Perform a discovery and get device list */	if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) {		printf("Didn't find any devices!\n");		return -1;	}	/* Did we got any ? (in some rare cases, this test is true) */	if (list->len <= 0) {		printf("Didn't find any devices!\n");		return -1;	}	return 0;}/* * Function irdaspray_waitfor_devices (fd) * *    Wait until some device come into range... * * Note much to say. We set our hint mask, and call the stack with the * maximum amount of time we want to wait. * If a new device come in, we will wake up, otherwise it will timeout... * Note : this function is only triggered by *new* device, devices already * in range won't trigger this function. * The exact rules are : *	If a device has been discovered, or has change its hint bits, *	less than the discovery timeout in the past, then return, *	otherwise block until this happen or timeout. * Therefore, if you poll continuously this function, you'd better sleep * a bit after a positive result before calling it again... */int irdaspray_waitfor_device(int fd){	int timeout = 30000;	/* Block only for 30s */	int len;#if SETHINTMASK	/* Set the filter used for performing discovery */	irdaspray_sethintmask(fd);#endif#if CHECKBEFOREWAIT	/* Note : before waiting for a new device to show up, we first	 * check if a device has not already been discovered */	if(irdaspray_check_discovery(fd) == 0)		return 0;#endif	/* Wait for a device to be in range */	printf("Waiting for a device...\n");	len = sizeof(timeout);	if (getsockopt(fd, SOL_IRLMP, IRLMP_WAITDEVICE, &timeout, &len)) {		if(errno != EAGAIN) {			perror("getsockopt-wait");			exit(-1);		}		printf("Nothing found in the last %d s\n", timeout / 1000); 		return -1;	}	return 0;	/* Found one device */}/* * Function echo_discover_devices (fd) * *    Try to discover some remote device(s) that we can connect to * * Note : in this function, the memory allocation for the discovery log * is done "the right way", so that we don't leak memory... */int irdaspray_discover_devices(int fd, char *service_name){	struct irda_device_list *	list;	unsigned char		buf[DISC_BUF_LEN];	struct irda_ias_set ias_query;	int err;	int len;	int i;	/* We are so proud of this feature that we show it again ! */#if SETHINTMASK	/* Set the filter used for performing discovery */	irdaspray_sethintmask(fd);#endif	/* Set the list to point to the correct place */	list = (struct irda_device_list *) buf;	len = DISC_BUF_LEN;	/* Perform a discovery and get device list */	if (getsockopt(fd, SOL_IRLMP, IRLMP_ENUMDEVICES, buf, &len)) {		printf("Didn't find any devices!\n");		return -1;	}	/* Did we got any ? (in some rare cases, this test is true) */	if (list->len <= 0) {		printf("Didn't find any devices!\n");		return -1;	}	/* List all devices */	printf("Discovered %d devices :\n", list->len);	for (i=0;i<list->len;i++) {		printf("  [%d] name:  %s, daddr: 0x%08x",		       i + 1, list->dev[i].info, list->dev[i].daddr);		fflush(stdout);		/* Ask if the requested service exist on this device */		len = sizeof(ias_query);		ias_query.daddr = list->dev[i].daddr;		strcpy(ias_query.irda_class_name, service_name);		strcpy(ias_query.irda_attrib_name, "IrDA:TinyTP:LsapSel");		err = getsockopt(fd, SOL_IRLMP, IRLMP_IAS_QUERY,				 &ias_query, &len);		if(err == 0) {			printf(", has service %s\n", service_name);		} else {			if(errno != EADDRNOTAVAIL)				printf(" <can't query IAS>\n");			else				printf(", doesn't have %s\n", service_name);		}	}				/* Ask the user */	printf("Enter device number:");	fflush(stdout);	if(scanf("%X", &i) != 1)		return -1;	i--;	if((i < 0) && (i > list->len))		return -1;	return(list->dev[i].daddr);}/* * IRIAS set/get/query tests */void irias_play(int	fd){	struct irda_ias_set ias_query;	int len;	/* Get the name of our own device */	len = sizeof(ias_query);	strcpy(ias_query.irda_class_name, "Device");	strcpy(ias_query.irda_attrib_name, "DeviceName");	if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, &len)) {		printf("The name of our device is = ``%s''\n",		       ias_query.attribute.irda_attrib_string.string);	}	/* Get the name of the remote device */	len = sizeof(ias_query);	strcpy(ias_query.irda_class_name, "Device");	strcpy(ias_query.irda_attrib_name, "DeviceName");	if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_QUERY, &ias_query, &len)) {		printf("The name of the other device is = ``%s''\n",		       ias_query.attribute.irda_attrib_string.string);	}	/* Set an integer in IAS (new object) */	strcpy(ias_query.irda_class_name, "my:object");	ias_query.irda_attrib_type = IAS_INTEGER;	strcpy(ias_query.irda_attrib_name, "my:int");	ias_query.attribute.irda_attrib_int = 45;	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <my:object><my:int> in IAS\n");	    perror("setsockopt");	  }	/* Set a string in IAS (existing object) */	strcpy(ias_query.irda_class_name, "my:object");	ias_query.irda_attrib_type = IAS_STRING;	strcpy(ias_query.irda_attrib_name, "my:string");	strcpy(ias_query.attribute.irda_attrib_string.string, "The String");	ias_query.attribute.irda_attrib_string.len = strlen("The String");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <my:object><my:string> in IAS\n");	    perror("setsockopt");	  }	/* Set another string in IAS (system object) */	strcpy(ias_query.irda_class_name, "Device");	ias_query.irda_attrib_type = IAS_STRING;	strcpy(ias_query.irda_attrib_name, "Owner");	strcpy(ias_query.attribute.irda_attrib_string.string, "Myself");	ias_query.attribute.irda_attrib_string.len = strlen("Myself");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <Device><Owner> in IAS\n");	    perror("setsockopt");	  }	/* Set yet another string in IAS (same object name as this socket) */	if (echo)		strcpy(ias_query.irda_class_name, "IrECHO");	else		strcpy(ias_query.irda_class_name, "IrDISCARD");	ias_query.irda_attrib_type = IAS_STRING;	strcpy(ias_query.irda_attrib_name, "App-Name");	strcpy(ias_query.attribute.irda_attrib_string.string, "irdaspray.magic");	ias_query.attribute.irda_attrib_string.len = strlen("irdaspray.magic");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <IrECHO><App-Name> in IAS\n");	    perror("setsockopt");	  }	/* Set another integer in IAS (the object attached to this socket) */	strcpy(ias_query.irda_class_name, "");	ias_query.irda_attrib_type = IAS_INTEGER;	strcpy(ias_query.irda_attrib_name, "App-Version");	ias_query.attribute.irda_attrib_int = 3;	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <><App-Version> in IAS\n");	    perror("setsockopt");	  }	/* Try to set a kernel attribute (should fail) */	strcpy(ias_query.irda_class_name, "Device");	strcpy(ias_query.irda_attrib_name, "DeviceName");	strcpy(ias_query.attribute.irda_attrib_string.string, "Linux");	ias_query.attribute.irda_attrib_string.len = strlen("Linux");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_SET, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't set <Device><DeviceName> in IAS\n");	    perror("setsockopt");	  }	/* Read the integer in IAS */	len = sizeof(ias_query);	strcpy(ias_query.irda_class_name, "my:object");	strcpy(ias_query.irda_attrib_name, "my:int");	if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, 		       &len)) 	  {	    printf("Type = %d\n", ias_query.irda_attrib_type);	    printf("Int = %d\n", ias_query.attribute.irda_attrib_int);	  }	/* Read the string in IAS */	len = sizeof(ias_query);	strcpy(ias_query.irda_class_name, "my:object");	strcpy(ias_query.irda_attrib_name, "my:string");	if (!getsockopt(fd, SOL_IRLMP, IRLMP_IAS_GET, &ias_query, 		       &len)) 	  {	    printf("Type = %d\n", ias_query.irda_attrib_type);	    printf("String = ``%s''\n", ias_query.attribute.irda_attrib_string.string);	  }}void irias_remove(int	fd){	struct irda_ias_set ias_query;	/* Delete the integer in IAS */	strcpy(ias_query.irda_class_name, "my:object");	strcpy(ias_query.irda_attrib_name, "my:int");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't remove <my:object><my:int> in IAS\n");	    perror("setsockopt");	  }	/* Delete the string in IAS */	strcpy(ias_query.irda_class_name, "my:object");	strcpy(ias_query.irda_attrib_name, "my:string");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, 		       sizeof(ias_query))) 	  {	    printf("Can't remove <my:object><my:string> in IAS\n");	    perror("setsockopt");	  }	/* Delete the other string in IAS */	strcpy(ias_query.irda_class_name, "Device");	strcpy(ias_query.irda_attrib_name, "Owner");	if (setsockopt(fd, SOL_IRLMP, IRLMP_IAS_DEL, &ias_query, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲狠狠爱一区二区三区| 亚洲精品中文在线| 国产成人在线视频免费播放| 久久嫩草精品久久久久| 经典三级一区二区| 欧美韩国日本一区| 91伊人久久大香线蕉| 洋洋av久久久久久久一区| 欧美精品色综合| 麻豆一区二区三| 国产亚洲污的网站| 日本黄色一区二区| 人妖欧美一区二区| 国产亚洲欧美中文| 欧洲一区二区三区在线| 日韩av一区二区在线影视| 久久一日本道色综合| av成人老司机| 天堂成人免费av电影一区| 欧美电影免费观看完整版| 成人毛片视频在线观看| 一二三四社区欧美黄| 欧美一卡二卡三卡四卡| 成人av网址在线| 亚洲韩国一区二区三区| 久久久激情视频| 欧美视频一二三区| 国产九色精品成人porny| 亚洲综合一区在线| 久久久久高清精品| 欧美精品v日韩精品v韩国精品v| 国产综合久久久久久鬼色| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 欧美日韩高清一区二区不卡| 国产精品一区二区91| 亚洲超碰97人人做人人爱| 久久久亚洲精品一区二区三区| 色婷婷久久一区二区三区麻豆| 免费看精品久久片| 亚洲免费在线播放| 久久精品视频网| 欧美浪妇xxxx高跟鞋交| 国产91丝袜在线播放| 日韩电影在线一区二区三区| 亚洲欧洲av在线| 精品国产sm最大网站免费看| 在线观看视频91| 国产成人无遮挡在线视频| 日本成人中文字幕| 亚洲国产日韩精品| 国产精品你懂的在线| 欧美精品一区二区三区在线| 欧美色电影在线| 99久久精品国产一区| 国产高清精品久久久久| 蜜臀av一级做a爰片久久| 亚洲成人av中文| 伊人婷婷欧美激情| 中文字幕在线不卡国产视频| 久久亚洲精精品中文字幕早川悠里 | 午夜影视日本亚洲欧洲精品| 中文字幕在线观看一区| 国产精品视频一二三区| 久久久久久久久岛国免费| 欧美xxxxx牲另类人与| 欧美一区二区视频在线观看 | 蜜桃av一区二区在线观看| 亚洲国产日韩在线一区模特 | 91精品国产综合久久国产大片| 一本大道av伊人久久综合| 成人av网在线| av动漫一区二区| 成人av集中营| 99久久99久久精品免费观看| 粉嫩高潮美女一区二区三区| 国产成人超碰人人澡人人澡| 国产高清不卡一区| 国产精品一区二区在线播放 | 一区二区三区中文字幕电影 | 成人午夜激情视频| 成人丝袜视频网| 91在线播放网址| 91高清在线观看| 欧美午夜在线一二页| 欧美日韩国产欧美日美国产精品| 欧美猛男男办公室激情| 91精品国产91综合久久蜜臀| 日韩视频一区二区| 26uuu精品一区二区在线观看| 久久人人97超碰com| 久久九九99视频| 亚洲日本护士毛茸茸| 亚洲一区二区三区四区五区中文| 亚洲福利视频一区| 蜜桃av一区二区在线观看| 国产高清亚洲一区| 99re6这里只有精品视频在线观看| 色婷婷精品大在线视频| 678五月天丁香亚洲综合网| 日韩欧美成人一区| 国产色综合一区| 亚洲精品视频在线| 日韩av二区在线播放| 国产精品69久久久久水密桃| 99re这里都是精品| 精品国产伦一区二区三区观看体验| 日韩欧美在线影院| 国产欧美日韩综合| 亚洲精品一二三| 美女尤物国产一区| 成人免费电影视频| 欧美日韩成人一区| 久久精品视频网| 亚洲成人一区二区在线观看| 国产一区二区三区久久久| 日本伦理一区二区| 精品国偷自产国产一区| 中文字幕亚洲成人| 久久精品国产亚洲aⅴ| 99久久精品免费观看| 日韩欧美电影在线| 亚洲精品欧美激情| 精品一区二区三区视频在线观看 | 青青草成人在线观看| 成人黄色777网| 欧美顶级少妇做爰| 中文字幕一区二区三区精华液| 青青草精品视频| 99久久久精品免费观看国产蜜| 欧美人与禽zozo性伦| 中文字幕一区二区三区乱码在线| 免费在线成人网| 91影视在线播放| 久久精品一区二区三区不卡| 日韩精品一级二级| 欧洲一区二区av| 国产精品国产自产拍高清av| 美女尤物国产一区| 欧美猛男男办公室激情| 亚洲色图第一区| 成人网男人的天堂| 久久久久国色av免费看影院| 秋霞成人午夜伦在线观看| 色就色 综合激情| 中文字幕+乱码+中文字幕一区| 免费一级片91| 制服丝袜亚洲精品中文字幕| 亚洲小说欧美激情另类| 91在线观看免费视频| 国产精品萝li| 岛国一区二区在线观看| 久久婷婷成人综合色| 免费国产亚洲视频| 91精品国产综合久久精品| 亚洲丰满少妇videoshd| 欧美专区日韩专区| 亚洲欧美偷拍卡通变态| 91亚洲精品乱码久久久久久蜜桃| 国产人妖乱国产精品人妖| 国产福利一区在线观看| 久久精品亚洲麻豆av一区二区| 国产又粗又猛又爽又黄91精品| 精品久久久久一区| 精品影视av免费| 精品成人一区二区三区| 麻豆成人综合网| 久久伊人蜜桃av一区二区| 国内精品国产成人国产三级粉色| 精品三级在线看| 国产真实精品久久二三区| 久久无码av三级| 处破女av一区二区| 国产精品福利av| 色先锋资源久久综合| 亚洲视频一区二区在线| 日本久久精品电影| 亚洲午夜视频在线观看| 在线综合视频播放| 久草这里只有精品视频| 久久九九久久九九| www.欧美色图| 亚洲一线二线三线视频| 欧美日韩极品在线观看一区| 丰满亚洲少妇av| 亚洲精品国产a久久久久久| 欧洲国内综合视频| 蜜臀av性久久久久蜜臀av麻豆| 精品国产凹凸成av人网站| 成人性色生活片免费看爆迷你毛片| 1区2区3区精品视频| 欧美午夜精品理论片a级按摩| 日韩电影在线一区二区| 久久精品综合网| 色美美综合视频| 日本欧美久久久久免费播放网| 欧美精彩视频一区二区三区| 色先锋资源久久综合| 久久精品国产亚洲a| 国产精品家庭影院| 91精品国产综合久久精品麻豆|