]>
Commit | Line | Data |
---|---|---|
2b5c311d 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 | function ip_split_prefix() { | |
23 | local address=${1} | |
24 | ||
25 | assert isset address | |
26 | ||
27 | echo "${address%%/*}" | |
28 | } | |
29 | ||
30 | function ip_get_prefix() { | |
31 | local address=${1} | |
32 | ||
33 | assert isset address | |
34 | ||
35 | echo "${address##*/}" | |
36 | } | |
37 | ||
38 | function ip_detect_protocol() { | |
39 | local address=${1} | |
40 | ||
41 | assert isset address | |
42 | ||
43 | local protocol | |
44 | for protocol in ipv4 ipv6; do | |
45 | if ${protocol}_is_valid ${address}; then | |
46 | echo "${protocol}" | |
47 | return ${EXIT_OK} | |
48 | fi | |
49 | done | |
50 | ||
51 | return ${EXIT_ERROR} | |
52 | } |