Skip to content

Commit 689fc20

Browse files
pmani84matthew-l-weber
authored andcommitted
Update to change the type to SOCK_DGRAM to avoid the need for adding the Layer 2 header.
Signed-off-by: Paul Mani <[email protected]>
1 parent 1a0b15a commit 689fc20

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

demos/copilot/src/python/switchRawSocket.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,16 @@
1414

1515
Interface = 'lo'
1616

17-
DestMac = b'\x00\x00\x00\x00\x00\x00'
18-
SrcMac = b'\x00\x00\x00\x00\x00\x00'
1917

2018
switchLogger = logger.Logger().GetLogger()
2119

2220
def SendRawPacket(message):
2321
"""Sends a Raw packet to the Light Server."""
2422

2523
eth_type = 0x88B5
26-
sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(eth_type))
24+
sock = socket.socket(socket.AF_PACKET, socket.SOCK_DGRAM, socket.htons(eth_type))
2725
sock.bind((Interface, 0))
28-
ethernet_frame = DestMac + SrcMac + struct.pack('!H', eth_type) + message
26+
ethernet_frame = message
2927
sock.send(ethernet_frame)
3028

3129
sock.close()

0 commit comments

Comments
 (0)