6 #include <netinet/ether.h>
9 #define CLIENT_PORT 63321
10 #define SWITCH_PORT 63322
12 #define NSDP_VERSION 1
13 #define NSDP_PROTOID "NSDP"
15 #define CODE_READ_REQ 1
16 #define CODE_READ_REP 2
17 #define CODE_WRITE_REQ 3
18 #define CODE_WRITE_REP 4
21 #define ERROR_READONLY 3
22 #define ERROR_WRITEONLY 4
23 #define ERROR_INVALID_VALUE 5
24 #define ERROR_DENIED 7
27 #define ATTR_PRODUCT 0x0001
28 #define ATTR_UNK_0002 0x0002
29 #define ATTR_NAME 0x0003
30 #define ATTR_MAC 0x0004
31 #define ATTR_UNK_0005 0x0005
32 #define ATTR_IP 0x0006
33 #define ATTR_NETMASK 0x0007
34 #define ATTR_GATEWAY 0x0008
35 #define ATTR_NEW_PASSWORD 0x0009
36 #define ATTR_PASSWORD 0x000A
37 #define ATTR_DHCP 0x000B
38 #define ATTR_UNK_000C 0x000C
39 #define ATTR_FIRM_VER 0x000D
40 #define ATTR_UNK_000E 0x000E
41 #define ATTR_UNK_000F 0x000F
42 #define ATTR_FIRM_UPGRADE 0x0010
43 #define ATTR_RESTART 0x0013
44 #define ATTR_ENCPASS 0x0014
45 #define ATTR_DEFAULTS 0x0400
46 #define ATTR_PORT_STATUS 0x0C00
47 #define ATTR_PORT_STATISTICS 0x1000
48 #define ATTR_STATS_RESET 0x1400
49 #define ATTR_CABLETEST_DO 0x1800
50 #define ATTR_CABLETEST_RESULT 0x1C00
51 #define ATTR_VLAN_TYPE 0x2000
52 #define ATTR_VLAN_PORT_CONF 0x2400
53 #define ATTR_VLAN_DOT_CONF 0x2800
54 #define ATTR_VLAN_DESTROY 0x2C00
55 #define ATTR_VLAN_PVID 0x3000
56 #define ATTR_QOS_TYPE 0x3400
57 #define ATTR_QOS_CONFIG 0x3800
58 #define ATTR_BITRATE_INPUT 0x4C00
59 #define ATTR_BITRATE_OUTPUT 0x5000
60 #define ATTR_STORM_ENABLE 0x5400
61 #define ATTR_STORM_BITRATE 0x5800
62 #define ATTR_MIRROR 0x5C00
63 #define ATTR_PORTS_COUNT 0x6000
64 #define ATTR_MAX_VLAN 0x6400
65 #define ATTR_IGMP_ENABLE_VLAN 0x6800
66 #define ATTR_IGMP_BLOCK_UNK 0x6C00
67 #define ATTR_IGMP_VALID_V3 0x7000
68 #define ATTR_TLV_BITMAP 0x7400
69 #define ATTR_LOOP_DETECT 0x9000
70 #define ATTR_END 0xFFFF
75 unsigned char version; /* always 1, maybe version */
76 unsigned char code; /* request code: read request, read reply, write request, write reply */
77 unsigned char error; /* error code, 0 when no error */
78 unsigned char unk1; /* always 0, unknown */
79 unsigned short attr; /* attribute code which caused error, 0 when no error */
80 unsigned char unk2[2]; /* always 0, unknown */
81 unsigned char client_mac[ETH_ALEN]; /* client MAC address */
82 unsigned char switch_mac[ETH_ALEN]; /* switch MAC address */
83 unsigned int seqnum; /* sequence number */
84 unsigned char proto_id[4]; /* always "NSDP", maybe short for "Netgear Switch Description Protocol" */
85 unsigned char unk3[4]; /* always 0, unknown */
86 unsigned char data[0]; /* attributes data */
87 } __attribute__((packed));
91 unsigned short attr; /* attribute code */
92 unsigned short size; /* attribute data size */
93 unsigned char data[0]; /* attribute data */
94 } __attribute__((packed));
98 struct attr_port_status {
99 unsigned char port; /* port number */
100 unsigned char status; /* port status (speed index) */
101 unsigned char unk; /* unknown */
102 } __attribute__((packed));
105 struct attr_port_stat {
106 unsigned char port; /* port number */
107 unsigned long long recv; /* received bytes */
108 unsigned long long sent; /* sent bytes */
109 unsigned long long unk1; /* unknown */
110 unsigned long long unk2; /* unknown */
111 unsigned long long unk3; /* unknown */
112 unsigned long long crc; /* CRC errors */
113 } __attribute__((packed));
116 struct attr_bitrate {
117 unsigned char port; /* port number */
118 int bitrate; /* bitrate index */
119 } __attribute__((packed));
123 unsigned char port; /* port number */
124 unsigned char prio; /* prio index */
125 } __attribute__((packed));
129 unsigned char port; /* port number */
130 unsigned short vlan; /* VLAN */
131 } __attribute__((packed));
134 struct attr_igmp_vlan {
135 unsigned short enable; /* IGMP filtering enabled */
136 unsigned short vlan; /* VLAN where IGMP packets are filtered */
137 } __attribute__((packed));
140 struct attr_cabletest_do {
141 unsigned char port; /* port number */
142 unsigned char action; /* action index */
143 } __attribute__((packed));
146 struct attr_cabletest_result {
147 unsigned char port; /* port number */
148 unsigned int v1; /* raw value 1 (values unknown yet) */
149 unsigned int v2; /* raw value 2 (values unknown yet) */
150 } __attribute__((packed));
153 /* Note: this structure is not sent "as-is" on the wire.
154 * A translation is done between the wire format (which uses somewhat not
155 * trivial bitmap) and this simpler format. See attr.c for more details.
157 struct attr_vlan_conf {
158 unsigned short vlan; /* VLAN number */
159 unsigned char ports[0]; /* array, maps each port association with the VLAN */
163 /* Note: this structure is not sent "as-is" on the wire.
164 * A translation is done between the wire format (which uses somewhat not
165 * trivial bitmap) and this simpler format. See attr.c for more details.
168 unsigned char outport; /* port number on which traffic is sent */
169 unsigned char ports[0]; /* array, maps each port source mirror traffic */