- 테더링은 /system/bin/ndc 을 사용 하여 네트워크 설정을 하는 것으로 보임.
Below are commands that Android talking to netd to start/stop tethering.
1. Start tethering
"softap fwreload wlan0 AP"
"softap start wlan0"
"softap set wlan0 wl0.1 hotspot456 open null 6 0 8"
"softap startap"
"interface getcfg wlan0"
"interface setcfg wlan0 192.168.43.1 24 [up]"
"tether interface add wlan0"
"ipfwd enable"
"tether start 192.168.43.2 192.168.43.254"
"tether dns set 10.177.0.34 10.180.12.172"
"nat enable wlan0 rmnet0 2 fe80::/64 192.168.43.0/24"
2. Stop tethering
"interface getcfg wlan0"
"interface setcfg wlan0 0.0.0.0 0 [up broadcast running multicast]"
"softap stopap"
"softap stop wlan0"
"softap fwreload wlan0 STA"
"nat disable wlan0 rmnet0 0"
"tether interface remove wlan0"
"tether stop"
"ipfwd disable"
-
관련 유틸리티를 부르는 부분은 안드로이드 문서에 나와 있음
-
예전 버전 4.xx에서는 아예 인터페이스를 다이렉트하게 불러 버림
- "tether interface add" 로 구글링 해 볼 것.
- 해당 명령은 그냥 masq -> ip_forw로 돌림. 즉 TTL값은 해당 코드를 탈 것임.
-
롤리팝의 경우 분석: https://dreamlog.tistory.com/452
-
8.0+ 이상에서는 구조가 바뀜.
# services/core/java/com/android/server/connectivity/Tethering.java
enableTetheringInternal
INetworkManagementService
mNMService.startTethering