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