diff options
Diffstat (limited to 'tools/make-services.py')
-rwxr-xr-x | tools/make-services.py | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tools/make-services.py b/tools/make-services.py index 0f832bec..db2afd3d 100755 --- a/tools/make-services.py +++ b/tools/make-services.py @@ -9,6 +9,14 @@ # # SPDX-License-Identifier: GPL-2.0-or-later +import sys +import getopt +import csv +import re +import collections +import urllib.request, urllib.error, urllib.parse +import codecs + iana_svc_url = 'https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv' __doc__ = '''\ @@ -18,13 +26,6 @@ url defaults to %s ''' % (iana_svc_url) -import sys -import getopt -import csv -import re -import collections -import urllib.request, urllib.error, urllib.parse -import codecs services_file = 'epan/services-data.c' @@ -105,7 +106,7 @@ def parse_rows(svc_fd): if description == service or description == service.replace("-", " "): description = None - if not port in services_map: + if port not in services_map: services_map[port] = collections.OrderedDict() # Remove some duplicates (first entry wins) @@ -117,7 +118,7 @@ def parse_rows(svc_fd): if proto_exists: continue - if not service in services_map[port]: + if service not in services_map[port]: services_map[port][service] = [description] services_map[port][service].append(proto) @@ -229,10 +230,12 @@ def main(argv): * service names, e.g. TCP port 80 -> http. * * It is subject to copyright and being used with IANA's permission: - * https://www.wireshark.org/lists/wireshark-dev/200708/msg00160.html + * https://lists.wireshark.org/archives/wireshark-dev/200708/msg00160.html * * The original file can be found at: * %s + * + * Generated by tools/make-services.py */ ''' % (iana_svc_url)) @@ -259,27 +262,27 @@ def main(argv): return e[0] return max_port - out.write("static ws_services_entry_t global_tcp_udp_services_table[] = {\n") + out.write("static const ws_services_entry_t global_tcp_udp_services_table[] = {\n") for e in tcp_udp: max_port = write_entry(out, e, max_port) out.write("};\n\n") - out.write("static ws_services_entry_t global_tcp_services_table[] = {\n") + out.write("static const ws_services_entry_t global_tcp_services_table[] = {\n") for e in tcp: max_port = write_entry(out, e, max_port) out.write("};\n\n") - out.write("static ws_services_entry_t global_udp_services_table[] = {\n") + out.write("static const ws_services_entry_t global_udp_services_table[] = {\n") for e in udp: max_port = write_entry(out, e, max_port) out.write("};\n\n") - out.write("static ws_services_entry_t global_sctp_services_table[] = {\n") + out.write("static const ws_services_entry_t global_sctp_services_table[] = {\n") for e in sctp: max_port = write_entry(out, e, max_port) out.write("};\n\n") - out.write("static ws_services_entry_t global_dccp_services_table[] = {\n") + out.write("static const ws_services_entry_t global_dccp_services_table[] = {\n") for e in dccp: max_port = write_entry(out, e, max_port) out.write("};\n\n") |