Example #1
0
 def subnetentry(x):
     ''' Generate a subnet declaration block given an IPv6 prefix string
         for inclusion in the RADVD config file.
     '''
     if x.find(":") >= 0:
         net = IPv6Prefix(x)
         return str(net)
     else:
         return ""
Example #2
0
 def addrstr(x):
     if x.find(":") >= 0:
         net = IPv6Prefix(x)
         fam = "inet6 ::"
     else:
         net = IPv4Prefix(x)
         fam = "inet 0.0.0.0"
     if net.maxaddr() == net.minaddr():
         return ""
     else:
         if os.uname()[0] == "Linux":
             rtcmd = "ip route add default via"
         elif os.uname()[0] == "FreeBSD":
             rtcmd = "route add -%s" % fam
         else:
             raise Exception, "unknown platform"
         return "%s %s" % (rtcmd, net.minaddr())
Example #3
0
 def routestr(x):
     if x.find(":") >= 0:
         net = IPv6Prefix(x)
         fam = "inet6"
         dst = "3ffe:4::/64"
     else:
         net = IPv4Prefix(x)
         fam = "inet"
         dst = "10.9.8.0/24"
     if net.maxaddr() == net.minaddr():
         return ""
     else:
         if os.uname()[0] == "Linux":
             rtcmd = "#/sbin/ip route add %s via" % dst
         elif os.uname()[0] == "FreeBSD":
             rtcmd = "#/sbin/route add -%s %s" % (fam, dst)
         else:
             raise Exception, "unknown platform"
         return "%s %s" % (rtcmd, net.minaddr())