]> git.sur5r.net Git - ngadmin/blobdiff - lib/include/ngadmin.h
Add invalid operation error code
[ngadmin] / lib / include / ngadmin.h
index 1f48f2fd738f07a0d01bfe452e11e001676f39ea..49dc761cd2edbac0798cbf69c174651620e78441 100644 (file)
 #include <netinet/ether.h>
 
 
-#ifdef BUILD_LIB
-#define EXPORT __attribute__((visibility("default")))
-#else
-#define EXPORT 
-#endif
-
-
 
 /**
  * Maximum size of product string. 
@@ -55,7 +48,10 @@ enum {
        ERR_INVARG = -6,                /**< invalid argument */
        ERR_TIMEOUT = -7,               /**< timeout */
        ERR_MEM = -8,                   /**< out of memory */
-       ERR_NOTIMPL = -8                /**< not implemented */
+       ERR_NOTIMPL = -9,               /**< not implemented */
+       ERR_BADREPLY = -10,             /**< bad reply */
+       ERR_INVOP = -11,                /**< invalid operation */
+       ERR_UNKNOWN = -12               /**< unknown error */
 };
 
 
@@ -106,10 +102,14 @@ enum {
 #define VLAN_MIN               1
 
 /**
- * Maximum VLAN id. 
+ * Maximum 802.1q VLAN id. 
  **/
-#define VLAN_MAX               4093
+#define VLAN_DOT_MAX           4093
 
+/**
+ * Maximum port VLAN id.
+ **/
+#define VLAN_PORT_MAX          9
 
 
 /**
@@ -241,7 +241,7 @@ extern "C" {
  * @param iface The network interface to use. 
  * @return A pointer to a ngadmin structure, or NULL if an error occurred. 
  */
-struct ngadmin* ngadmin_init (const char *iface) EXPORT;
+struct ngadmin* ngadmin_init (const char *iface);
 
 
 /**
@@ -251,7 +251,7 @@ struct ngadmin* ngadmin_init (const char *iface) EXPORT;
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  */
-int ngadmin_close (struct ngadmin *nga) EXPORT;
+int ngadmin_close (struct ngadmin *nga);
 
 
 /**
@@ -272,7 +272,7 @@ int ngadmin_close (struct ngadmin *nga) EXPORT;
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  */
-int ngadmin_forceInterface (struct ngadmin *nga) EXPORT;
+int ngadmin_forceInterface (struct ngadmin *nga);
 
 
 /**
@@ -293,7 +293,7 @@ int ngadmin_forceInterface (struct ngadmin *nga) EXPORT;
  * @param value Enable or disable the systematic use of broadcast packets. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setKeepBroadcasting (struct ngadmin *nga, bool value) EXPORT;
+int ngadmin_setKeepBroadcasting (struct ngadmin *nga, bool value);
 
 
 /**
@@ -307,7 +307,7 @@ int ngadmin_setKeepBroadcasting (struct ngadmin *nga, bool value) EXPORT;
  * @param value Enable or disable the use of the global broadcast address. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_useGlobalBroadcast (struct ngadmin *nga, bool value) EXPORT;
+int ngadmin_useGlobalBroadcast (struct ngadmin *nga, bool value);
 
 
 /**
@@ -317,7 +317,7 @@ int ngadmin_useGlobalBroadcast (struct ngadmin *nga, bool value) EXPORT;
  * @param pass The password string to use. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setPassword (struct ngadmin *nga, const char *pass) EXPORT;
+int ngadmin_setPassword (struct ngadmin *nga, const char *pass);
 
 
 /**
@@ -327,7 +327,7 @@ int ngadmin_setPassword (struct ngadmin *nga, const char *pass) EXPORT;
  * @param tv A pointer to a timeval structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setTimeout (struct ngadmin *nga, const struct timeval *tv) EXPORT;
+int ngadmin_setTimeout (struct ngadmin *nga, const struct timeval *tv);
 
 
 /**
@@ -338,7 +338,7 @@ int ngadmin_setTimeout (struct ngadmin *nga, const struct timeval *tv) EXPORT;
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_scan (struct ngadmin *nga) EXPORT;
+int ngadmin_scan (struct ngadmin *nga);
 
 
 /**
@@ -349,7 +349,7 @@ int ngadmin_scan (struct ngadmin *nga) EXPORT;
  * @param nb A pointer to an integer which will receive the number of switches. 
  * @return A pointer to an array of switch characteristics. 
  */
-const struct swi_attr* ngadmin_getSwitchTab (struct ngadmin *nga, int *nb) EXPORT;
+const struct swi_attr* ngadmin_getSwitchTab (struct ngadmin *nga, int *nb);
 
 
 /**
@@ -358,7 +358,7 @@ const struct swi_attr* ngadmin_getSwitchTab (struct ngadmin *nga, int *nb) EXPOR
  * @param nga A pointer to the ngadmin structure. 
  * @return A pointer the switch characteristics or NULL if you are not logged. 
  **/
-const struct swi_attr* ngadmin_getCurrentSwitch (struct ngadmin *nga) EXPORT;
+const struct swi_attr* ngadmin_getCurrentSwitch (struct ngadmin *nga);
 
 
 
@@ -371,7 +371,7 @@ const struct swi_attr* ngadmin_getCurrentSwitch (struct ngadmin *nga) EXPORT;
  * @param filename A path to the file of the new firmware to send. 
  * @return ERR_NOTIMPL
  **/
-int ngadmin_upgradeFirmware (struct ngadmin *nga, const char *filename) EXPORT;
+int ngadmin_upgradeFirmware (struct ngadmin *nga, const char *filename);
 
 
 /**
@@ -384,7 +384,7 @@ int ngadmin_upgradeFirmware (struct ngadmin *nga, const char *filename) EXPORT;
  * @param id The id (position in the switch array) of the switch you want to login to. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_login (struct ngadmin *nga, int id) EXPORT;
+int ngadmin_login (struct ngadmin *nga, int id);
 
 
 /**
@@ -396,7 +396,7 @@ int ngadmin_login (struct ngadmin *nga, int id) EXPORT;
  *         Must not be NULL. The array size must be ports_count*sizeof(unsigned char). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getPortsStatus (struct ngadmin *nga, unsigned char *ports) EXPORT;
+int ngadmin_getPortsStatus (struct ngadmin *nga, unsigned char *ports);
 
 
 /**
@@ -407,7 +407,7 @@ int ngadmin_getPortsStatus (struct ngadmin *nga, unsigned char *ports) EXPORT;
  * @param name The name string to use. A NULL value clears the name. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setName (struct ngadmin *nga, const char *name) EXPORT;
+int ngadmin_setName (struct ngadmin *nga, const char *name);
 
 
 /**
@@ -419,7 +419,7 @@ int ngadmin_setName (struct ngadmin *nga, const char *name) EXPORT;
  *        The array size must be ports_count*sizeof(struct port_stats). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps) EXPORT;
+int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps);
 
 
 /**
@@ -429,7 +429,7 @@ int ngadmin_getPortsStatistics (struct ngadmin *nga, struct port_stats *ps) EXPO
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_resetPortsStatistics (struct ngadmin *nga) EXPORT;
+int ngadmin_resetPortsStatistics (struct ngadmin *nga);
 
 
 /**
@@ -441,7 +441,7 @@ int ngadmin_resetPortsStatistics (struct ngadmin *nga) EXPORT;
  * @param pass The new password string to use. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_changePassword (struct ngadmin *nga, const char* pass) EXPORT;
+int ngadmin_changePassword (struct ngadmin *nga, const char* pass);
 
 
 /**
@@ -452,7 +452,7 @@ int ngadmin_changePassword (struct ngadmin *nga, const char* pass) EXPORT;
  * @param s A pointer to an integer which will receive 0 or 1. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getStormFilterState (struct ngadmin *nga, int *s) EXPORT;
+int ngadmin_getStormFilterState (struct ngadmin *nga, int *s);
 
 
 /**
@@ -463,7 +463,7 @@ int ngadmin_getStormFilterState (struct ngadmin *nga, int *s) EXPORT;
  * @param s An integer with value 0 or 1. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setStormFilterState (struct ngadmin *nga, int s) EXPORT;
+int ngadmin_setStormFilterState (struct ngadmin *nga, int s);
 
 
 /**
@@ -475,7 +475,7 @@ int ngadmin_setStormFilterState (struct ngadmin *nga, int s) EXPORT;
  *              The array size must be ports_count*sizeof(int). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports) EXPORT;
+int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports);
 
 
 /**
@@ -487,7 +487,7 @@ int ngadmin_getStormFilterValues (struct ngadmin *nga, int *ports) EXPORT;
  *              The array size must be ports_count*sizeof(int). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports) EXPORT;
+int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports);
 
 
 /**
@@ -499,7 +499,7 @@ int ngadmin_setStormFilterValues (struct ngadmin *nga, const int *ports) EXPORT;
  *              The array size must be ports_count*sizeof(int). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports) EXPORT;
+int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports);
 
 
 /**
@@ -511,7 +511,7 @@ int ngadmin_getBitrateLimits (struct ngadmin *nga, int *ports) EXPORT;
  *              The array size must be ports_count*sizeof(int). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports) EXPORT;
+int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports);
 
 
 /**
@@ -522,7 +522,7 @@ int ngadmin_setBitrateLimits (struct ngadmin *nga, const int *ports) EXPORT;
  * @param s A pointer to an integer. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getQOSMode (struct ngadmin *nga, int *s) EXPORT;
+int ngadmin_getQOSMode (struct ngadmin *nga, int *s);
 
 
 /**
@@ -533,7 +533,7 @@ int ngadmin_getQOSMode (struct ngadmin *nga, int *s) EXPORT;
  * @param s An integer with the new mode. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setQOSMode (struct ngadmin *nga, int s) EXPORT;
+int ngadmin_setQOSMode (struct ngadmin *nga, int s);
 
 
 /**
@@ -546,7 +546,7 @@ int ngadmin_setQOSMode (struct ngadmin *nga, int s) EXPORT;
                 The array size must be ports_count*sizeof(ports). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getQOSValues (struct ngadmin *nga, char *ports) EXPORT;
+int ngadmin_getQOSValues (struct ngadmin *nga, char *ports);
 
 
 /**
@@ -559,7 +559,7 @@ int ngadmin_getQOSValues (struct ngadmin *nga, char *ports) EXPORT;
                 The array size must be ports_count*sizeof(ports). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setQOSValues (struct ngadmin *nga, const char *ports) EXPORT;
+int ngadmin_setQOSValues (struct ngadmin *nga, const char *ports);
 
 
 /**
@@ -571,7 +571,7 @@ int ngadmin_setQOSValues (struct ngadmin *nga, const char *ports) EXPORT;
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_restart (struct ngadmin *nga) EXPORT;
+int ngadmin_restart (struct ngadmin *nga);
 
 
 /**
@@ -583,7 +583,7 @@ int ngadmin_restart (struct ngadmin *nga) EXPORT;
  * @param nga A pointer to the ngadmin structure. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_defaults (struct ngadmin *nga) EXPORT;
+int ngadmin_defaults (struct ngadmin *nga);
 
 
 /**
@@ -599,7 +599,7 @@ int ngadmin_defaults (struct ngadmin *nga) EXPORT;
                 The array size must be (1+ports_count)*sizeof(char). 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getMirror (struct ngadmin *nga, char *ports) EXPORT;
+int ngadmin_getMirror (struct ngadmin *nga, char *ports);
 
 
 /**
@@ -612,7 +612,7 @@ int ngadmin_getMirror (struct ngadmin *nga, char *ports) EXPORT;
                 If it is NULL, port mirroring is disabled. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setMirror (struct ngadmin *nga, const char *ports) EXPORT;
+int ngadmin_setMirror (struct ngadmin *nga, const char *ports);
 
 
 /**
@@ -623,7 +623,7 @@ int ngadmin_setMirror (struct ngadmin *nga, const char *ports) EXPORT;
  * @param ic A pointer to an igmp_conf structure. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic) EXPORT;
+int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic);
 
 
 /**
@@ -634,7 +634,7 @@ int ngadmin_getIGMPConf (struct ngadmin *nga, struct igmp_conf *ic) EXPORT;
  * @param ic A pointer to an igmp_conf structure. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setIGMPConf (struct ngadmin *nga, const struct igmp_conf *ic) EXPORT;
+int ngadmin_setIGMPConf (struct ngadmin *nga, const struct igmp_conf *ic);
 
 
 /**
@@ -648,7 +648,7 @@ int ngadmin_setIGMPConf (struct ngadmin *nga, const struct igmp_conf *ic) EXPORT
  * @param nb The number of elements in the array. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb) EXPORT;
+int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb);
 
 
 /**
@@ -660,7 +660,7 @@ int ngadmin_cabletest (struct ngadmin *nga, struct cabletest *ct, int nb) EXPORT
              Only non-zero fields of the structure are taken into account. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setNetConf (struct ngadmin *nga, const struct net_conf *nc) EXPORT;
+int ngadmin_setNetConf (struct ngadmin *nga, const struct net_conf *nc);
 
 
 /**
@@ -671,7 +671,7 @@ int ngadmin_setNetConf (struct ngadmin *nga, const struct net_conf *nc) EXPORT;
  * @param t A pointer to an integer which will receive the VLAN type. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getVLANType (struct ngadmin *nga, int *t) EXPORT;
+int ngadmin_getVLANType (struct ngadmin *nga, int *t);
 
 
 /**
@@ -682,7 +682,33 @@ int ngadmin_getVLANType (struct ngadmin *nga, int *t) EXPORT;
  * @param t An integer which contains the new VLAN type. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setVLANType (struct ngadmin *nga, int t) EXPORT;
+int ngadmin_setVLANType (struct ngadmin *nga, int t);
+
+
+/**
+ * Get the ports VLANs in port mode. 
+ * Retrieves the associated VLAN of ports in port mode. 
+ * @note The switch should be in port mode. 
+ * @note You must be logged on a switch. 
+ * @param nga A pointer to the ngadmin structure. 
+ * @param ports A pointer to an array of integers which will receive the 
+                number of associated VLAN. Must not be NULL. 
+ * @return ERR_OK when everything is well or an error code otherwise. 
+ **/
+int ngadmin_getVLANPortConf (struct ngadmin *nga, unsigned char *ports);
+
+
+/**
+ * Set the ports VLAN in port mode. 
+ * Changes the associated VLAN of ports in port mode. 
+ * @note The switch should be in port mode. 
+ * @note You must be logged on a switch. 
+ * @param nga A pointer to the ngadmin structure. 
+ * @param ports A pointer to an array of integers which contain the 
+                number of associated VLAN. Must not be NULL. 
+ * @return ERR_OK when everything is well or an error code otherwise. 
+ **/
+int ngadmin_setVLANPortConf (struct ngadmin *nga, const unsigned char *ports);
 
 
 /**
@@ -702,7 +728,7 @@ int ngadmin_setVLANType (struct ngadmin *nga, int t) EXPORT;
              It will receive the actual number of VLAN written in the arrays. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getVLANDotAllConf (struct ngadmin *nga, unsigned short *vlans, unsigned char *ports, int *nb) EXPORT;
+int ngadmin_getVLANDotAllConf (struct ngadmin *nga, unsigned short *vlans, unsigned char *ports, int *nb);
 
 
 /**
@@ -716,7 +742,7 @@ int ngadmin_getVLANDotAllConf (struct ngadmin *nga, unsigned short *vlans, unsig
                 configuration. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getVLANDotConf (struct ngadmin *nga, unsigned short vlan, unsigned char *ports) EXPORT;
+int ngadmin_getVLANDotConf (struct ngadmin *nga, unsigned short vlan, unsigned char *ports);
 
 
 /**
@@ -730,7 +756,7 @@ int ngadmin_getVLANDotConf (struct ngadmin *nga, unsigned short vlan, unsigned c
                 configuration. Must not be NULL. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsigned char *ports) EXPORT;
+int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsigned char *ports);
 
 
 /**
@@ -742,7 +768,7 @@ int ngadmin_setVLANDotConf (struct ngadmin *nga, unsigned short vlan, const unsi
  * @param vlan The VLAN you want to destroy. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_VLANDestroy (struct ngadmin *nga, unsigned short vlan) EXPORT;
+int ngadmin_VLANDestroy (struct ngadmin *nga, unsigned short vlan);
 
 
 /**
@@ -755,7 +781,7 @@ int ngadmin_VLANDestroy (struct ngadmin *nga, unsigned short vlan) EXPORT;
  *              The array size must be sizeof(unsigned short)*ports_count. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_getAllPVID (struct ngadmin *nga, unsigned short *ports) EXPORT;
+int ngadmin_getAllPVID (struct ngadmin *nga, unsigned short *ports);
 
 
 /**
@@ -767,7 +793,7 @@ int ngadmin_getAllPVID (struct ngadmin *nga, unsigned short *ports) EXPORT;
  * @param vlan The new PVID value. 
  * @return ERR_OK when everything is well or an error code otherwise. 
  **/
-int ngadmin_setPVID (struct ngadmin *nga, unsigned char port, unsigned short vlan) EXPORT;
+int ngadmin_setPVID (struct ngadmin *nga, unsigned char port, unsigned short vlan);
 
 
 #ifdef __cplusplus