I am starting to work on a lightweight OSPFv2 protocol implementation and
thought that twisted looked like a good tool to use for a lot of the state
machine and timing parts. I need to create a SOCK_RAW socket for protocol
89. Can someone point me in the right direction to get twisted to use this?
Here's a minimal example of what I need to do to receive the packets
import socket
import struct
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, 89)
sock.bind(('', 0))
multicast_group = '224.0.0.5'
group = socket.inet_aton(multicast_group)
mreq = struct.pack('4s4s', group, socket.inet_aton('192.168.88.253'))
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
while True:
data, address = sock.recvfrom(1024)
print(data.hex())