zoukankan      html  css  js  c++  java
  • Android教程:wifi热点问题

    http://www.linuxidc.com/Linux/2012-05/60718.htm

    现在很多移动设备都提供wifi hostpot功能,使用方便,也省下了原来无线路由器的成本。wifi和wifi hotspot功能是互斥的,即在同一时间里,你只能用其中一种功能。在Android较新版本(2.2之后)中已经实现,本文实现在命令行模式下完成wifi hotspot功能的启动,并简单介绍其中涉及到的相关工具。

     
    0、确保eth0可以访问网络
     
    1、修改framework/base/core/res/res/values/config.xml
    1. <!-- List of regexpressions describing the interface (if any) that represent tetherable 
      Wifi interfaces. If the device doesn't want to support tethering over Wifi this 
      should be empty. An example would be "softap.*" --> 
      <string-array translatable="false" name="config_tether_wifi_regexs"> 
      <item>"wlap0"</item> 
      </string-array> 
      <!-- Dhcp range (min, max) to use for tethering purposes --> 
      <string-array translatable="false" name="config_tether_dhcp_range"> 
      </string-array> 
      <!-- Regex array of allowable upstream ifaces for tethering - for example if you want 
      tethering on a new interface called "foo2" add <item>"foo\d"</item> to the array --> 
      <string-array translatable="false" name="config_tether_upstream_regexs"> 
      <item>"eth0"</item> 
      <item>"ppp0"</item> 
      <item>"wlan0"</item> 
      </string-array> 
     
    2、加载wifi驱动(我这使用的是atheros)
    insmod /system/wifi/ar6000.ko ifname=wlap0
    若成功的话,则第3、4、5步自动执行。
     
    3、设置IP地址
    /system/bin/ifconfig wlap0 192.168.100.1 netmask 255.255.255.0
     
    4、iptables设置
    echo 1 > /proc/sys/net/ipv4/ip_forward
    /system/bin/iptables -A FORWARD -i wlap0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT 
    /system/bin/iptables -A FORWARD -i wlap0 -o eth0 -j ACCEPT 
    /system/bin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
     
    5、dnsmasq设置
    /system/bin/dnsmasq --no-daemon --no-resolv --no-poll --dhcp-range=192.168.100.100,192.168.100.200,100h
    当然也可以把相关配置写成文件再执行dnsmasq --conf-file=/*/dnsmasq.conf
     
    6、启动hostapd
    /system/bin/hostapd_wps -dd /data/misc/wifi/hostapd.conf
     
    出现的问题
    1、执行上述命令后,客户端去连接的时候获取不到IP地址,重新启动hostapd就OK?
    可以采用如下方法修正
    /sytem/bin/ndc softap set eth0 wlap0 djstava open
    /system/bin/ndc softap start
    /system/bin/ndc/softap startap
  • 相关阅读:
    怎样在ASP.NET中使用VB.NET上传大文件
    准备开始研读petShop
    Documentum常见问题9—导航树的一些常见设置
    [转]CMMI 入门 基本术语:约束、假设、依赖、风险、承诺
    MyEclipse 8.6反编译插件安装
    Documentum常见问题7—为客户化Type类型Import时添加自定义属性
    【自省篇】程序员的十大技术烦恼
    Documentum常见问题10修改特定Type的显示图标
    打发时间的题目,每天做一点
    Documentum常见问题8—限制导航树上的文件夹个数
  • 原文地址:https://www.cnblogs.com/leaven/p/3520440.html
Copyright © 2011-2022 走看看