MCPcopy Index your code
hub / github.com/secdev/scapy / make_route

Method make_route

scapy/route.py:64–89  ·  view source on GitHub ↗
(self,
                   host=None,  # type: Optional[str]
                   net=None,  # type: Optional[str]
                   gw=None,  # type: Optional[str]
                   dev=None,  # type: Optional[str]
                   metric=1,  # type: int
                   )

Source from the content-addressed store, hash-verified

62 [("Network", "Netmask", "Gateway", "Iface", "Output IP", "Metric")]) # noqa: E501
63
64 def make_route(self,
65 host=None, # type: Optional[str]
66 net=None, # type: Optional[str]
67 gw=None, # type: Optional[str]
68 dev=None, # type: Optional[str]
69 metric=1, # type: int
70 ):
71 # type: (...) -> Tuple[int, int, str, str, str, int]
72 if host is not None:
73 thenet, msk = host, 32
74 elif net is not None:
75 thenet, msk_b = net.split("/")
76 msk = int(msk_b)
77 else:
78 raise Scapy_Exception("make_route: Incorrect parameters. You should specify a host or a net") # noqa: E501
79 if gw is None:
80 gw = "0.0.0.0"
81 if dev is None:
82 if gw:
83 nhop = gw
84 else:
85 nhop = thenet
86 dev, ifaddr, _ = self.route(nhop)
87 else:
88 ifaddr = "0.0.0.0" # acts as a 'via' in `ip addr add`
89 return (atol(thenet), itom(msk), gw, dev, ifaddr, metric)
90
91 def add(self, *args, **kargs):
92 # type: (*Any, **Any) -> None

Callers 2

addMethod · 0.95
deltMethod · 0.95

Calls 4

routeMethod · 0.95
Scapy_ExceptionClass · 0.90
atolFunction · 0.90
itomFunction · 0.90

Tested by

no test coverage detected