MCPcopy Create free account
hub / github.com/secdev/scapy / DestMACField

Class DestMACField

scapy/layers/l2.py:198–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196# Fields
197
198class DestMACField(MACField):
199 def __init__(self, name):
200 # type: (str) -> None
201 MACField.__init__(self, name, None)
202
203 def i2h(self, pkt, x):
204 # type: (Optional[Packet], Optional[str]) -> str
205 if x is None and pkt is not None:
206 x = None
207 return super(DestMACField, self).i2h(pkt, x)
208
209 def i2m(self, pkt, x):
210 # type: (Optional[Packet], Optional[str]) -> bytes
211 if x is None and pkt is not None:
212 try:
213 x = conf.neighbor.resolve(pkt, pkt.payload)
214 except socket.error:
215 pass
216 if x is None:
217 if conf.raise_no_dst_mac:
218 raise ScapyNoDstMacException()
219 else:
220 x = "ff:ff:ff:ff:ff:ff"
221 warning(
222 "MAC address to reach destination not found. Using broadcast."
223 )
224 return super(DestMACField, self).i2m(pkt, x)
225
226
227class SourceMACField(MACField):

Callers 2

EtherClass · 0.85
Dot3Class · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…