Commits

Alessio Caiazza  committed 9be8db2

fixed vlan id display.

VLAN ID goes from 1 to 4096 wich fits a uint16_t.
Now the codes works also on 64 bit machine.

  • Participants
  • Parent commits 9dcea83

Comments (0)

Files changed (2)

 unsigned char * gs105e_queryData;
 unsigned int gsDataLen;
 
-struct vlan * getVlanSetting(unsigned int vlanId) {
+struct vlan * getVlanSetting(uint16_t vlanId) {
         struct vlan *  _vlan = settings.vlans;
         
         while (_vlan != NULL) {
         return NULL;
 }
 
-void addVlanSetting(unsigned int vlanId, unsigned char tagged, unsigned char member) {
+void addVlanSetting(uint16_t vlanId, unsigned char tagged, unsigned char member) {
         struct vlan * old = settings.vlans;
         struct vlan * new = (struct vlan *) malloc (sizeof( struct vlan) );
         new->id = vlanId;
         return a;
 }
 
-unsigned int toUInt(char * data) {
+uint16_t toU16I(char *data) {
         int n;
-        unsigned int a;
+        uint16_t a;
         for (n = 0; n < 2; n++) {
                 a <<= 8;
                 a |= ((unsigned int )data[n]) & 0xFF;
                         p->errors = toLong(&data[41]);
                         break;
                 case GS_VLAN:;
-                        unsigned int vlanId = toUInt(data);
+                        uint16_t vlanId = toU16I(data);
                         unsigned char tagged = (unsigned char) data[3];
                         unsigned char memberOf = (unsigned char) data[2];
                         struct vlan * _vlan = getVlanSetting(vlanId);
 }
 
 
-int gs105e_addVlan(int vlanId) {
+int gs105e_addVlan(uint16_t vlanId) {
         makeHeader(QR_EXEC);
         
         char data[4] = {vlanId / 256, vlanId % 256, 0, 0};
         
 }
 
-int gs105e_setVlanMembers(unsigned int vlanId, unsigned int members, unsigned int tagged) {
+int gs105e_setVlanMembers(uint16_t vlanId, unsigned int members, unsigned int tagged) {
         char data[4] = {0, vlanId & 0xFF, (char)members & 0xFF, (char)tagged & 0xFF};
         makeHeader(QR_EXEC);
         addActData(GS_VLAN, 4, data);
 }
 
 
-int gs105e_delVlan(int vlanId) {
+int gs105e_delVlan(uint16_t vlanId) {
         makeHeader(QR_EXEC);
         
         char data[2] = {vlanId / 256, vlanId % 256};
         return gs105e_act();
         
 }
-int gs105e_restart(int vlanId) {
+int gs105e_restart(uint16_t vlanId) {
         makeHeader(QR_EXEC);
         
         char data[1] = {1};
                 }
                 settings.vlans = NULL;
         }
-                
+
         makeHeader(QR_REQ);
         addQuery(GS_MODEL);
         addQuery(GS_NAME);
         addQuery(GS_VLANSETTING);
         
         gs105e_query ();
-         gs105e_receive();       
+        gs105e_receive();
 }
 #ifndef GS105E_H
 #define GS105E_H
 #include <stdio.h>
+#include <stdint.h>
 
 #define GS_MODEL 0x0001
 #define GS_NAME 0x0003
 int packetId;
 
 struct vlan {
-        int id;
+        uint16_t id;
         char members;
         char tag;
         struct vlan * next;
 
 void gs105e_query (void);
 
-int gs105e_addVlan(int vlanId) ;
-int gs105e_delVlan(int vlanId) ;
+int gs105e_addVlan(uint16_t vlanId) ;
+int gs105e_delVlan(uint16_t vlanId) ;
 int gs105e_discover(void);
 
 int gs105e_setName(char * data);