]>
Commit | Line | Data |
---|---|---|
b73e9d43 MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | . /usr/lib/network/header-config | |
23 | ||
636f1b96 MT |
24 | HOOK_SETTINGS=( |
25 | "PRIVACY_EXTENSIONS" | |
26 | ) | |
b73e9d43 MT |
27 | |
28 | # Privacy Extensions are disabled by default | |
636f1b96 | 29 | DEFAULT_PRIVACY_EXTENSIONS="off" |
b73e9d43 | 30 | |
1c6a4e30 | 31 | hook_check_config_settings() { |
b73e9d43 MT |
32 | assert isbool PRIVACY_EXTENSIONS |
33 | } | |
34 | ||
6ca65afb | 35 | hook_parse_cmdline() { |
320f1fda JS |
36 | local id="${1}" |
37 | shift | |
38 | ||
6ca65afb | 39 | local arg |
b73e9d43 MT |
40 | while read arg; do |
41 | case "${arg}" in | |
42 | --privacy-extensions=*) | |
636f1b96 | 43 | PRIVACY_EXTENSIONS="$(cli_get_bool "${arg}")" |
b73e9d43 MT |
44 | ;; |
45 | esac | |
2212045f | 46 | done <<< "$(args "$@")" |
6ca65afb JS |
47 | } |
48 | ||
1c6a4e30 | 49 | hook_up() { |
b73e9d43 MT |
50 | local zone=${1} |
51 | shift | |
52 | ||
53 | if ! device_exists ${zone}; then | |
54 | error "Zone '${zone}' doesn't exist." | |
55 | exit ${EXIT_ERROR} | |
56 | fi | |
57 | ||
58 | zone_config_settings_read "${zone}" "${HOOK}" | |
59 | ||
60 | # Enable IPv6 auto-configuration | |
61 | ipv6_device_autoconf_enable "${zone}" | |
62 | ||
63 | # Set up privacy extensions (RFC3041) | |
64 | if enabled PRIVACY_EXTENSIONS; then | |
65 | ipv6_device_privacy_extensions_enable "${zone}" | |
66 | else | |
67 | ipv6_device_privacy_extensions_disable "${zone}" | |
68 | fi | |
69 | ||
70 | exit ${EXIT_OK} | |
71 | } | |
72 | ||
1c6a4e30 | 73 | hook_down() { |
b73e9d43 MT |
74 | local zone=${1} |
75 | local config=${2} | |
76 | shift 2 | |
77 | ||
78 | if ! device_exists ${zone}; then | |
79 | error "Zone '${zone}' doesn't exist." | |
80 | exit ${EXIT_ERROR} | |
81 | fi | |
82 | ||
83 | # Disable IPv6 auto-configuration | |
84 | ipv6_device_autoconf_disable "${zone}" | |
85 | ||
86 | exit ${EXIT_OK} | |
87 | } | |
88 | ||
1c6a4e30 | 89 | hook_status() { |
b73e9d43 MT |
90 | local zone=${1} |
91 | local config=${2} | |
92 | shift 2 | |
93 | ||
94 | if ! device_exists ${zone}; then | |
95 | error "Zone '${zone}' doesn't exist." | |
96 | exit ${EXIT_ERROR} | |
97 | fi | |
98 | ||
99 | zone_config_settings_read "${zone}" "${config}" | |
100 | ||
101 | local addresses=$(ipv6_device_get_addresses "${zone}" --scope="global") | |
102 | local status | |
103 | if isset addresses; then | |
104 | status="${MSG_HOOK_UP}" | |
105 | else | |
106 | status="${MSG_HOOK_DOWN}" | |
107 | fi | |
108 | cli_statusline 3 "${HOOK}" "${status}" | |
109 | ||
110 | if enabled PRIVACY_EXTENSIONS; then | |
111 | cli_print_fmt1 3 "Privacy Extensions enabled" | |
112 | cli_space | |
113 | fi | |
114 | ||
115 | local addr | |
116 | for addr in ${addresses}; do | |
117 | cli_print_fmt1 3 "IPv6 address" "${addr}" | |
118 | done | |
119 | cli_space | |
120 | ||
121 | exit ${EXIT_OK} | |
122 | } |