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