]> git.sur5r.net Git - ngadmin/blob - lib/include/ngadmin.h
Add error codes to handle bad replies and unknown errors
[ngadmin] / lib / include / ngadmin.h
1
2 /**
3  * User interface file. 
4  * All client applications which want to use NgAdmin must include this file. 
5  * @file ngadmin.h
6  */
7
8
9 #ifndef DEF_NGADMIN
10 #define DEF_NGADMIN
11
12
13 #include <stdbool.h>
14 #include <arpa/inet.h>
15
16 #include <netinet/ether.h>
17
18
19
20 /**
21  * Maximum size of product string. 
22  */
23 #define PRODUCT_SIZE    64
24
25 /**
26  * Maximum size of name string. 
27  **/
28 #define NAME_SIZE       64
29
30 /**
31  *  Maximum size of firmware version string. 
32  **/
33 #define FIRMWARE_SIZE   64
34
35
36
37 /**
38  * Error codes. 
39  * This enum lists all the error codes the library can return to user. 
40  **/
41 enum {
42         ERR_OK = 0,                     /**< no error */
43         ERR_NET = -1,                   /**< network error */
44         ERR_NOTLOG = -2,                /**< not logged */
45         ERR_DENIED = -3,                /**< access denied */
46         ERR_BADPASS = -4,               /**< bad password */
47         ERR_BADID = -5,                 /**< bad switch id */
48         ERR_INVARG = -6,                /**< invalid argument */
49         ERR_TIMEOUT = -7,               /**< timeout */
50         ERR_MEM = -8,                   /**< out of memory */
51         ERR_NOTIMPL = -9,               /**< not implemented */
52         ERR_BADREPLY = -10,             /**< bad reply */
53         ERR_UNKNOWN = -11               /**< unknown error */
54 };
55
56
57
58 /**
59  * Port speeds. 
60  * This enum lists all the speeds a port can have. 
61  **/
62 enum {
63         SPEED_UNK = -1,                 /**< unknown status */
64         SPEED_DOWN = 0,                 /**< link down */
65         SPEED_10 = 1,                   /**< 10 Mb/s */
66         SPEED_100 = 4,                  /**< 100 Mb/s */
67         SPEED_1000 = 5                  /**< 1000 Mb/s */
68 };
69
70
71
72 /**
73  * VLAN types. 
74  * This enum lists all the VLAN types available
75  **/
76 enum {
77         VLAN_DISABLED = 0,              /**< VLAN disabled */
78         VLAN_PORT_BASIC = 1,            /**< port basic */
79         VLAN_PORT_ADV = 2,              /**< port advanced */
80         VLAN_DOT_BASIC = 3,             /**< 802.1q basic */
81         VLAN_DOT_ADV = 4                /**< 802.1q advanced */
82 };
83
84
85 /**
86  * VLAN port specification. 
87  * This enum lists all the VLAN specifications a port can have. 
88  **/
89 enum {
90         VLAN_UNSPEC = 0xFF,             /**< unspecified */
91         VLAN_NO = 0,                    /**< not present */
92         VLAN_UNTAGGED = 1,              /**< present, untagged */
93         VLAN_TAGGED = 2                 /**< present, tagged */
94 };
95
96
97
98 /**
99  * Minimum VLAN id. 
100  **/
101 #define VLAN_MIN                1
102
103 /**
104  * Maximum 802.1q VLAN id. 
105  **/
106 #define VLAN_DOT_MAX            4093
107
108 /**
109  * Maximum port VLAN id.
110  **/
111 #define VLAN_PORT_MAX           9
112
113
114 /**
115  * QoS modes. 
116  * This enum lists all the availables QoS modes. 
117  **/
118 enum {
119         QOS_PORT = 1,                   /**< port based */
120         QOS_DOT = 2                     /**< 802.1p based */
121 };
122
123
124 /**
125  * Port priorities. 
126  * This enum lists all the priorities a port can have. 
127  **/
128 enum {
129         PRIO_UNSPEC = -1,               /**< unspecified */
130         PRIO_HIGH = 1,                  /**< high */
131         PRIO_MED = 2,                   /**< medium */
132         PRIO_NORM = 3,                  /**< normal */
133         PRIO_LOW = 4                    /**< low */
134 };
135
136
137
138
139 /**
140  * Bitrates. 
141  * This enum lists all the available bitrates. 
142  **/
143 enum {
144         BITRATE_UNSPEC = -1,    /**< unspecified */
145         BITRATE_NOLIMIT = 0,    /**< unlimited */
146         BITRATE_512K = 1,       /**< 512 Kb/s */
147         BITRATE_1M = 2,         /**< 1 Mb/s */
148         BITRATE_2M = 3,         /**< 2 Mb/s */
149         BITRATE_4M = 4,         /**< 4 Mb/s */
150         BITRATE_8M = 5,         /**< 8 Mb/s */
151         BITRATE_16M = 6,        /**< 16 Mb/s */
152         BITRATE_32M = 7,        /**< 32 Mb/s */
153         BITRATE_64M = 8,        /**< 64 Mb/s */
154         BITRATE_128M = 9,       /**< 128 Mb/s */
155         BITRATE_256M = 10,      /**< 256 Mb/s */
156         BITRATE_512M = 11       /**< 512 Mb/s */
157 };
158
159
160
161
162 /**
163  * NgAdmin library main structure. 
164  * The structure content is hidden to clients to prevent them to manually 
165  * change data and mess up things. 
166  **/
167 struct ngadmin;
168
169
170
171 /**
172  * Network configuration. 
173  * Represents the network configuration of a switch. 
174  */
175 struct net_conf {
176         struct in_addr ip;              /**< IP */
177         struct in_addr netmask;         /**< netmask */
178         struct in_addr gw;              /**< gateway IP */
179         bool dhcp;                      /**< DHCP enabled */
180 };
181
182
183 /**
184  * Switch characteristics. 
185  * Represents the main characteristics of a switch. 
186  */
187 struct swi_attr {
188         char product[PRODUCT_SIZE];     /**< product name (eg.\ GS108EV1) */
189         char name[NAME_SIZE];           /**< custom name */
190         char firmware[FIRMWARE_SIZE];   /**< firmware version string */
191         unsigned char ports;            /**< number of ports */
192         struct ether_addr mac;          /**< MAC address */
193         struct net_conf nc;             /**< network configuration */
194 };
195
196
197 /**
198  * Port statistics. 
199  * Represents statistics of a particular port. 
200  */
201 struct port_stats {
202         unsigned long long recv;        /**< packets received */
203         unsigned long long sent;        /**< packets sent */
204         unsigned long long crc;         /**< CRC errors */
205 };
206
207
208 /**
209  * IGMP snooping configuration. 
210  * Represents the IGMP snooping configuration of a switch. 
211  */
212 struct igmp_conf {
213         bool enable;                    /**< IGMP snooping enabled */
214         unsigned short vlan;            /**< VLAN on which IGMP snooping is done */
215         bool validate;                  /**< validate IGMPv3 headers */
216         bool block;                     /**< block unknown multicast addresses */
217 };
218
219
220 /**
221  * Cabletest result.
222  */
223 struct cabletest {
224         char port;              /**< port */
225         int v1;                 /**< raw value 1 */
226         int v2;                 /**< raw value 2 */
227 };
228
229
230
231 #ifdef __cplusplus
232 extern "C" {
233 #endif
234
235
236 /**
237  * Initialize NgAdmin library. 
238  * This function initializes the NgAdmin library. You must call it before any 
239  * other function. 
240  * @param iface The network interface to use. 
241  * @return A pointer to a ngadmin structure, or NULL if an error occurred. 
242  */
243 struct ngadmin* ngadmin_init (const char *iface);
244
245
246 /**
247  * Close NgAdmin library. 
248  * This function frees the resources used by the library. You really should 
249  * call this when you are done using the library. 
250  * @param nga A pointer to the ngadmin structure. 
251  * @return ERR_OK when everything is well or an error code otherwise. 
252  */
253 int ngadmin_close (struct ngadmin *nga);
254
255
256 /**
257  * Force the use of the interface. 
258  * This function allows to solve two problems: 
259  * - When you have multiple network interfaces, sending to the global broadcast 
260  *   address may not send the packet on the interface you want. \n
261  *   This function forces the packet to go on the interface you specified at 
262  *   the library initialization. 
263  * - When the switch is not in your network range, because DHCP is disabled or
264  *   you started the DHCP server after the switch. \n
265  *   This function allows you to ignore the routing table and consider every 
266  *   address is directly reachable on the interface. \n
267  *   An alternative is to use ngadmin_setKeepBroadcasting, or simply add a route. 
268  * 
269  * @warning Requires root priviledges. 
270  * @see ngadmin_setKeepBroadcasting()
271  * @param nga A pointer to the ngadmin structure. 
272  * @return ERR_OK when everything is well or an error code otherwise. 
273  */
274 int ngadmin_forceInterface (struct ngadmin *nga);
275
276
277 /**
278  * Keep broadcasting even when talking with a particular switch. 
279  * By default, once you login on a switch, NgAdmin talks with it using unicast. 
280  * This prevents the password from being sent to all your network. \n
281  * The switch still replies using broadcast, but the password is not included 
282  * in the replies. \n
283  * This function allows you to disable this feature and do like the official 
284  * Windows application that always use broadcast packets. \n
285  * This also allows to configure a switch which is not on your network range 
286  * without forcing the interface. \n
287  * When you enable this option, you must be aware that on every parameter 
288  * change you make on the switch, your password is broadcasted in cleartext 
289  * to all your network. 
290  * @see ngadmin_forceInterface()
291  * @param nga A pointer to the ngadmin structure. 
292  * @param value Enable or disable the systematic use of broadcast packets. 
293  * @return ERR_OK when everything is well or an error code otherwise. 
294  **/
295 int ngadmin_setKeepBroadcasting (struct ngadmin *nga, bool value);
296
297
298 /**
299  * Use global broadcast address. 
300  * By default, NgAdmin uses the interface broadcast address. 
301  * This option forces the lib to use the global broadcast address 
302  * (255.255.255.255) instead. 
303  * @warning If you have multiple interfaces, enabling this may cause problems. 
304  * @see ngadmin_forceInterface()
305  * @param nga A pointer to the ngadmin structure. 
306  * @param value Enable or disable the use of the global broadcast address. 
307  * @return ERR_OK when everything is well or an error code otherwise. 
308  **/
309 int ngadmin_useGlobalBroadcast (struct ngadmin *nga, bool value);
310
311
312 /**
313  * Specify the password to use to login. 
314  * Sets the password to use to login on switches. 
315  * @param nga A pointer to the ngadmin structure. 
316  * @param pass The password string to use. 
317  * @return ERR_OK when everything is well or an error code otherwise. 
318  **/
319 int ngadmin_setPassword (struct ngadmin *nga, const char *pass);
320
321
322 /**
323  * Set timeout for networking. 
324  * Sets the timeout when waiting for network packets. 
325  * @param nga A pointer to the ngadmin structure. 
326  * @param tv A pointer to a timeval structure. 
327  * @return ERR_OK when everything is well or an error code otherwise. 
328  **/
329 int ngadmin_setTimeout (struct ngadmin *nga, const struct timeval *tv);
330
331
332 /**
333  * Scan the network for switches. 
334  * This function scans the network for Netgear switches that use NSDP. 
335  * @warning Systematically blocks for the timeout value. 
336  * @note If you are logged on a switch, calling this function will delog you. 
337  * @param nga A pointer to the ngadmin structure. 
338  * @return ERR_OK when everything is well or an error code otherwise. 
339  **/
340 int ngadmin_scan (struct ngadmin *nga);
341
342
343 /**
344  * Get the list of detected switches. 
345  * This function allows you gou get the list of all last detected switchs. 
346  * @note When a scan is done, this array is no more valid. 
347  * @param nga A pointer to the ngadmin structure. 
348  * @param nb A pointer to an integer which will receive the number of switches. 
349  * @return A pointer to an array of switch characteristics. 
350  */
351 const struct swi_attr* ngadmin_getSwitchTab (struct ngadmin *nga, int *nb);
352
353
354 /**
355  * Get the switch on which you are logged. 
356  * This function allows you to get the switch on which you are logged. 
357  * @param nga A pointer to the ngadmin structure. 
358  * @return A pointer the switch characteristics or NULL if you are not logged. 
359  **/
360 const struct swi_attr* ngadmin_getCurrentSwitch (struct ngadmin *nga);
361
362
363
364 /**
365  * Upgrade the switch firmware. 
366  * This function allows you to upgrade the switch firmware. 
367  * @warning Currently not implemented. 
368  * @note You must be logged on a switch. 
369  * @param nga A pointer to the ngadmin structure. 
370  * @param filename A path to the file of the new firmware to send. 
371  * @return ERR_NOTIMPL
372  **/
373 int ngadmin_upgradeFirmware (struct ngadmin *nga, const char *filename);
374
375
376 /**
377  * Login on a switch. 
378  * This function permits to login on a switch. 
379  * @note If you are already logged, this function delogs you whatever the new 
380  *       login attempt is successfull or not. 
381  * @see ngadmin_setPassword()
382  * @param nga A pointer to the ngadmin structure. 
383  * @param id The id (position in the switch array) of the switch you want to login to. 
384  * @return ERR_OK when everything is well or an error code otherwise. 
385  **/
386 int ngadmin_login (struct ngadmin *nga, int id);
387
388
389 /**
390  * Get the ports speed status. 
391  * This functions retrieves the ports speed status. 
392  * @note You must be logged on a switch. 
393  * @param nga A pointer to the ngadmin structure. 
394  * @param ports A pointer to an array of ports which will receive ports status. 
395  *         Must not be NULL. The array size must be ports_count*sizeof(unsigned char). 
396  * @return ERR_OK when everything is well or an error code otherwise. 
397  **/
398 int ngadmin_getPortsStatus (struct ngadmin *nga, unsigned char *ports);
399
400
401 /**
402  * Change the name of a switch. 
403  * This changes the name of a switch. 
404  * @note You must be logged on a switch. 
405  * @param nga A pointer to the ngadmin structure. 
406  * @param name The name string to use. A NULL value clears the name. 
407  * @return ERR_OK when everything is well or an error code otherwise. 
408  **/
409 int ngadmin_setName (struct ngadmin *nga, const char *name);
410
411
412 /**
413  * Get the ports statistics. 
414  * Retrieves the ports packet statistics. 
415  * @note You must be logged on a switch. 
416  * @param nga A pointer to the ngadmin structure. 
417  * @param ps A pointer to an array of port_stats structures. Must not be NULL. 
418  *        The array size must be ports_count*sizeof(struct port_stats). 
419  * @return ERR_OK when everything is well or an error code otherwise. 
420  **/
421 int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps);
422
423
424 /**
425  * Reset the ports statistics. 
426  * This resets the ports packet statistics. 
427  * @note You must be logged on a switch. 
428  * @param nga A pointer to the ngadmin structure. 
429  * @return ERR_OK when everything is well or an error code otherwise. 
430  **/
431 int ngadmin_resetPortsStatistics (struct ngadmin *nga);
432
433
434 /**
435  * Change the password of a switch. 
436  * This changes the password of a switch. On success, automatically updates 
437  * local password so you do not have to relog. 
438  * @note You must be logged on a switch. 
439  * @param nga A pointer to the ngadmin structure. 
440  * @param pass The new password string to use. 
441  * @return ERR_OK when everything is well or an error code otherwise. 
442  **/
443 int ngadmin_changePassword (struct ngadmin *nga, const char* pass);
444
445
446 /**
447  * Get the broadcast storm filtering state. 
448  * Retrieves the broadcast storm filtering state. 
449  * @note You must be logged on a switch. 
450  * @param nga A pointer to the ngadmin structure. 
451  * @param s A pointer to an integer which will receive 0 or 1. 
452  * @return ERR_OK when everything is well or an error code otherwise. 
453  **/
454 int ngadmin_getStormFilterState (struct ngadmin *nga, int *s);
455
456
457 /**
458  * Set the broadcast storm filtering state. 
459  * Changes the broadcast storm filtering state. 
460  * @note You must be logged on a switch. 
461  * @param nga A pointer to the ngadmin structure. 
462  * @param s An integer with value 0 or 1. 
463  * @return ERR_OK when everything is well or an error code otherwise. 
464  **/
465 int ngadmin_setStormFilterState (struct ngadmin *nga, int s);
466
467
468 /**
469  * Get the broadcast storm bitrates. 
470  * Retrieves the broadcast storm filtering bitrates. 
471  * @note You must be logged on a switch. 
472  * @param nga A pointer to the ngadmin structure. 
473  * @param ports A pointer to an array of integers. Must not be NULL. 
474  *              The array size must be ports_count*sizeof(int). 
475  * @return ERR_OK when everything is well or an error code otherwise. 
476  **/
477 int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports);
478
479
480 /**
481  * Set the broadcast storm bitrates. 
482  * Changes the broadcast storm filtering values. 
483  * @note You must be logged on a switch. 
484  * @param nga A pointer to the ngadmin structure. 
485  * @param ports A pointer to an array of integers. Must not be NULL. 
486  *              The array size must be ports_count*sizeof(int). 
487  * @return ERR_OK when everything is well or an error code otherwise. 
488  **/
489 int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports);
490
491
492 /**
493  * Get the bitrates limits. 
494  * Retrieves the bitrates limits of each port. 
495  * @note You must be logged on a switch. 
496  * @param nga A pointer to the ngadmin structure. 
497  * @param ports A pointer to an array of integers. Must not be NULL. 
498  *              The array size must be ports_count*sizeof(int). 
499  * @return ERR_OK when everything is well or an error code otherwise. 
500  **/
501 int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports);
502
503
504 /**
505  * Set the bitrates limits. 
506  * Changes the bitrates limits of each port. 
507  * @note You must be logged on a switch. 
508  * @param nga A pointer to the ngadmin structure. 
509  * @param ports A pointer to an array of integers. Must not be NULL. 
510  *              The array size must be ports_count*sizeof(int). 
511  * @return ERR_OK when everything is well or an error code otherwise. 
512  **/
513 int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports);
514
515
516 /**
517  * Get the QoS mode. 
518  * Retrieves the QoS mode. 
519  * @note You must be logged on a switch. 
520  * @param nga A pointer to the ngadmin structure. 
521  * @param s A pointer to an integer. Must not be NULL. 
522  * @return ERR_OK when everything is well or an error code otherwise. 
523  **/
524 int ngadmin_getQOSMode (struct ngadmin *nga, int *s);
525
526
527 /**
528  * Set the QoS mode. 
529  * Changes the QoS mode. 
530  * @note You must be logged on a switch. 
531  * @param nga A pointer to the ngadmin structure. 
532  * @param s An integer with the new mode. 
533  * @return ERR_OK when everything is well or an error code otherwise. 
534  **/
535 int ngadmin_setQOSMode (struct ngadmin *nga, int s);
536
537
538 /**
539  * Get the QoS values. 
540  * Retrieves the QoS priority values for all the ports. 
541  * @note You must be logged on a switch. 
542  * @note The switch QoS mode should be port based to use this function. 
543  * @param nga A pointer to the ngadmin structure. 
544  * @param ports A pointer to an array of chars. Must not be NULL.
545                 The array size must be ports_count*sizeof(ports). 
546  * @return ERR_OK when everything is well or an error code otherwise. 
547  **/
548 int ngadmin_getQOSValues (struct ngadmin *nga, char *ports);
549
550
551 /**
552  * Set the QoS values. 
553  * Changes the QoS priority values for all the ports. 
554  * @note You must be logged on a switch. 
555  * @note The switch QoS mode should be port based to use this function. 
556  * @param nga A pointer to the ngadmin structure. 
557  * @param ports A pointer to an array of chars. Must not be NULL.
558                 The array size must be ports_count*sizeof(ports). 
559  * @return ERR_OK when everything is well or an error code otherwise. 
560  **/
561 int ngadmin_setQOSValues (struct ngadmin *nga, const char *ports);
562
563
564 /**
565  * Restart the switch. 
566  * Restarts the switch. 
567  * @note You must be logged on a switch. 
568  * @note If successfull, you should wait a few seconds while the switch 
569          effectively restarts. 
570  * @param nga A pointer to the ngadmin structure. 
571  * @return ERR_OK when everything is well or an error code otherwise. 
572  **/
573 int ngadmin_restart (struct ngadmin *nga);
574
575
576 /**
577  * Restore the switch default parameters. 
578  * Restores the switch default parameters and restarts it. 
579  * @note You must be logged on a switch. 
580  * @note If successfull, you will be delogged and the switch list will be 
581          cleared. You should wait a few seconds while the switch effectively restarts. 
582  * @param nga A pointer to the ngadmin structure. 
583  * @return ERR_OK when everything is well or an error code otherwise. 
584  **/
585 int ngadmin_defaults (struct ngadmin *nga);
586
587
588 /**
589  * Get the port mirroring values. 
590  * Retrieves the port mirrorring values. 
591  * @note The switch QoS mode should be port based to use this function. 
592  * @note You must be logged on a switch. 
593  * @param nga A pointer to the ngadmin structure.
594  * @param ports A pointer to an array of chars. Must not be NULL. \n
595                 The first element of the array is the output port (or 0 if port 
596                 mirroring is disabled), followed by 0 or 1 values for each port 
597                 if it is present or not. \n
598                 The array size must be (1+ports_count)*sizeof(char). 
599  * @return ERR_OK when everything is well or an error code otherwise. 
600  **/
601 int ngadmin_getMirror (struct ngadmin *nga, char *ports);
602
603
604 /**
605  * Set the port mirroring values. 
606  * Changes the port mirroring values. 
607  * @note The switch QoS mode should be port based to use this function. 
608  * @param nga A pointer to the ngadmin structure. 
609  * @param ports A pointer to an array of chars. It as the same format as in 
610                 ngadmin_getMirror. \n
611                 If it is NULL, port mirroring is disabled. 
612  * @return ERR_OK when everything is well or an error code otherwise. 
613  **/
614 int ngadmin_setMirror (struct ngadmin *nga, const char *ports);
615
616
617 /**
618  * Get the IGMP configuration. 
619  * Retrieves the IGMP & multicast configuration. 
620  * @note You must be logged on a switch. 
621  * @param nga A pointer to the ngadmin structure. 
622  * @param ic A pointer to an igmp_conf structure. Must not be NULL. 
623  * @return ERR_OK when everything is well or an error code otherwise. 
624  **/
625 int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic);
626
627
628 /**
629  * Set the IGMP configuration. 
630  * Changes the IGMP configuration. 
631  * @note You must be logged on a switch. 
632  * @param nga A pointer to the ngadmin structure. 
633  * @param ic A pointer to an igmp_conf structure. Must not be NULL. 
634  * @return ERR_OK when everything is well or an error code otherwise. 
635  **/
636 int ngadmin_setIGMPConf (struct ngadmin *nga, const struct igmp_conf *ic);
637
638
639 /**
640  * Perform a cable test. 
641  * Performs a cable test on one ore more ports. 
642  * @note Results are still raw values. 
643  * @note This function takes a very long time. 
644  * @note You must be logged on a switch. 
645  * @param nga A pointer to the ngadmin structure. 
646  * @param ct A pointer to an array of cabletest structures. Must not be NULL. 
647  * @param nb The number of elements in the array. 
648  * @return ERR_OK when everything is well or an error code otherwise. 
649  **/
650 int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb);
651
652
653 /**
654  * Set the network configuration. 
655  * Changes the network configuration. 
656  * @note You must be logged on a switch. 
657  * @param nga A pointer to the ngadmin structure. 
658  * @param nc A pointer to a net_conf structure. Must not be NULL. \n
659              Only non-zero fields of the structure are taken into account. 
660  * @return ERR_OK when everything is well or an error code otherwise. 
661  **/
662 int ngadmin_setNetConf (struct ngadmin *nga, const struct net_conf *nc);
663
664
665 /**
666  * Get the VLAN type. 
667  * Retrieves the VLAN type. 
668  * @note You must be logged on a switch. 
669  * @param nga A pointer to the ngadmin structure. 
670  * @param t A pointer to an integer which will receive the VLAN type. Must not be NULL. 
671  * @return ERR_OK when everything is well or an error code otherwise. 
672  **/
673 int ngadmin_getVLANType (struct ngadmin *nga, int *t);
674
675
676 /**
677  * Set the VLAN type. 
678  * Changes the VLAN type. 
679  * @note You must be logged on a switch. 
680  * @param nga A pointer to the ngadmin structure. 
681  * @param t An integer which contains the new VLAN type. 
682  * @return ERR_OK when everything is well or an error code otherwise. 
683  **/
684 int ngadmin_setVLANType (struct ngadmin *nga, int t);
685
686
687 /**
688  * Get the ports VLANs in port mode. 
689  * Retrieves the associated VLAN of ports in port mode. 
690  * @note The switch should be in port mode. 
691  * @note You must be logged on a switch. 
692  * @param nga A pointer to the ngadmin structure. 
693  * @param ports A pointer to an array of integers which will receive the 
694                 number of associated VLAN. Must not be NULL. 
695  * @return ERR_OK when everything is well or an error code otherwise. 
696  **/
697 int ngadmin_getVLANPortConf (struct ngadmin *nga, unsigned char *ports);
698
699
700 /**
701  * Set the ports VLAN in port mode. 
702  * Changes the associated VLAN of ports in port mode. 
703  * @note The switch should be in port mode. 
704  * @note You must be logged on a switch. 
705  * @param nga A pointer to the ngadmin structure. 
706  * @param ports A pointer to an array of integers which contain the 
707                 number of associated VLAN. Must not be NULL. 
708  * @return ERR_OK when everything is well or an error code otherwise. 
709  **/
710 int ngadmin_setVLANPortConf (struct ngadmin *nga, const unsigned char *ports);
711
712
713 /**
714  * Get all the 802.1q VLAN configuration. 
715  * Retrieves all the VLAN configuration in 802.1q mode. 
716  * @note The switch should be in 802.1q mode. 
717  * @note You must be logged on a switch. 
718  * @param nga A pointer to the ngadmin structure. 
719  * @param vlans A pointer to an array of unsigned shorts which will receive 
720  *              VLAN ids. Must not be NULL. \n
721  *              The array size must be sizeof(unsigned short)*(*nb). 
722  * @param ports A pointer to an array of unsigned chars which will receive the 
723                 802.1q configuration for each VLAN. Must not be NULL. \n
724                 The array size must be sizeof(unsigned char)*ports_count*(*nb). 
725  * @param nb A pointer to an integer which contains the maximum number of 
726              elements allowed in the array. Must not be NULL. \n
727              It will receive the actual number of VLAN written in the arrays. 
728  * @return ERR_OK when everything is well or an error code otherwise. 
729  **/
730 int ngadmin_getVLANDotAllConf (struct ngadmin *nga, unsigned short *vlans, unsigned char *ports, int *nb);
731
732
733 /**
734  * Get the configuration of a VLAN in 802.1q mode. 
735  * Retrieves the configuration of a particular VLAN in 802.1q mode. 
736  * @note The switch should be in 802.1q mode. 
737  * @note You must be logged on a switch. 
738  * @param nga A pointer to the ngadmin structure. 
739  * @param vlan The VLAN you want to get the configuration. 
740  * @param ports A pointer to an array of integers which will receive the 
741                 configuration. Must not be NULL. 
742  * @return ERR_OK when everything is well or an error code otherwise. 
743  **/
744 int ngadmin_getVLANDotConf (struct ngadmin *nga, unsigned short vlan, unsigned char *ports);
745
746
747 /**
748  * Set the configuration if a VLAN in 802.1q mode. 
749  * Changes the configuration of a particular VLAN in 802.1q mode. 
750  * @note The switch should be in 802.1q mode. 
751  * @note You must be logged on a switch. 
752  * @param nga A pointer to the ngadmin structure. 
753  * @param vlan The VLAN you want to change the configuration. 
754  * @param ports A pointer to an array of integers which contain the 
755                 configuration. Must not be NULL. 
756  * @return ERR_OK when everything is well or an error code otherwise. 
757  **/
758 int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsigned char *ports);
759
760
761 /**
762  * Destroy a VLAN in 802.1q mode. 
763  * Destroys a particular VLAN in 802.1q mode. 
764  * @note The switch should be in 802.1q mode. 
765  * @note You must be logged on a switch. 
766  * @param nga A pointer to the ngadmin structure. 
767  * @param vlan The VLAN you want to destroy. 
768  * @return ERR_OK when everything is well or an error code otherwise. 
769  **/
770 int ngadmin_VLANDestroy (struct ngadmin *nga, unsigned short vlan);
771
772
773 /**
774  * Get the PVID values. 
775  * Retrieves the PVID values of all the ports. 
776  * @note You must be logged on a switch. 
777  * @param nga A pointer to the ngadmin structure. 
778  * @param ports A pointer to an array of unsigned shorts which will receive the 
779  *              PVID values. Must not be NULL. \n
780  *              The array size must be sizeof(unsigned short)*ports_count. 
781  * @return ERR_OK when everything is well or an error code otherwise. 
782  **/
783 int ngadmin_getAllPVID (struct ngadmin *nga, unsigned short *ports);
784
785
786 /**
787  * Set the PVID of one port. 
788  * Changes the PVID of one port. 
789  * @note You must be logged on a switch. 
790  * @param nga A pointer to the ngadmin structure. 
791  * @param port The port you want to change PVID. 
792  * @param vlan The new PVID value. 
793  * @return ERR_OK when everything is well or an error code otherwise. 
794  **/
795 int ngadmin_setPVID (struct ngadmin *nga, unsigned char port, unsigned short vlan);
796
797
798 #ifdef __cplusplus
799 }
800 #endif
801
802
803
804 #endif
805