]> git.sur5r.net Git - ngadmin/blob - lib/ngadmin.h
Lib: fixed memory leaks.
[ngadmin] / lib / 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 #include <netinet/ether.h>
16
17
18 #ifdef BUILD_LIB
19 #define EXPORT  __attribute__((visibility("default")))
20 #else
21 #define EXPORT  
22 #endif
23
24
25
26 /**
27  * Maximum size of product string. 
28  */
29 #define PRODUCT_SIZE    64
30
31 /**
32  * Maximum size of name string. 
33  **/
34 #define NAME_SIZE       64
35
36 /**
37  *  Maximum size of firmware version string. 
38  **/
39 #define FIRMWARE_SIZE   64
40
41
42
43 /**
44  * Error codes. 
45  * This enum lists all the error codes the library can return to user. 
46  **/
47 enum {
48  ERR_OK=0,                      /**< no error */
49  ERR_NET=-1,                    /**< network error */
50  ERR_NOTLOG=-2,                 /**< not logged */
51  ERR_DENIED=-3,                 /**< access denied */
52  ERR_BADPASS=-4,                /**< bad password */
53  ERR_BADID=-5,                  /**< bad switch id */
54  ERR_INVARG=-6,                 /**< invalid argument */
55  ERR_TIMEOUT=-7,                /**< timeout */
56  ERR_NOTIMPL=-8                 /**< not implemented */
57 };
58
59
60
61 /**
62  * Port speeds. 
63  * This enum lists all the speeds a port can have. 
64  **/
65 enum {
66  SPEED_DOWN=0,                  /**< link down */
67  SPEED_10=1,                    /**< 10 Mb/s */
68  SPEED_100=4,                   /**< 100 Mb/s */
69  SPEED_1000=5                   /**< 1000 Mb/s */
70 };
71
72
73
74 /**
75  * VLAN types. 
76  * This enum lists all the VLAN types available
77  **/
78 enum {
79  VLAN_DISABLED=0,               /**< VLAN disabled */
80  VLAN_PORT_BASIC=1,             /**< port basic */
81  VLAN_PORT_ADV=2,               /**< port advanced */
82  VLAN_DOT_BASIC=3,              /**< 802.1q basic */
83  VLAN_DOT_ADV=4                 /**< 802.1q advanced */
84 };
85
86
87 /**
88  * VLAN port specification. 
89  * This enum lists all the VLAN specifications a port can have. 
90  **/
91 enum {
92  VLAN_UNSPEC=0xFF,              /**< unspecified */
93  VLAN_NO=0,                     /**< not present */
94  VLAN_UNTAGGED=1,               /**< present, untagged */
95  VLAN_TAGGED=2                  /**< present, tagged */
96 };
97
98
99
100 /**
101  * Minimum VLAN id. 
102  **/
103 #define VLAN_MIN                1
104
105 /**
106  * Maximum VLAN id. 
107  **/
108 #define VLAN_MAX                4093
109
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
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) EXPORT;
683
684
685 /**
686  * Get all the 802.1q VLAN configuration. 
687  * Retrieves all the VLAN configuration in 802.1q mode. 
688  * @note The switch should be in 802.1q mode. 
689  * @note You must be logged on a switch. 
690  * @param nga A pointer to the ngadmin structure. 
691  * @param vlans A pointer to an array of unsigned shorts which will receive 
692  *              VLAN ids. Must not be NULL. \n
693  *              The array size must be sizeof(unsigned short)*(*nb). 
694  * @param ports A pointer to an array of unsigned chars which will receive the 
695                 802.1q configuration for each VLAN. Must not be NULL. \n
696                 The array size must be sizeof(unsigned char)*ports_count*(*nb). 
697  * @param nb A pointer to an integer which contains the maximum number of 
698              elements allowed in the array. Must not be NULL. \n
699              It will receive the actual number of VLAN written in the arrays. 
700  * @return ERR_OK when everything is well or an error code otherwise. 
701  **/
702 int ngadmin_getVLANDotAllConf (struct ngadmin *nga, unsigned short *vlans, unsigned char *ports, int *nb) EXPORT;
703
704
705 /**
706  * Get the configuration of a VLAN in 802.1q mode. 
707  * Retrieves the configuration of a particular VLAN in 802.1q mode. 
708  * @note The switch should be in 802.1q mode. 
709  * @note You must be logged on a switch. 
710  * @param nga A pointer to the ngadmin structure. 
711  * @param vlan The VLAN you want to get the configuration. 
712  * @param ports A pointer to an array of integers which will receive the 
713                 configuration. Must not be NULL. 
714  * @return ERR_OK when everything is well or an error code otherwise. 
715  **/
716 int ngadmin_getVLANDotConf (struct ngadmin *nga, unsigned short vlan, unsigned char *ports) EXPORT;
717
718
719 /**
720  * Set the configuration if a VLAN in 802.1q mode. 
721  * Changes the configuration of a particular VLAN in 802.1q mode. 
722  * @note The switch should be in 802.1q mode. 
723  * @note You must be logged on a switch. 
724  * @param nga A pointer to the ngadmin structure. 
725  * @param vlan The VLAN you want to change the configuration. 
726  * @param ports A pointer to an array of integers which contain the 
727                 configuration. Must not be NULL. 
728  * @return ERR_OK when everything is well or an error code otherwise. 
729  **/
730 int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsigned char *ports) EXPORT;
731
732
733 /**
734  * Destroy a VLAN in 802.1q mode. 
735  * Destroys a particular VLAN in 802.1q mode. 
736  * @note The switch should be in 802.1q mode. 
737  * @note You must be logged on a switch. 
738  * @param nga A pointer to the ngadmin structure. 
739  * @param vlan The VLAN you want to destroy. 
740  * @return ERR_OK when everything is well or an error code otherwise. 
741  **/
742 int ngadmin_VLANDestroy (struct ngadmin *nga, unsigned short vlan) EXPORT;
743
744
745 /**
746  * Get the PVID values. 
747  * Retrieves the PVID values of all the ports. 
748  * @note You must be logged on a switch. 
749  * @param nga A pointer to the ngadmin structure. 
750  * @param ports A pointer to an array of unsigned shorts which will receive the 
751  *              PVID values. Must not be NULL. \n
752  *              The array size must be sizeof(unsigned short)*ports_count. 
753  * @return ERR_OK when everything is well or an error code otherwise. 
754  **/
755 int ngadmin_getAllPVID (struct ngadmin *nga, unsigned short *ports) EXPORT;
756
757
758 /**
759  * Set the PVID of one port. 
760  * Changes the PVID of one port. 
761  * @note You must be logged on a switch. 
762  * @param nga A pointer to the ngadmin structure. 
763  * @param port The port you want to change PVID. 
764  * @param vlan The new PVID value. 
765  * @return ERR_OK when everything is well or an error code otherwise. 
766  **/
767 int ngadmin_setPVID (struct ngadmin *nga, unsigned char port, unsigned short vlan) EXPORT;
768
769
770 #ifdef __cplusplus
771 }
772 #endif
773
774
775
776 #endif
777