aboutsummaryrefslogtreecommitdiff
path: root/utils/toripaddr2list.py
blob: 47c5412e5371812e6a6ea7e03ca25e5e5a5921f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3

import sys
import socket, struct

if len (sys.argv) != 2 :
    print("Usage: toripaddr2list.py <file>")
    sys.exit (1)
            
with open(sys.argv[1]) as fp:
    for cnt, line in enumerate(fp):
        x = line.rstrip().split("/")
        ipaddr = x[0]
        cidr   = x[1]
        
        if(cidr == None):
            cidr = "32"

        print(" { 0x"+socket.inet_aton(ipaddr).hex().upper()+" /* "+ipaddr+"/"+cidr+" */, "+cidr+", NDPI_PROTOCOL_XYX },")