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