OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #!/bin/sh |
2 | |||
3 | [ -n "$INCLUDE_ONLY" ] || { |
||
4 | . /lib/functions.sh |
||
5 | . /lib/functions/network.sh |
||
6 | . ../netifd-proto.sh |
||
7 | init_proto "$@" |
||
8 | } |
||
9 | |||
10 | proto_ipip_setup() { |
||
11 | local cfg="$1" |
||
12 | local remoteip |
||
13 | |||
14 | local df ipaddr peeraddr tunlink ttl tos zone mtu |
||
15 | json_get_vars df ipaddr peeraddr tunlink ttl tos zone mtu |
||
16 | |||
17 | [ -z "$peeraddr" ] && { |
||
18 | proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" |
||
19 | proto_block_restart "$cfg" |
||
20 | return |
||
21 | } |
||
22 | |||
23 | remoteip=$(resolveip -t 10 -4 "$peeraddr") |
||
24 | |||
25 | if [ -z "$remoteip" ]; then |
||
26 | proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" |
||
27 | return |
||
28 | fi |
||
29 | |||
30 | for ip in $remoteip; do |
||
31 | peeraddr=$ip |
||
32 | break |
||
33 | done |
||
34 | |||
35 | ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) |
||
36 | |||
37 | [ -z "$ipaddr" ] && { |
||
38 | local wanif="$tunlink" |
||
39 | if [ -z $wanif ] && ! network_find_wan wanif; then |
||
40 | proto_notify_error "$cfg" "NO_WAN_LINK" |
||
41 | return |
||
42 | fi |
||
43 | |||
44 | if ! network_get_ipaddr ipaddr "$wanif"; then |
||
45 | proto_notify_error "$cfg" "NO_WAN_LINK" |
||
46 | return |
||
47 | fi |
||
48 | } |
||
49 | |||
3 | office | 50 | [ -z "$zone" ] && zone="wan" |
51 | |||
1 | office | 52 | proto_init_update "ipip-$cfg" 1 |
53 | |||
54 | proto_add_tunnel |
||
55 | json_add_string mode "ipip" |
||
56 | json_add_int mtu "${mtu:-1280}" |
||
57 | json_add_int ttl "${ttl:-64}" |
||
58 | [ -n "$tos" ] && json_add_string tos "$tos" |
||
59 | json_add_string local "$ipaddr" |
||
60 | json_add_string remote "$peeraddr" |
||
61 | [ -n "$tunlink" ] && json_add_string link "$tunlink" |
||
62 | json_add_boolean df "${df:-1}" |
||
63 | |||
64 | proto_close_tunnel |
||
65 | |||
66 | proto_add_data |
||
67 | [ -n "$zone" ] && json_add_string zone "$zone" |
||
68 | proto_close_data |
||
69 | |||
70 | proto_send_update "$cfg" |
||
71 | } |
||
72 | |||
73 | proto_ipip_teardown() { |
||
74 | local cfg="$1" |
||
75 | } |
||
76 | |||
77 | proto_ipip_init_config() { |
||
78 | no_device=1 |
||
79 | available=1 |
||
80 | |||
81 | proto_config_add_int "mtu" |
||
82 | proto_config_add_int "ttl" |
||
83 | proto_config_add_string "tos" |
||
84 | proto_config_add_string "tunlink" |
||
85 | proto_config_add_string "zone" |
||
86 | proto_config_add_string "ipaddr" |
||
87 | proto_config_add_string "peeraddr" |
||
88 | proto_config_add_boolean "df" |
||
89 | } |
||
90 | |||
91 | [ -n "$INCLUDE_ONLY" ] || { |
||
92 | add_protocol ipip |
||
93 | } |