⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rc.wlan

📁 Linux Wireless LAN Project 的目标是开发一个完整的
💻 WLAN
字号:
#! /bin/sh# Wireless network setup for ISA cards#  (this file can safely be re-executed for restarts)# History:#   1999-jun        Created #   1999-jul-4	    Optimized for restarts#   1999-nov-5      MSM-Modified for 0.3.4# Due to the odd way WLAN cards need to be setup, we're executing this # not until the whole system has been setup. So, typically, this# rc.wlan script can be executed via rc.local## One of the issues here is the way that the driver allocates its device# name.  Some drivers can be explicitly told what device name to use, # linux-wlan doesn't currently support that.  So to make sure your existing# eth?? devices use the names they did before installing the wlan card,# you need to make sure you don't load the am930_isa module before your# ethernet modules.  On a redhat system, the ethernet modules are loaded# (for run level 3) by /etc/rc.d/rc3.d/S10network.  This script can be run# any time after that.## You can still use a redhat network setup, but use ONBOOT=no# You can then use 'ifup eth1' and 'ifdown eth1' at will while the# system is running. In that case you can leave out the IP code# below, and leave the IP setup to the redhat scripts # (see /etc/sysconfig/network-scripts).is_true (){    [ "$1" = "y" -o "$1" = "Y" -o "$1" = "yes" -o "$1" = "YES" ]}#########################################################################		kernel version, probably you should not tamper with this#		with the possible exception of simply using M=am930_isa V=`uname -r`M=/lib/modules/$V/net/am930_isa.o #########################################################################	MAC Setup Variables	# Scan for which SSID?	SCAN_SSID=""#	DESIRED_SSID="WORK_BSS"	DESIRED_SSID="HOME_BSS"	# Scan for which BSS and type?	SCAN=yes				# yes|no	SCAN_BSSID="ff:ff:ff:ff:ff:ff"	SCAN_BSSTYPE=both		# both|ind|infr	SCAN_TYPE=active		# active|passive		# Define scan range	SCAN_STARTCH=1	SCAN_ENDCH=11	SCAN_TIMEPERCHANNEL=100	# Create a BSS if one not detected?	CREATEBSS=no	CREATE_SSID=BreakInPlease	# Pick your own SSID and channel!!!	CREATE_CHANNEL=1	CREATE_BCN_INT=100	# Are we only sniffing? (don't auth and assoc)	SNIFONLY=n	# Frame conversion type	P80211_CONVERSION=rfc1042	# encapsulation|rfc1042|802.1h	# Wep stuff  (currently unsupported, Don't turn it on!)	PRIVACY=no	WEP_EXCLUDE=noexclude_unencrypted	WEP_DEFKEY=0	WEP_KEY1="f1:10:ec:e0:dc"	WEP_KEY2="0f:f2:04:09:fb"	WEP_KEY3="13:37:f2:f9:2d"	WEP_KEY4="e9:17:19:63:c7"#########################################################################	WLAN PnP setup (needs to be consistent w/ your /etc/isapnp.conf)IRQ=9IOBASE=0x240######################################################################### 	Network stack setup, comment out IP= if you don't want to do #	this here but through your linux distribution's setup scriptsDEVICE=eth1		IP=192.168.2.31NM=255.255.255.0# next two can be derived from the above two, be careful how you do thatBC=192.168.2.255NW=192.168.2.0#########################################################################  Insert the AM930 module:#  remember, for ISA don't use rmmod, it may hang your kernel.#  this is a bug in the driver that needs to be cleared#  however, we can safely down the interface,  wlanctl and up it again##	only insert the module if it had not been inserted before#	never rmmod this module, it is buggy to remove and safe to leave incnt=`lsmod | grep -c ^am930`if [ "$cnt" != "0" ]; then  echo Module $M had already been loaded, no need to rmmod/insmodelse  insmod $M am930_irq=$IRQ am930_iobase=$IOBASEfiif is_true "$SCAN"; then	# Scan for existing networks	echo "wlan scanning channels $STARTCH to $ENDCH"	netlist=`wlanctl $DEVICE scan \		$SCAN_STARTCH $SCAN_ENDCH $SCAN_TIMEPERCHANNEL \		$SCAN_BSSID $SCAN_BSSTYPE $SCAN_TYPE "$SCAN_SSID"`	echo "Detected BSSs:"	echo "ch  bssid              bcn   cap_info  ssid"	echo "------------------------------------------------------"	echo "$netlist"fi# Set your wep keys, if present# MSM: setting them works, but there's no cypher so strange things#      might happen. See README.wep.if is_true $PRIVACY ; then	wlanctl $DEVICE privacy \		$EXCLUDE \		$WEP_DEFKEY \		$WEP_KEY1 \		$WEP_KEY2 \		$WEP_KEY3 \		$WEP_KEY4fi# Set the ethernet conversionwlanctl $DEVICE ethconv $P80211_CONVERSION# If our $SCAN_SSID matches one found in the scan, join it.  #  else, check to see if we're allowed to create one.if (echo "$netlist" | grep -q "$DESIRED_SSID") ; then	join_bssinfo=`(echo "$netlist" | grep "$DESIRED_SSID")`	join_ssid=$DESIRED_SSID	join_bssid=`(echo "$join_bssinfo" | cut -c5-21)`	join_channel=`(echo "$join_bssinfo" | cut -c1-2)`	join_capinfo=`(echo "$join_bssinfo" | cut -c30-35)`	wlanctl $DEVICE bssjoin $join_bssid	echo "wlan joined BSS, channel=$join_channel"\	     "bssid=$join_bssid ssid=\"$DESIRED_SSID\""	# Now see if we need to auth and assoc w/ an infra bss	if is_true $SNIFONLY; then		echo "wlan skipping auth and assoc for sniffer"	else		ISIBSS=$[$join_capinfo & 0x02]		if [ $ISIBSS -eq 0 ]; then			wlanctl $DEVICE authen			wlanctl $DEVICE assoc		fi	fielse	# If we're allowed, create a bss	if is_true $CREATEBSS ; then		wlanctl $DEVICE bsscreate \			$CREATE_CHANNEL $CREATE_BCN_INT 0 \			"$CREATE_SSID"		echo "wlan created BSS with" \			"channel=$CREATE_CHANNEL and" \			"ssid=$CREATE_SSID"		$DESIRED_SSID=$CREATE_SSID	else		echo "wlan failed to find ssid=$DESIRED_SSID"		exit 1	fifi########################################################################if [ "$IP" = "" ]; then  echo $DEVICE not activated, relying on your own methods to do this  exit 0fi# start up the network	(you can leave this out if your Linux#			 implementation does that work for you)#			e.g. redhat would use  "ifup $DEVICE"ifconfig $DEVICE $IP broadcast $BC netmask $NM # on kernel 2.2 don't need to route, ifconfig does it for you# if you do this, it will show two routes, it doesn't seem to hurtroute add -net $NW  netmask $NM $DEVICE# Add static routes.Make sure you add the reverse routes on the other end# route my regular ELAN#route add -net 192.168.1.0 gw wxavier#  the official redhat way#  1) add entry to /etc/conf.modules#  2) add a wlantcl initialization routine to /etc/rc.d/init.d#     and set the appropriate startup inbetween #1 and #3#  3) add eth1 interface to network via 'netcfg'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -