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