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

Method encap

scapy/contrib/macsec.py:120–133  ·  view source on GitHub ↗

encapsulate a frame using this Secure Association

(self, pkt)

Source from the content-addressed store, hash-verified

118 return 0
119
120 def encap(self, pkt):
121 """encapsulate a frame using this Secure Association"""
122 if pkt.name != Ether().name:
123 raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet') # noqa: E501
124 hdr = copy.deepcopy(pkt)
125 payload = hdr.payload
126 del hdr.payload
127 tag = MACsec(SCI=self.sci, AN=self.an,
128 SC=self.send_sci,
129 E=self.e_bit(), C=self.c_bit(),
130 SL=MACsecSA.shortlen(pkt),
131 PN=(self.pn & 0xFFFFFFFF), type=pkt.type)
132 hdr.type = ETH_P_MACSEC
133 return hdr / tag / payload
134
135 # this doesn't really need to be a method, but for symmetry with
136 # encap(), it is

Callers

nothing calls this directly

Calls 5

e_bitMethod · 0.95
c_bitMethod · 0.95
EtherClass · 0.90
MACsecClass · 0.85
shortlenMethod · 0.80

Tested by

no test coverage detected