You only need three things here: [EMAIL PROTECTED] wrote: > >#!/usr/bin/python >import scapy >import struct > >class lldp_class: > def __init__(self): > self.chassis_id_tlv = None > > def chassis_id(subtype, chassis_info):
Make that def chassis_id(self, subtype, chassis_info): When you call "p.chassis_id", "p" is passed as the first parameter to chassis_id. By convention, we call that "self", in the same way the object of a C++ method is called "this" (although that is enforced, rather than convention). > if subtype == 4: > chassis_data = struct.pack("!B",chassis_info) > subtype_data = struct.pack("!B",subtype) > self.chassis_id_tlv = subtype_data + chassis_data > >def __main__(): Make that def main(): The underscores have a special meaning that you do not need here. Note that the name "main" is not required; some people call it something like "test". > 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) Now, at the end, add: if __name__=="__main__": main() That should do it. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list