All,
thank you for your responses. I learned much and made some modifications in my
small program. Currently I am attempting to put together a packet that contains
a Python message (created using struct.pack) and a Scapy message (Ether()).
Having a packet with combined payload from Python and Scapy doesn't seem to
work the way I do it:
ether = scapy.Ether(dst="01:02:03:04:05:06")
payload = ether + payload (where payload is the chassis_id)
I get as error:
File "lldp.py", line 23, in main
fullpayload = ether + payload
TypeError: unsupported operand type(s) for +: 'Ether' and 'str'
I'm thinking instead to just use Python to create the Ethernet Frame as well
and then send the packet off. How difficult is this? I could only find
references online on how to send TCP/UDP packets but no information on how to
send a packet with a Layer1 and Layer2 only. The ethernet frame should only
contain a destination MAC, a source MAC and a type (88cc). Any advice on how to
create such a packet and send it? (if anyone knows of an easy way to use a
hybrid of Python and Scapy, that's fine by me as well).
Thanks!
class lldp_class:
def __init__(self):
self.chassis_id_tlv = None
def chassis_id(self, subtype, chassis_info):
if subtype == 4:
chassis_data_int = [int(x,16) for x in chassis_info.split(":")]
chassis_data = struct.pack("6B", *chassis_data_int)
subtype_data = struct.pack("!B",subtype)
self.chassis_id_tlv = subtype_data + chassis_data
def main():
p = lldp_class()
p.chassis_id(4, "01:80:C2:00:00:0E")
payload = p.chassis_id_tlv
ether = scapy.Ether(dst="01:02:03:04:05:06")
fullpayload = ether + payload
sendp(fullpayload)
main()
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/
--
http://mail.python.org/mailman/listinfo/python-list