]>
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 | ||
e617226b MT |
22 | # A list of supported versions of the IP protocol |
23 | IP_SUPPORTED_PROTOCOLS="" | |
24 | ||
2b5c311d MT |
25 | function ip_split_prefix() { |
26 | local address=${1} | |
27 | ||
28 | assert isset address | |
29 | ||
30 | echo "${address%%/*}" | |
31 | } | |
32 | ||
33 | function ip_get_prefix() { | |
34 | local address=${1} | |
35 | ||
36 | assert isset address | |
37 | ||
38 | echo "${address##*/}" | |
39 | } | |
40 | ||
41 | function ip_detect_protocol() { | |
42 | local address=${1} | |
43 | ||
44 | assert isset address | |
45 | ||
46 | local protocol | |
e617226b | 47 | for protocol in ${IP_SUPPORTED_PROTOCOLS}; do |
2b5c311d MT |
48 | if ${protocol}_is_valid ${address}; then |
49 | echo "${protocol}" | |
50 | return ${EXIT_OK} | |
51 | fi | |
52 | done | |
53 | ||
54 | return ${EXIT_ERROR} | |
55 | } | |
e617226b MT |
56 | |
57 | function ip_protocol_is_supported() { | |
58 | local proto=${1} | |
59 | ||
60 | assert isset proto | |
61 | ||
62 | listmatch ${proto} ${IP_SUPPORTED_PROTOCOLS} | |
63 | } |