Opennet Firmware
olsr_parse_service_descriptions.awk
gehe zur Dokumentation dieser Datei
1# formatting details: see "get_olsr_service"
2
3BEGIN { OFS = "\t"; }
4{
5 # example input:
6 # openvpn://192.168.2.191:5101|udp|gw public_host:subaru.opennet-initiative.de upload:293 download:11786 #192.168.2.191
7 if ($1 && ($1 ~ /^[^#]/)) {
8 # remove trailing " #..." (describing the source of the announcement)
9 sub("[[:blank:]]+#.*$", "", $0);
10
11 split($0, tokens, "|");
12
13 # parse the first part, e.g. "openvpn://192.168.2.191:5101"
14 split(tokens[1], url_tokens, ":");
15 scheme = url_tokens[1];
16 host = substr(url_tokens[2], 3);
17 split(url_tokens[3], port_and_path, "/");
18 port = port_and_path[1];
19 path = "/" port_and_path[2];
20
21 protocol = tokens[2];
22 details_count = split(tokens[3], service_and_details) - 1;
23 service = service_and_details[1];
24 if (details_count > 0) {
25 details = tokens[3];
26 sub("^[^ ]+ ", "", details);
27 } else {
28 details = "";
29 }
30
31 if ((scheme == "http") && (port == "8080") && (protocol == "tcp") && ((service == "gw") || (service == "ugw"))) {
32 scheme = "openvpn";
33 port = "1600";
34 protocol = "udp";
35 service = "gw";
36 }
37 print(service, scheme, host, port, protocol, path, details);
38 }
39}