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_END 0xFFFF
74 unsigned char version; /* always 1, maybe version */
75 unsigned char code; /* request code: read request, read reply, write request, write reply */
76 unsigned char error; /* error code, 0 when no error */
77 unsigned char unk1; /* always 0, unknown */
78 unsigned short attr; /* attribute code which caused error, 0 when no error */
79 unsigned char unk2[2]; /* always 0, unknown */
80 unsigned char client_mac[ETH_ALEN]; /* client MAC address */
81 unsigned char switch_mac[ETH_ALEN]; /* switch MAC address */
82 unsigned int seqnum; /* sequence number */
83 unsigned char proto_id[4]; /* always "NSDP", maybe short for "Netgear Switch Description Protocol" */
84 unsigned char unk3[4]; /* always 0, unknown */
85 unsigned char data[0]; /* attributes data */
86 } __attribute__((packed));
90 unsigned short attr; /* attribute code */
91 unsigned short size; /* attribute data size */
92 unsigned char data[0]; /* attribute data */
93 } __attribute__((packed));
97 struct attr_port_status {
98 unsigned char port; /* port number */
99 unsigned char status; /* port status (speed index) */
100 unsigned char unk; /* unknown */
101 } __attribute__((packed));
104 struct attr_port_stat {
105 unsigned char port; /* port number */
106 unsigned long long recv; /* received bytes */
107 unsigned long long sent; /* sent bytes */
108 unsigned long long unk1; /* unknown */
109 unsigned long long unk2; /* unknown */
110 unsigned long long unk3; /* unknown */
111 unsigned long long crc; /* CRC errors */
112 } __attribute__((packed));
115 struct attr_bitrate {
116 unsigned char port; /* port number */
117 int bitrate; /* bitrate index */
118 } __attribute__((packed));
122 unsigned char port; /* port number */
123 unsigned char prio; /* prio index */
124 } __attribute__((packed));
128 unsigned char port; /* port number */
129 unsigned short vlan; /* VLAN */
130 } __attribute__((packed));
133 struct attr_igmp_vlan {
134 unsigned short enable; /* IGMP filtering enabled */
135 unsigned short vlan; /* VLAN where IGMP packets are filtered */
136 } __attribute__((packed));
139 struct attr_cabletest_do {
140 unsigned char port; /* port number */
141 unsigned char action; /* action index */
142 } __attribute__((packed));
145 struct attr_cabletest_result {
146 unsigned char port; /* port number */
147 unsigned int v1; /* raw value 1 (values unknown yet) */
148 unsigned int v2; /* raw value 2 (values unknown yet) */
149 } __attribute__((packed));
152 /* Note: this structure is not sent "as-is" on the wire.
153 * A translation is done between the wire format (which uses somewhat not
154 * trivial bitmap) and this simpler format. See attr.c for more details.
156 struct attr_vlan_conf {
157 unsigned short vlan; /* VLAN number */
158 unsigned char ports[0]; /* array, maps each port association with the VLAN */
162 /* Note: this structure is not sent "as-is" on the wire.
163 * A translation is done between the wire format (which uses somewhat not
164 * trivial bitmap) and this simpler format. See attr.c for more details.
167 unsigned char outport; /* port number on which traffic is sent */
168 unsigned char ports[0]; /* array, maps each port source mirror traffic */