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