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

Class SourceIPField

scapy/fields.py:914–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

912
913
914class SourceIPField(IPField):
915 def __init__(self, name):
916 # type: (str) -> None
917 IPField.__init__(self, name, None)
918
919 def __findaddr(self, pkt):
920 # type: (Packet) -> Optional[str]
921 if conf.route is None:
922 # unused import, only to initialize conf.route
923 import scapy.route # noqa: F401
924 return pkt.route()[1] or conf.route.route()[1]
925
926 def i2m(self, pkt, x):
927 # type: (Optional[Packet], Optional[Union[str, Net]]) -> bytes
928 if x is None and pkt is not None:
929 x = self.__findaddr(pkt)
930 return super(SourceIPField, self).i2m(pkt, x)
931
932 def i2h(self, pkt, x):
933 # type: (Optional[Packet], Optional[Union[str, Net]]) -> str
934 if x is None and pkt is not None:
935 x = self.__findaddr(pkt)
936 return super(SourceIPField, self).i2h(pkt, x)
937
938
939class IP6Field(Field[Optional[Union[str, Net6]], bytes]):

Callers 3

IPClass · 0.90
ARPClass · 0.90
HSRPmd5Class · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected