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

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

?? if_media.c

?? Linux下wifi實現
?? C
字號:
/* * Copyright (c) 1997 *	Jonathan Stone and Jason R. Thorpe.  All rights reserved. * * This software is derived from information provided by Matt Thomas. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *      This product includes software developed by Jonathan Stone *	and Jason R. Thorpe for the NetBSD Project. * 4. The names of the authors may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: if_media.c 1614 2006-05-31 21:05:08Z mentor $ *//* * BSD/OS-compatible network interface media selection. * * Where it is safe to do so, this code strays slightly from the BSD/OS * design.  Software which uses the API (device drivers, basically) * shouldn't notice any difference. * * Many thanks to Matt Thomas for providing the information necessary * to implement this interface. */#ifndef EXPORT_SYMTAB#define	EXPORT_SYMTAB#endif#include <linux/config.h>#include <linux/version.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/slab.h>#include <linux/if.h>#include <linux/netdevice.h>#ifndef ifr_media#define	ifr_media	ifr_ifru.ifru_ivalue#endif#include <asm/uaccess.h>#include "if_media.h"/* * Compile-time options: * IFMEDIA_DEBUG: *	turn on implementation-level debug printfs. * 	Useful for debugging newly-ported  drivers. */struct ifmedia_entry *ifmedia_match(struct ifmedia *, int, int);#ifdef IFMEDIA_DEBUGint ifmedia_debug = 0;static void ifmedia_printword(int);#endif/* * Initialize if_media struct for a specific interface instance. */voidifmedia_init(struct ifmedia *ifm, int dontcare_mask,	ifm_change_cb_t change_callback, ifm_stat_cb_t status_callback){	LIST_INIT(&ifm->ifm_list);	ifm->ifm_cur = NULL;	ifm->ifm_media = 0;	ifm->ifm_mask = dontcare_mask;		/* IF don't-care bits */	ifm->ifm_change = change_callback;	ifm->ifm_status = status_callback;}voidifmedia_removeall(struct ifmedia *ifm){	struct ifmedia_entry *entry;	for (entry = LIST_FIRST(&ifm->ifm_list); entry;	     entry = LIST_FIRST(&ifm->ifm_list)) {		LIST_REMOVE(entry, ifm_list);		kfree(entry);	}}/* * Add a media configuration to the list of supported media * for a specific interface instance. */voidifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux){	register struct ifmedia_entry *entry;#ifdef IFMEDIA_DEBUG	if (ifmedia_debug) {		if (ifm == NULL) {			printk("ifmedia_add: null ifm\n");			return;		}		printk("Adding entry for ");		ifmedia_printword(mword);	}#endif	entry = kmalloc(sizeof(*entry), GFP_KERNEL);	if (entry == NULL)		panic("ifmedia_add: can't malloc entry");	entry->ifm_media = mword;	entry->ifm_data = data;	entry->ifm_aux = aux;	LIST_INSERT_HEAD(&ifm->ifm_list, entry, ifm_list);}/* * Add an array of media configurations to the list of * supported media for a specific interface instance. */voidifmedia_list_add(struct ifmedia *ifm, struct ifmedia_entry *lp, int count){	int i;	for (i = 0; i < count; i++)		ifmedia_add(ifm, lp[i].ifm_media, lp[i].ifm_data, lp[i].ifm_aux);}/* * Set the default active media.  * * Called by device-specific code which is assumed to have already * selected the default media in hardware.  We do _not_ call the * media-change callback. */voidifmedia_set(struct ifmedia *ifm, int target){	struct ifmedia_entry *match;	match = ifmedia_match(ifm, target, ifm->ifm_mask);	if (match == NULL) {		printk("ifmedia_set: no match for 0x%x/0x%x\n",			target, ~ifm->ifm_mask);		panic("ifmedia_set");	}	ifm->ifm_cur = match;#ifdef IFMEDIA_DEBUG	if (ifmedia_debug) {		printk("ifmedia_set: target ");		ifmedia_printword(target);		printk("ifmedia_set: setting to ");		ifmedia_printword(ifm->ifm_cur->ifm_media);	}#endif}/* * Device-independent media ioctl support function. */intifmedia_ioctl(struct net_device *dev, struct ifreq *ifr,	struct ifmedia *ifm, u_long cmd){	struct ifmedia_entry *match;	struct ifmediareq *ifmr = (struct ifmediareq *) ifr;	int error = 0, sticky;	if (dev == NULL || ifr == NULL || ifm == NULL)		return -EINVAL;	switch (cmd) {	/*	 * Set the current media.	 */	case  SIOCSIFMEDIA:	{		struct ifmedia_entry *oldentry;		int oldmedia;		int newmedia = ifr->ifr_media;		match = ifmedia_match(ifm, newmedia, ifm->ifm_mask);		if (match == NULL) {#ifdef IFMEDIA_DEBUG			if (ifmedia_debug) {				printk("ifmedia_ioctl: no media found for 0x%x\n", 					newmedia);			}#endif			return -ENXIO;		}		/*		 * If no change, we're done.		 * XXX Automedia may invole software intervention.		 *     Keep going in case the the connected media changed.		 *     Similarly, if best match changed (kernel debugger?).		 */		if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) &&		    (newmedia == ifm->ifm_media) &&		    (match == ifm->ifm_cur))			return 0;		/*		 * We found a match, now make the driver switch to it.		 * Make sure to preserve our old media type in case the		 * driver can't switch.		 */#ifdef IFMEDIA_DEBUG		if (ifmedia_debug) {			printk("ifmedia_ioctl: switching %s to ", dev->name);			ifmedia_printword(match->ifm_media);		}#endif		oldentry = ifm->ifm_cur;		oldmedia = ifm->ifm_media;		ifm->ifm_cur = match;		ifm->ifm_media = newmedia;		error = (*ifm->ifm_change)(dev);		if ((error < 0) && (error != -ENETRESET)) {			ifm->ifm_cur = oldentry;			ifm->ifm_media = oldmedia;		}		break;	}	/*	 * Get list of available media and current media on interface.	 */	case  SIOCGIFMEDIA: 	{		struct ifmedia_entry *ep;		int *kptr, count;		int usermax;	/* user requested max */		kptr = NULL;		/* XXX gcc */		ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ?			ifm->ifm_cur->ifm_media : IFM_NONE;		ifmr->ifm_mask = ifm->ifm_mask;		ifmr->ifm_status = 0;		(*ifm->ifm_status)(dev, ifmr);		count = 0;		usermax = 0;		/*		 * If there are more interfaces on the list, count		 * them.  This allows the caller to set ifmr->ifm_count		 * to 0 on the first call to know how much space to		 * allocate.		 */		LIST_FOREACH(ep, &ifm->ifm_list, ifm_list)			usermax++;		/*		 * Don't allow the user to ask for too many		 * or a negative number.		 */		if (ifmr->ifm_count > usermax)			ifmr->ifm_count = usermax;		else if (ifmr->ifm_count < 0)			return (-EINVAL);		if (ifmr->ifm_count != 0) {			kptr = (int *)kmalloc(ifmr->ifm_count * sizeof(int),			    GFP_KERNEL);			if (kptr == NULL)				return (-ENOMEM);			/*			 * Get the media words from the interface's list.			 */			ep = LIST_FIRST(&ifm->ifm_list);			for (; ep != NULL && count < ifmr->ifm_count;			    ep = LIST_NEXT(ep, ifm_list), count++)				kptr[count] = ep->ifm_media;			if (ep != NULL)				error = -E2BIG;	/* oops! */		} else			count = usermax;		/*		 * We do the copyout on E2BIG, because that's		 * just our way of telling userland that there		 * are more.  This is the behavior I've observed		 * under BSD/OS 3.0		 */		sticky = error;		if ((error == 0 || error == -E2BIG) && ifmr->ifm_count != 0) {			error = copy_to_user(ifmr->ifm_ulist,				kptr, ifmr->ifm_count * sizeof(int));		}		if (error == 0)			error = sticky;		if (ifmr->ifm_count != 0)			kfree(kptr);		ifmr->ifm_count = count;		break;	}	default:		return -EINVAL;	}	return error;}/* * Find media entry matching a given ifm word. * */struct ifmedia_entry *ifmedia_match(struct ifmedia *ifm, int target, int mask){	struct ifmedia_entry *match, *next;	match = NULL;	mask = ~mask;	LIST_FOREACH(next, &ifm->ifm_list, ifm_list) {		if ((next->ifm_media & mask) == (target & mask)) {#if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC)			if (match)				printk("ifmedia_match: multiple match for "					"0x%x/0x%x\n", target, mask);#endif			match = next;		}	}	return match;}#ifdef IFMEDIA_DEBUGstruct ifmedia_description ifm_type_descriptions[] =    IFM_TYPE_DESCRIPTIONS;struct ifmedia_description ifm_subtype_ethernet_descriptions[] =    IFM_SUBTYPE_ETHERNET_DESCRIPTIONS;struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] =    IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS;struct ifmedia_description ifm_subtype_tokenring_descriptions[] =    IFM_SUBTYPE_TOKENRING_DESCRIPTIONS;struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] =    IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS;struct ifmedia_description ifm_subtype_fddi_descriptions[] =    IFM_SUBTYPE_FDDI_DESCRIPTIONS;struct ifmedia_description ifm_subtype_fddi_option_descriptions[] =    IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS;struct ifmedia_description ifm_subtype_ieee80211_descriptions[] =    IFM_SUBTYPE_IEEE80211_DESCRIPTIONS;struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] =    IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS;struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] =    IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS;struct ifmedia_description ifm_subtype_shared_descriptions[] =    IFM_SUBTYPE_SHARED_DESCRIPTIONS;struct ifmedia_description ifm_shared_option_descriptions[] =    IFM_SHARED_OPTION_DESCRIPTIONS;struct ifmedia_type_to_subtype {		/* XXX: right place for declaration? */	struct ifmedia_description *subtypes;	struct ifmedia_description *options;	struct ifmedia_description *modes;};/* must be in the same order as IFM_TYPE_DESCRIPTIONS */struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = {	{ &ifm_subtype_ethernet_descriptions[0],	  &ifm_subtype_ethernet_option_descriptions[0],	  NULL, },	{ &ifm_subtype_tokenring_descriptions[0],	  &ifm_subtype_tokenring_option_descriptions[0],	  NULL, },	{ &ifm_subtype_fddi_descriptions[0],	  &ifm_subtype_fddi_option_descriptions[0],	  NULL, },	{ &ifm_subtype_ieee80211_descriptions[0],	  &ifm_subtype_ieee80211_option_descriptions[0],	  &ifm_subtype_ieee80211_mode_descriptions[0] },};/* * print a media word. */static voidifmedia_printword(int ifmw){	struct ifmedia_description *desc;	struct ifmedia_type_to_subtype *ttos;	int seen_option = 0;	/* Find the top-level interface type. */	for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes;	    desc->ifmt_string != NULL; desc++, ttos++)		if (IFM_TYPE(ifmw) == desc->ifmt_word)			break;	if (desc->ifmt_string == NULL) {		printk("<unknown type>\n");		return;	}	printk(desc->ifmt_string);	/* Any mode. */	for (desc = ttos->modes; desc && desc->ifmt_string != NULL; desc++)		if (IFM_MODE(ifmw) == desc->ifmt_word) {			if (desc->ifmt_string != NULL)				printk(" mode %s", desc->ifmt_string);			break;		}	/*	 * Check for the shared subtype descriptions first, then the	 * type-specific ones.	 */	for (desc = ifm_subtype_shared_descriptions;	    desc->ifmt_string != NULL; desc++)		if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)			goto got_subtype;	for (desc = ttos->subtypes; desc->ifmt_string != NULL; desc++)		if (IFM_SUBTYPE(ifmw) == desc->ifmt_word)			break;	if (desc->ifmt_string == NULL) {		printk(" <unknown subtype>\n");		return;	} got_subtype:	printk(" %s", desc->ifmt_string);	/*	 * Look for shared options.	 */	for (desc = ifm_shared_option_descriptions;	    desc->ifmt_string != NULL; desc++) {		if (ifmw & desc->ifmt_word) {			if (seen_option == 0)				printk(" <");			printk("%s%s", seen_option++ ? "," : "",			    desc->ifmt_string);		}	}	/*	 * Look for subtype-specific options.	 */	for (desc = ttos->options; desc->ifmt_string != NULL; desc++) {		if (ifmw & desc->ifmt_word) {			if (seen_option == 0)				printk(" <");			printk("%s%s", seen_option++ ? "," : "",			    desc->ifmt_string); 		}	}	printk("%s\n", seen_option ? ">" : "");}#endif /* IFMEDIA_DEBUG */EXPORT_SYMBOL(ifmedia_ioctl);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人网在线播放| 国产电影一区二区三区| 国产精品污www在线观看| 欧美电影免费观看高清完整版 | 2019国产精品| 69精品人人人人| 91精品国产品国语在线不卡| 51精品国自产在线| 日韩精品一区二区在线观看| 欧美电影免费提供在线观看| 欧美zozo另类异族| 国产亲近乱来精品视频| 亚洲欧洲在线观看av| 亚洲免费色视频| 亚洲图片有声小说| 蜜桃视频一区二区| 国产成人av在线影院| 99精品视频一区二区| 91丨国产丨九色丨pron| 91极品视觉盛宴| 欧美一区二区三区在线| 久久美女艺术照精彩视频福利播放| 欧美不卡一二三| 国产精品美女久久久久av爽李琼| 国产精品国产a级| 香港成人在线视频| 久久99精品久久久久婷婷| 99久久精品国产导航| 欧美日韩三级在线| 国产亚洲一本大道中文在线| 亚洲欧美一区二区不卡| 蜜臀av性久久久久蜜臀av麻豆| 国产精品一区免费视频| 欧美视频在线播放| 国产日产欧美一区| 午夜精品久久久久久| 成人伦理片在线| 制服.丝袜.亚洲.中文.综合| 日本一区二区免费在线观看视频| 玉足女爽爽91| 国产精品一区二区免费不卡 | 狠狠色狠狠色综合| 色国产综合视频| 日韩久久精品一区| 亚洲精品视频免费看| 国精品**一区二区三区在线蜜桃| 日本伦理一区二区| 国产欧美日韩综合精品一区二区| 日韩精品欧美精品| 91在线观看下载| 欧美精品一区二区三区蜜臀| 亚洲一区二区美女| 99久久精品国产麻豆演员表| 精品久久久久久最新网址| 亚洲成人av中文| 91在线观看地址| 国产精品白丝在线| 国产成人精品一区二| 欧美成人精品1314www| 亚洲成人免费视频| 色欧美日韩亚洲| 欧美国产1区2区| 国内外成人在线视频| 91精品国产黑色紧身裤美女| 一区二区三区鲁丝不卡| 99久久精品国产网站| 中文字幕成人在线观看| 国产剧情一区在线| 久久久午夜精品理论片中文字幕| 日韩国产欧美在线视频| 欧美日本乱大交xxxxx| 午夜在线成人av| 制服丝袜一区二区三区| 日日夜夜免费精品| 欧亚洲嫩模精品一区三区| 亚洲丝袜美腿综合| 91蝌蚪porny| 亚洲乱码中文字幕| 91久久线看在观草草青青| 亚洲色图制服诱惑| 色婷婷综合久久久久中文| 亚洲视频中文字幕| 在线一区二区三区四区五区 | 国产亲近乱来精品视频| 国产91丝袜在线18| 18欧美乱大交hd1984| 色婷婷激情久久| 亚洲一区二区欧美| 日韩欧美高清在线| 国产精品系列在线观看| 国产精品乱码一区二三区小蝌蚪| www.性欧美| 亚洲福利电影网| 日韩亚洲欧美一区| 国产精华液一区二区三区| 中文字幕一区二区三区在线播放| 99re视频精品| 视频在线在亚洲| 日韩精品一区二区三区三区免费| 国产成人免费在线观看| 亚洲男同1069视频| 欧美精品黑人性xxxx| 国模套图日韩精品一区二区| 亚洲色图清纯唯美| 欧美男人的天堂一二区| 国产一区二区精品久久99| **网站欧美大片在线观看| 欧美日韩精品一区二区三区| 国产乱一区二区| 一区二区免费看| 国产女人18水真多18精品一级做| 色婷婷综合久色| 国产成人一级电影| 亚洲成人一区二区| 国产欧美一区二区精品忘忧草| 欧美午夜片在线看| 国产成人免费在线观看不卡| 首页欧美精品中文字幕| 中文av一区二区| 精品欧美黑人一区二区三区| 欧美性极品少妇| 成人视屏免费看| 热久久久久久久| 亚洲综合在线观看视频| 精品福利在线导航| 欧美日韩不卡在线| 91性感美女视频| 国产91丝袜在线18| 久久精工是国产品牌吗| 亚洲成a人片综合在线| 国产精品三级av| 久久免费看少妇高潮| 欧美日本在线看| 欧美图片一区二区三区| 北条麻妃国产九九精品视频| 国产精品一区二区视频| 蜜臀国产一区二区三区在线播放| 亚洲一区二区黄色| 一区二区三区久久久| 亚洲欧美日韩成人高清在线一区| 久久久美女艺术照精彩视频福利播放| 欧美军同video69gay| 欧美日韩国产区一| 欧美日韩中文字幕一区二区| 91福利国产成人精品照片| 99久久综合精品| 懂色中文一区二区在线播放| 精品一区二区三区久久久| 日韩av不卡在线观看| 三级精品在线观看| 免费在线看成人av| 久久99久久99小草精品免视看| 三级欧美在线一区| 精彩视频一区二区三区| 久久国产精品免费| 国产精品综合二区| 成人一区二区三区| 99精品视频在线观看| 色综合久久久久网| 欧美日韩国产大片| 精品国产一区二区三区四区四| 久久久久亚洲蜜桃| 日本一区二区三区四区在线视频| 国产日韩一级二级三级| 国产精品乱码一区二区三区软件 | 亚洲午夜免费电影| 亚洲一级电影视频| 日韩电影免费一区| 久久99国产精品免费| 国产成人精品一区二 | 亚洲福利视频一区| 麻豆一区二区三区| 国产精品99久久久| 色综合视频一区二区三区高清| 欧美色综合网站| 日韩色视频在线观看| 欧美激情一区二区三区四区| 日韩美女啊v在线免费观看| 亚洲电影一区二区三区| 久久精品国产99久久6| www.av精品| 欧美一级二级三级乱码| 欧美国产欧美综合| 亚洲综合精品自拍| 激情六月婷婷综合| 色偷偷88欧美精品久久久| 日韩欧美三级在线| 亚洲美女屁股眼交3| 免费成人你懂的| 成人白浆超碰人人人人| 欧美日韩极品在线观看一区| 国产农村妇女精品| 日韩av一区二| 91丨porny丨户外露出| 欧美va亚洲va国产综合| 亚洲欧美国产77777| 国产一区二区三区久久悠悠色av| 91久久人澡人人添人人爽欧美| 久久久噜噜噜久久人人看| 亚洲777理论|