10 #include <netinet/ether.h>
21 char unk1; // always 1, maybe version
22 char code; // request code: read request, read reply, write request, write reply
23 unsigned short error; // error code, 0 when no error
24 unsigned short attr; // attribute code which caused error, 0 when no error
25 char unk2[2]; // always 0, unknown
26 char client_mac[ETH_ALEN]; // client MAC address
27 char switch_mac[ETH_ALEN]; // switch MAC address
28 unsigned int seqnum; // sequence number
29 char proto_id[4]; // always "NSDP", maybe short for "Netgear Switch Description Protocol"
30 char unk3[4]; // always 0, unknown
32 } __attribute__((packed)) ;
38 } __attribute__((packed)) ;
47 struct attr_header *ah;
59 extern const struct ether_addr nullMac;
65 int trim (char *txt, int start);
68 int min (int a, int b);
71 void initNgHeader (struct ng_header *nh, char code, const struct ether_addr *client_mac, const struct ether_addr *switch_mac, unsigned int seqnum);
74 bool validateNgHeader (const struct ng_header *nh, char code, const struct ether_addr *client_mac, const struct ether_addr *switch_mac, unsigned int seqnum);
77 void initNgPacket (struct ng_packet *np);
80 void addPacketAttr (struct ng_packet *np, unsigned short attr, unsigned short size, void* data);
83 void addPacketEmptyAttr (struct ng_packet *np, unsigned short attr);
86 void addPacketByteAttr (struct ng_packet *np, unsigned short attr, char val);
89 void addPacketShortAttr (struct ng_packet *np, unsigned short attr, short val);
92 int getPacketTotalSize (const struct ng_packet *np);
95 struct attr* newEmptyAttr (unsigned short attr);
98 struct attr* newAttr (unsigned short attr, unsigned short size, void *data);
101 struct attr* newByteAttr (unsigned short attr, unsigned char value);
104 struct attr* newShortAttr (unsigned short attr, short value);
107 struct attr* newIntAttr (unsigned short attr, int value);
110 struct attr* newAddrAttr (unsigned short attr, struct in_addr value);
113 void freeAttr (struct attr *at);
116 void extractPacketAttributes (struct ng_packet *np, unsigned short *error, unsigned short *attr_error, List *attr);
119 void extractSwitchAttributes (struct swi_attr *sa, const List *l);