3 [ -n "$INCLUDE_ONLY" ] ||
{
9 proto_directip_init_config
() {
12 proto_config_add_string
"device:device"
13 proto_config_add_string
"apn"
14 proto_config_add_string
"pincode"
15 proto_config_add_string
"auth"
16 proto_config_add_string
"username"
17 proto_config_add_string
"password"
18 proto_config_add_defaults
21 proto_directip_setup
() {
23 local chat devpath devname
25 local device apn pincode ifname auth username password
$PROTO_DEFAULT_OPTIONS
26 json_get_vars device apn pincode auth username password
$PROTO_DEFAULT_OPTIONS
28 [ -n "$ctl_device" ] && device
=$ctl_device
30 device
="$(readlink -f $device)"
32 proto_notify_error
"$interface" NO_DEVICE
33 proto_set_available
"$interface" 0
37 devname
="$(basename "$device")"
38 devpath
="$(readlink -f /sys/class/tty/$devname/device)"
39 ifname
="$( ls "$devpath"/../../*/net )"
42 proto_notify_error
"$interface" NO_IFNAME
43 proto_set_available
"$interface" 0
47 gcom
-d "$device" -s /etc
/gcom
/getcardinfo.gcom |
grep -q "Sierra Wireless" ||
{
48 proto_notify_error
"$interface" BAD_DEVICE
49 proto_block_restart
"$interface"
53 if [ -n "$pincode" ]; then
54 PINCODE
="$pincode" gcom
-d "$device" -s /etc
/gcom
/setpin.gcom ||
{
55 proto_notify_error
"$interface" PIN_FAILED
56 proto_block_restart
"$interface"
60 # wait for carrier to avoid firmware stability bugs
61 gcom
-d "$device" -s /etc
/gcom
/getcarrier.gcom ||
return 1
69 USE_APN
="$apn" USE_USER
="$username" USE_PASS
="$password" USE_AUTH
="$auth_type" \
70 gcom
-d "$device" -s /etc
/gcom
/directip.gcom ||
{
71 proto_notify_error
"$interface" CONNECT_FAILED
72 proto_block_restart
"$interface"
76 logger
-p daemon.info
-t "directip[$$]" "Connected, starting DHCP"
77 proto_init_update
"$ifname" 1
78 proto_send_update
"$interface"
81 json_add_string name
"${interface}_4"
82 json_add_string ifname
"@$interface"
83 json_add_string proto
"dhcp"
84 proto_add_dynamic_defaults
85 ubus call network add_dynamic
"$(json_dump)"
88 json_add_string name
"${interface}_6"
89 json_add_string ifname
"@$interface"
90 json_add_string proto
"dhcpv6"
91 json_add_string extendprefix
1
92 proto_add_dynamic_defaults
93 ubus call network add_dynamic
"$(json_dump)"
98 proto_directip_teardown
() {
104 [ -n "$ctl_device" ] && device
=$ctl_device
106 gcom
-d "$device" -s /etc
/gcom
/directip-stop.gcom || proto_notify_error
"$interface" CONNECT_FAILED
108 proto_init_update
"*" 0
109 proto_send_update
"$interface"
112 [ -n "$INCLUDE_ONLY" ] ||
{
113 add_protocol directip