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"
20 proto_directip_setup
() {
22 local chat devpath devname
24 local device apn pincode ifname auth username password
25 json_get_vars device apn pincode auth username password
27 [ -n "$ctl_device" ] && device
=$ctl_device
30 proto_notify_error
"$interface" NO_DEVICE
31 proto_set_available
"$interface" 0
35 devname
="$(basename "$device")"
36 devpath
="$(readlink -f /sys/class/tty/$devname/device)"
37 ifname
="$( ls "$devpath"/../../*/net )"
40 proto_notify_error
"$interface" NO_IFNAME
41 proto_set_available
"$interface" 0
45 cardinfo
=$
(gcom
-d "$device" -s /etc
/gcom
/getcardinfo.gcom
)
46 [ -n $
(echo "$cardinfo" |
grep -q "Sierra Wireless") ] ||
{
47 proto_notify_error
"$interface" BAD_DEVICE
48 proto_block_restart
"$interface"
52 if [ -n "$pincode" ]; then
53 PINCODE
="$pincode" gcom
-d "$device" -s /etc
/gcom
/setpin.gcom ||
{
54 proto_notify_error
"$interface" PIN_FAILED
55 proto_block_restart
"$interface"
59 # wait for carrier to avoid firmware stability bugs
60 gcom
-d "$device" -s /etc
/gcom
/getcarrier.gcom ||
return 1
68 USE_APN
="$apn" USE_USER
="$username" USE_PASS
="$password" USE_AUTH
="$auth_type" \
69 gcom
-d "$device" -s /etc
/gcom
/directip.gcom ||
{
70 proto_notify_error
"$interface" CONNECT_FAILED
71 proto_block_restart
"$interface"
75 logger
-p daemon.info
-t "directip[$$]" "Connected, starting DHCP"
76 proto_init_update
"$ifname" 1
77 proto_send_update
"$interface"
80 json_add_string name
"${interface}_4"
81 json_add_string ifname
"@$interface"
82 json_add_string proto
"dhcp"
83 ubus call network add_dynamic
"$(json_dump)"
86 json_add_string name
"${interface}_6"
87 json_add_string ifname
"@$interface"
88 json_add_string proto
"dhcpv6"
89 json_add_string extendprefix
1
90 ubus call network add_dynamic
"$(json_dump)"
95 proto_directip_teardown
() {
101 [ -n "$ctl_device" ] && device
=$ctl_device
103 gcom
-d "$device" -s /etc
/gcom
/directip-stop.gcom || proto_notify_error
"$interface" CONNECT_FAILED
105 proto_init_update
"*" 0
106 proto_send_update
"$interface"
109 [ -n "$INCLUDE_ONLY" ] ||
{
110 add_protocol directip