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