--- /code/originalrstp/rstp.c	Tue Apr 01 05:48:28 2008
+++ /code/RSTP/rstp.c	Wed Oct 29 12:27:55 2008
@@ -42,22 +43,41 @@
 
 
 /* memcmp wrapper, validating size equality of _a and _b */
+#ifndef __GNUC__
+#define CMP(_a, _op, _b)                                           \
+(memcmp(&(_a), &(_b),                                              \
+  __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
+                        sizeof(_a),                                \
+                        0)                                   \
+) _op 0)
+#else
 #define CMP(_a, _op, _b)                                           \
 (memcmp(&(_a), &(_b),                                              \
   __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
                         sizeof(_a),                                \
                         (void)0)                                   \
 ) _op 0)
+#endif
 
 #define ZERO(_a) memset(&(_a), 0, sizeof(_a))
 
 /* memcmp wrapper, validating size equality of _a and _b */
+#ifndef __GNUC__
+#define CPY(_a, _b)                                           \
+(memcpy(&(_a), &(_b),                                              \
+  __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
+                        sizeof(_a),                                \
+                        0)                                   \
+))
+#else
 #define CPY(_a, _b)                                           \
 (memcpy(&(_a), &(_b),                                              \
   __builtin_choose_expr(sizeof(_a) == sizeof(_b),                  \
                         sizeof(_a),                                \
                         (void)0)                                   \
 ))
+#endif
+
 
 #define BRIDGE_ARGS_PROTO        Bridge *BRIDGE
 #define PORT_ARGS_PROTO          Bridge *BRIDGE, Port *PORT
@@ -71,19 +91,36 @@
    That way log messages can use BRIDGE and PORT always.
 */
 
+#ifndef __GNUC__
+struct _dummy_user_ref_struct
+{
+  void *user_ref;
+} _user_ref_var = { NULL },
+  *BRIDGE = &_user_ref_var, *PORT = &_user_ref_var;
+#else
 struct _dummy_user_ref_struct
 {
   void *user_ref;
 } _user_ref_var = { .user_ref = NULL},
   *BRIDGE = &_user_ref_var, *PORT = &_user_ref_var;
+#endif
 
 /* Logging macros */
+#ifndef __GNUC__
+#define DEBUG(...) \
+  STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_DEBUG, __VA_ARGS__)
+#define ERROR(...) \
+  STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_ERROR, __VA_ARGS__)
+#define ABORT(...) \
+  { ERROR(__VA_ARGS__);}
+#else
 #define DEBUG(fmt...) \
   STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_DEBUG, fmt)
 #define ERROR(fmt...) \
   STP_OUT_logmsg(BRIDGE->user_ref, PORT->user_ref, STP_LOG_LEVEL_ERROR, fmt)
 #define ABORT(fmt...) \
   ({ ERROR(fmt); *(int *)0 = 1; })
+#endif
 
 /***************** Macros for state machine descriptions ********************/
 
@@ -102,9 +139,23 @@
 #define STM_FUNC(_name) _CAT(_name, func)
 
 /* BEGIN is state 0 in all state machines */
+#ifndef __GNUC__
+#define STATES(...) enum _CAT(STM_NAME, states) { STN(BEGIN), __VA_ARGS__ }
+#else
 #define STATES(_args...) enum _CAT(STM_NAME, states) { STN(BEGIN), _args }
+#endif
 
 /* Transition definition */
+#ifndef __GNUC__
+#define TR(_cond, _new_state) \
+{                                                                           \
+  if (_cond) {                                                               \
+    new_state = STN(_new_state);                                             \
+    DEBUG("%s: Transition to state %s\n", _STR(STM_NAME), #_new_state);      \
+    goto STM_LABEL(_new_state);                                              \
+  }                                                                          \
+}
+#else
 #define TR(_cond, _new_state) \
 ({                                                                           \
   if (_cond) {                                                               \
@@ -113,6 +164,7 @@
     goto STM_LABEL(_new_state);                                              \
   }                                                                          \
 })
+#endif
 
 /* Global conditions: Transition conditions that don't depend on current state.
    In our state machine, they get checked after those that are specific to the
@@ -120,17 +172,32 @@
    new_state is the state we last transitioned to, or 0 if no transition
    was made.
 */
+#ifndef __GNUC__
+#define GC(...)      \
+         global_conditions:      \
+             __VA_ARGS__         \
+             return new_state
+#else
 #define GC(_transitions...)      \
          global_conditions:      \
              _transitions        \
              return new_state
+#endif
 
 /* Transitions from BEGIN state */
+#ifndef __GNUC__
+#define BG(...)                                              \
+         case STN(BEGIN):                                                \
+             __VA_ARGS__                                                \
+             ABORT("%s: No where to go from BEGIN\n", _STR(STM_NAME));   \
+             return -1
+#else
 #define BG(_transitions...)                                              \
          case STN(BEGIN):                                                \
              _transitions                                                \
              ABORT("%s: No where to go from BEGIN\n", _STR(STM_NAME));   \
              return -1
+#endif
 
 /* State definition */
 #define ST(_state, _actions, _transitions) \
@@ -142,12 +209,31 @@
              _transitions                  \
              goto global_conditions
 
+#ifndef __GNUC__
+#define STM_FUNC_DECL(_type, ...) \
+  int _type(int state, int single_step, __VA_ARGS__)
+#else
 #define STM_FUNC_DECL(_type, _args...) \
   int _type(int state, int single_step, _args)
+#endif
+
 
 /* This just barely works. _args expansion includes commas */
 //int STM_FUNC(STM_NAME)(int state, int single_step, _args)
 
+#ifndef __GNUC__
+#define STM(_args, ...)                                 \
+static STM_FUNC_DECL(STM_FUNC(STM_NAME), _args)                  \
+{                                                                \
+  int new_state = 0;                                             \
+  switch (state) {                                               \
+    __VA_ARGS__                                                  \
+      default:                                                   \
+    ABORT("%s: Got unknown state %d\n", __func__, state);        \
+    return -1;                                                   \
+  }                                                              \
+}
+#else
 #define STM(_args, _contents...)                                 \
 static STM_FUNC_DECL(STM_FUNC(STM_NAME), _args)                  \
 {                                                                \
@@ -159,9 +245,21 @@
     return -1;                                                   \
   }                                                              \
 }
+#endif
+
 
 #define UCT 1
 
+#ifndef __GNUC__
+#define STM_RUN(_state, _transitioned, _func, ...) \
+{                                                               \
+  int new_state = _func(*_state, 0/*no single step*/, __VA_ARGS__);    \
+  if (new_state > 0) {                                           \
+    *_state = new_state;                                         \
+    *_transitioned = TRUE;                                       \
+  }                                                              \
+}
+#else
 #define STM_RUN(_state, _transitioned, _func, _args...) \
 ({                                                               \
   int new_state = _func(*_state, 0/*no single step*/, _args);    \
@@ -170,11 +268,20 @@
     *_transitioned = TRUE;                                       \
   }                                                              \
 })
+#endif
 
+#ifndef __GNUC__
+#define STM_BEGIN(_state, _func, ...) \
+{                                                               \
+  *_state = _func(0/*BEGIN*/, 1/*single step*/, __VA_ARGS__);          \
+}
+#else
 #define STM_BEGIN(_state, _func, _args...) \
 ({                                                               \
   *_state = _func(0/*BEGIN*/, 1/*single step*/, _args);          \
 })
+#endif
+
 
 /************ End of Macros for state machine descriptions ***********/
 
@@ -188,14 +295,26 @@
 
 typedef uint bool;
 
-typedef struct _BridgeId {
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
+typedef COMPILER_INLINE_PACK struct _BridgeId {
   uchar bridge_identifier_priority[2];
   uchar bridge_address[6];
 } __attribute__((packed)) BridgeId;
-
-typedef struct {
+#ifdef __ICCARM__
+#pragma pack()
+#endif
+
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
+typedef COMPILER_INLINE_PACK struct _PathCost{
   uchar cost[4];
 } __attribute__((packed)) PathCost;
+#ifdef __ICCARM__
+#pragma pack()
+#endif
 
 static inline uint path_cost_to_uint(PathCost x)
 {
@@ -204,7 +323,22 @@
 
 }
 
+#ifndef __GNUC__
+static inline PathCost path_cost_add(PathCost x, uint y)
+{
+  PathCost r;
+
+  uint z = y +
+    (x.cost[0] << 24) + (x.cost[1] << 16) + (x.cost[2] << 8) + (x.cost[3]);
+
+  r.cost[0] = (z >> 24);
+  r.cost[1] = (z >> 16) & 0xff;
+  r.cost[2] = (z >> 8) & 0xff;
+  r.cost[3] = z & 0xff;
 
+  return r;
+}
+#else
 static inline PathCost path_cost_add(PathCost x, uint y)
 {
   uint z = y +
@@ -219,16 +353,27 @@
   return r;
 }
 
-typedef struct _PortId {
+#endif
+
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
+typedef COMPILER_INLINE_PACK struct _PortId {
   uchar port_id[2]; /* 4 high bits of priority and 12 for Id */
 } __attribute__((packed)) PortId;
+#ifdef __ICCARM__
+#pragma pack()
+#endif
 
 static inline uint port_id_to_uint(PortId p)
 {
   return (p.port_id[0] << 8) + p.port_id[1];
 }
 
-typedef struct _PriorityVector
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
+typedef COMPILER_INLINE_PACK struct _PriorityVector
 {
   BridgeId root_bridge_id;
   PathCost root_path_cost;
@@ -236,16 +381,24 @@
   PortId   designated_port_id;
   PortId   bridge_port_id;
 } __attribute__((packed)) PriorityVector;
-
+#ifdef __ICCARM__
+#pragma pack()
+#endif
+
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
 /* First 4 components of priority vector */
-typedef struct _PriorityVector4
+typedef COMPILER_INLINE_PACK struct _PriorityVector4
 {
   BridgeId root_bridge_id;
   PathCost root_path_cost;
   BridgeId designated_bridge_id;
   PortId   designated_port_id;
 } __attribute__((packed)) PriorityVector4;
-
+#ifdef __ICCARM__
+#pragma pack()
+#endif
 
 typedef struct _Times
 {
@@ -314,13 +467,18 @@
 
 #define STP_PROTOCOL_ID 0
 
-typedef struct _RawBPDU
+#ifdef __ICCARM__
+#pragma pack(1)
+#endif
+typedef COMPILER_INLINE_PACK struct _RawBPDU
 {
   uint16 protocol_id;
   uchar version;
   uchar type;
+#ifdef __GNUC__
   /* TCN has only upto this */
   uchar TCN_END[0];
+#endif
   uchar flags;
 #define BPDU_FLAG_TC                     0x1
 #define BPDU_FLAG_PROPOSAL               0x2
@@ -339,15 +497,26 @@
   uchar hello_time[2];
   uchar forward_delay[2];
   /* End of Config BPDU */
+#ifdef __GNUC__
   uchar CONFIG_END[0];
-
+#endif
   uchar version1_len;
   /* End of RST BPDU */
+#ifdef __GNUC__
   uchar RST_END[0];
-
+#endif
 } __attribute__((packed)) RawBPDU;
+#ifdef __ICCARM__
+#pragma pack()
+#endif
 
 
+#ifndef __GNU_C
+// Markers not allowed
+#define TCN_END_SIZE_BYTES    4
+#define CONFIG_END_SIZE_BYTES (sizeof(RawBPDU) - sizeof(uchar))
+#define RST_END_SIZE_BYTES    (sizeof(RawBPDU))
+#endif
 
 /* Values for adminPointToPointMAC */
 typedef enum _AdminP2P {
@@ -825,6 +994,20 @@
 /* PORT is not defined by this but is possible defined where this is used.
    FPORT iterates over all ports, so we need to use the FPORT->_field
    (with underscore) for for port variables in the expression here */
+#ifndef __GNUC__
+static bool g_ForAllPortBool;
+#define ForAllPort(result, expr)                                                     \
+{                                                                           \
+  Port *FPORT;                                                               \
+  bool res = TRUE;                                                           \
+  for (FPORT = BRIDGE->port_list; FPORT != NULL; FPORT = FPORT->port_next)   \
+    if (!(expr)) {                                                           \
+      res = FALSE;                                                           \
+      break;                                                                 \
+    }                                                                        \
+  result = res;                                                                       \
+}
+#else
 #define ForAllPort(expr)                                                     \
 ({                                                                           \
   Port *FPORT;                                                               \
@@ -836,17 +1019,27 @@
     }                                                                        \
   res;                                                                       \
 })
+#endif
 
 /* Execute statements for all ports */
 /* PORT is not defined by this but is possible defined where this is used.
    FPORT iterates over all ports, so we need to use the FPORT->_field
    (with underscore) for for port variables in statements here */
+#ifndef __GNUC__
+#define ForAllPortDo(...)                                          \
+{                                                                           \
+  Port *FPORT;                                                               \
+  for (FPORT = BRIDGE->port_list; FPORT != NULL; FPORT = FPORT->port_next)   \
+    { __VA_ARGS__ }                                                           \
+}
+#else
 #define ForAllPortDo(statements...)                                          \
 ({                                                                           \
   Port *FPORT;                                                               \
   for (FPORT = BRIDGE->port_list; FPORT != NULL; FPORT = FPORT->port_next)   \
     { statements }                                                           \
 })
+#endif
 
 // 17.20 ----- conditions and paramaters
 
@@ -857,7 +1050,7 @@
 #define AutoEdge AutoEdgePort
 
 // 17.20.3
-#define allSynced ForAllPort(FPORT->_synced || FPORT->_role == RootPort)
+#define allSynced(result) ForAllPort(result, FPORT->_synced || FPORT->_role == RootPort)
 
 // 17.20.4
 #define EdgeDelay (operPointToPointMAC?MigrateTime:MaxAge)
@@ -878,7 +1071,7 @@
 // #define MigrateTime MigrateTime
 
 // 17.20.10
-#define reRooted ForAllPort(FPORT == PORT || FPORT->_rrWhile == 0)
+#define reRooted(result) ForAllPort(result, FPORT == PORT || FPORT->_rrWhile == 0)
 
 // 17.20.11
 #define rstpVersion (ForceProtocolVersion >= 2)
@@ -968,10 +1161,15 @@
   BRIDGE->tcWhile_count+= change;
 }
 
+#ifndef __GNUC__
+#define set_tcWhile(_val) \
+{ uint _oldval = tcWhile; tcWhile = _val; \
+   update_tcWhile_count(BRIDGE_ARGS, (tcWhile?1:0) - (_oldval?1:0)); }
+#else
 #define set_tcWhile(_val) \
 ({ uint _oldval = tcWhile; tcWhile = _val; \
    update_tcWhile_count(BRIDGE_ARGS, (tcWhile?1:0) - (_oldval?1:0)); })
-
+#endif
 
 // 17.21.7
 static void newTcWhile(PORT_ARGS_PROTO)
@@ -1113,7 +1311,9 @@
 // 17.21.16
 static void setSelectedTree(BRIDGE_ARGS_PROTO)
 {
-  if (ForAllPort(FPORT->_reselect == FALSE))
+  bool temp;
+  ForAllPort(temp, FPORT->_reselect == FALSE);
+  if (temp)
     ForAllPortDo(
                  FPORT->_selected = TRUE;
                  );
@@ -1167,6 +1367,7 @@
 static void txConfig(PORT_ARGS_PROTO)
 {
   RawBPDU b;
+  int flags;
 
   b.protocol_id = STP_PROTOCOL_ID;
   b.version = 0;
@@ -1174,7 +1375,7 @@
 
   b.priority = designatedPriority;
 
-  int flags = 0;
+  flags = 0;
   flags |= (tcWhile != 0) ? BPDU_FLAG_TC : 0;
   flags |= (tcAck) ? BPDU_FLAG_TC_ACK : 0;
   b.flags = flags;
@@ -1182,13 +1383,19 @@
   set_bpdu_times(&b, &designatedTimes);
 
   DEBUG("Sending Config BPDU\n");
+#ifndef __GNUC__
+  STP_OUT_tx_bpdu(PORT->user_ref, &b, CONFIG_END_SIZE_BYTES);
+#else
   STP_OUT_tx_bpdu(PORT->user_ref, &b, offsetof(RawBPDU, CONFIG_END));
+#endif
 }
 
 // 17.21.20
 static void txRstp(PORT_ARGS_PROTO)
 {
   RawBPDU b;
+  int flags;
+  int r;
 
   b.protocol_id = STP_PROTOCOL_ID;
   b.version = 2;
@@ -1196,9 +1403,9 @@
 
   b.priority = designatedPriority;
 
-  int flags = 0;
+  flags = 0;
 
-  int r = role;
+  r = role;
   if (r == AlternatePort || r == BackupPort)
     r = AltBackupPort;
 
@@ -1218,7 +1425,11 @@
   b.version1_len = 0;
 
   DEBUG("Sending RST BPDU\n");
+#ifndef __GNUC__
+  STP_OUT_tx_bpdu(PORT->user_ref, &b, RST_END_SIZE_BYTES);
+#else
   STP_OUT_tx_bpdu(PORT->user_ref, &b, offsetof(RawBPDU, RST_END));
+#endif
 }
 
 // 17.21.21
@@ -1231,7 +1442,12 @@
   b.type = BPDUTypeTCN;
 
   DEBUG("Sending TCN BPDU\n");
+#ifndef __GNUC__
+  STP_OUT_tx_bpdu(PORT->user_ref, &b, TCN_END_SIZE_BYTES);
+#else
   STP_OUT_tx_bpdu(PORT->user_ref, &b, offsetof(RawBPDU, TCN_END));
+#endif
+
 }
 
 // 17.21.22
@@ -1419,7 +1635,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, ONE_SECOND);
@@ -1502,7 +1718,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, CHECKING_RSTP);
@@ -1546,7 +1762,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(AdminEdge, EDGE);
@@ -1586,7 +1802,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, TRANSMIT_INIT);
@@ -1772,7 +1988,7 @@
 
 STM(BRIDGE_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, INIT_BRIDGE);
@@ -1789,7 +2005,8 @@
        updtRolesTree(BRIDGE_ARGS);
        setSelectedTree(BRIDGE_ARGS);
        ,
-       TR(!ForAllPort(!FPORT->_reselect), ROLE_SELECTION);
+       ForAllPort(g_ForAllPortBool,!FPORT->_reselect);
+       TR(!g_ForAllPortBool, ROLE_SELECTION);
        );
 
     );
@@ -1935,14 +2152,17 @@
        rrWhile = FwdDelay;
        ,
        TR(proposed && !agree && xc, ROOT_PROPOSED);
-       TR(((allSynced && !agree) || (proposed && agree)) && xc, ROOT_AGREED);
+       allSynced(g_ForAllPortBool);
+       TR(((g_ForAllPortBool && !agree) || (proposed && agree)) && xc, ROOT_AGREED);
        TR(((agreed && !synced) || (sync && synced)) && xc, ROOT_SYNCED);
        TR(!forward && !reRoot && xc, REROOT);
        TR(reRoot && forward && xc, REROOTED);
+       reRooted(g_ForAllPortBool);
        TR((fdWhile == 0 ||
-           ((reRooted && (rbWhile == 0)) && (rstpVersion))) && !learn && xc,
+           ((g_ForAllPortBool && (rbWhile == 0)) && (rstpVersion))) && !learn && xc,
           ROOT_LEARN);
-       TR((fdWhile == 0 || ((reRooted && (rbWhile == 0)) && (rstpVersion)))
+       reRooted(g_ForAllPortBool);
+       TR((fdWhile == 0 || ((g_ForAllPortBool && (rbWhile == 0)) && (rstpVersion)))
           && learn && !forward && xc,
           ROOT_FORWARD);
        TR(rrWhile != FwdDelay && xc, ROOT_PORT);
@@ -2058,7 +2278,8 @@
        ,
        TR(proposed && !agree && xc,
           ALTERNATE_PROPOSED);
-       TR(((allSynced && !agree) || (proposed && agree)) && xc,
+       allSynced(g_ForAllPortBool);
+       TR(((g_ForAllPortBool && !agree) || (proposed && agree)) && xc,
           ALTERNATE_AGREED);
        TR((rbWhile != 2*HelloTime) && (role == BackupPort) && xc,
           BACKUP_PORT);
@@ -2080,7 +2301,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, DISCARDING);
@@ -2125,7 +2346,7 @@
 
 STM(PORT_ARGS_PROTO,
 
-    GC();
+    GC(;);
 
     BG(
        TR(UCT, INACTIVE);
@@ -2248,11 +2469,12 @@
 
 static void state_machines_run(BRIDGE_ARGS_PROTO)
 {
+  int i;
+  bool transitioned;
+
   if (!BRIDGE->stp_on)
     return;
 
-  int i;
-  bool transitioned;
   do {
     transitioned = FALSE;
     for (i = 0; i < NUM_BRIDGE_STATE_MACHINES; i++)
@@ -2268,10 +2490,10 @@
 
 static void state_machines_begin(BRIDGE_ARGS_PROTO)
 {
+  int i;
   if (!BRIDGE->stp_on)
     return;
 
-  int i;
   for (i = 0; i < NUM_BRIDGE_STATE_MACHINES; i++)
     STM_BEGIN(&BRIDGE->state[i], bridge_stms[i], BRIDGE_ARGS);
 
@@ -2520,6 +2742,9 @@
 int STP_IN_set_bridge_config(Bridge *BRIDGE, const STP_BridgeConfig *cfg)
 {
   int r = 0;
+  Times new_times;
+  bool set_times;
+
   bool changed = FALSE, init = FALSE;
   /* First, validation */
 
@@ -2540,8 +2765,8 @@
     }
   }
 
-  Times new_times = BridgeTimes;
-  bool set_times = FALSE;
+  new_times = BridgeTimes;
+  set_times = FALSE;
 
   if (cfg->set_bridge_hello_time) {
     // 17.14 - Table 17-1
@@ -2782,6 +3007,16 @@
 typedef STP_BridgeConfig  STP_bridgeConfig;
 typedef STP_PortConfig    STP_portConfig;
 
+#ifndef __GNUC__
+#define SET_CFG(_type, _arg, _field, _value, _retval) \
+{                                                           \
+  STP_ ## _type ## Config cfg;                               \
+  ZERO(cfg);                                                 \
+  cfg._type ## _ ## _field = _value;                         \
+  cfg. set_ ## _type ## _ ## _field = 1;                     \
+  _retval = STP_IN_set_ ## _type ## _config(_arg, &cfg);               \
+}
+#else
 #define SET_CFG(_type, _arg, _field, _value) \
 ({                                                           \
   STP_ ## _type ## Config cfg;                               \
@@ -2790,44 +3025,59 @@
   cfg. set_ ## _type ## _ ## _field = 1;                     \
   STP_IN_set_ ## _type ## _config(_arg, &cfg);               \
 })
+#endif
 
 /* Single field Bridge config functions */
 
 int STP_IN_set_protocol_version(Bridge *BRIDGE, unsigned int version)
 {
-  return SET_CFG(bridge, BRIDGE, protocol_version, version);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, protocol_version, version, retval);
+  return retval;
 }
 
 int STP_IN_set_bridge_address(Bridge *BRIDGE, const STP_MacAddress *addr)
 {
-  return SET_CFG(bridge, BRIDGE, address, *addr);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, address, *addr, retval);
+  return retval;
 }
 
 int STP_IN_set_bridge_priority(Bridge *BRIDGE, unsigned int priority)
 {
-  return SET_CFG(bridge, BRIDGE, priority, priority);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, priority, priority, retval);
+  return retval;
 }
 
 int STP_IN_set_bridge_hello_time(Bridge *BRIDGE, unsigned int hello_time)
 {
-  return SET_CFG(bridge, BRIDGE, hello_time, hello_time);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, hello_time, hello_time, retval);
+  return retval;
 }
 
 int STP_IN_set_bridge_max_age(Bridge *BRIDGE, unsigned int max_age)
 {
-  return SET_CFG(bridge, BRIDGE, max_age, max_age);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, max_age, max_age, retval);
+  return retval;
 }
 
 
 int STP_IN_set_bridge_forward_delay(Bridge *BRIDGE, unsigned int fwd_delay)
 {
-  return SET_CFG(bridge, BRIDGE, forward_delay, fwd_delay);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, forward_delay, fwd_delay, retval);
+  return retval;
 }
 
 
 int STP_IN_set_tx_hold_count(Bridge *BRIDGE, unsigned int count)
 {
-  return SET_CFG(bridge, BRIDGE, tx_hold_count, count);
+  bool retval;
+  SET_CFG(bridge, BRIDGE, tx_hold_count, count, retval);
+  return retval;
 }
 
 
@@ -2835,28 +3085,38 @@
 
 int STP_IN_set_port_priority(Port *PORT, unsigned int priority)
 {
-  return SET_CFG(port, PORT, priority, priority);
+  bool retval;
+  SET_CFG(port, PORT, priority, priority, retval);
+  return retval;
 }
 
 int STP_IN_set_port_pathcost(Port *PORT, unsigned int pcost)
 {
-  return SET_CFG(port, PORT, pathcost, pcost);
+  bool retval;
+  SET_CFG(port, PORT, pathcost, pcost, retval);
+  return retval;
 }
 
 /* edge is 0 or 1 */
 int STP_IN_set_port_admin_edge(Port *PORT, unsigned int edge)
 {
-  return SET_CFG(port, PORT, admin_edge, edge);
+  bool retval;
+  SET_CFG(port, PORT, admin_edge, edge, retval);
+  return retval;
 }
 
 int STP_IN_set_port_auto_edge(Port *PORT, unsigned int edge)
 {
-  return SET_CFG(port, PORT, auto_edge, edge);
+  bool retval;
+  SET_CFG(port, PORT, auto_edge, edge, retval);
+  return retval;
 }
 
 int STP_IN_set_port_admin_p2p(Port *PORT, unsigned int p2p)
 {
-  return SET_CFG(port, PORT, admin_p2p, p2p);
+  bool retval;
+  SET_CFG(port, PORT, admin_p2p, p2p, retval);
+  return retval;
 }
 
 /* Force migration check */
@@ -2957,6 +3217,7 @@
  */
 Bridge *STP_IN_bridge_create(void *user_ref)
 {
+  Bridge *BRIDGE;
   Bridge *b = STP_OUT_mem_zalloc(sizeof(Bridge));
 
   if (!b) {
@@ -2966,7 +3227,7 @@
 
   b->user_ref = user_ref;
 
-  Bridge *BRIDGE = b;
+  BRIDGE = b;
 
   /* Default configuration values */
   BridgeIdentifierPriority[0] = 0x80; // Default bridge priority = 32768
@@ -3003,12 +3264,15 @@
 Port *STP_IN_port_create(Bridge *BRIDGE,
                          unsigned int port_number, void *user_ref)
 {
+  Port *p;
+  Port *PORT;
+
   if (port_number == 0 || (port_number & ~0x0fff)) {
     ERROR("Port id should be in the range 1 - 1023\n");
     return NULL;
   }
 
-  Port *p = STP_OUT_mem_zalloc(sizeof(Port));
+  p = STP_OUT_mem_zalloc(sizeof(Port));
 
   if (!p) {
     ERROR("Couldn't allocate memory for port\n");
@@ -3021,7 +3285,7 @@
   p->port_next = BRIDGE->port_list;
   BRIDGE->port_list = p;
 
-  Port *PORT = p;
+  PORT = p;
 
   portId.port_id[0] = 0x80 | (port_number >> 8); // Default port priority = 128
   portId.port_id[1] = port_number & 0xff;
@@ -3048,6 +3312,7 @@
 void STP_IN_port_delete(Port *PORT)
 {
   Bridge *BRIDGE = PORT->bridge;
+  Port **prev; 
 
   /* Disable */
   if (portEnabled) {
@@ -3056,7 +3321,7 @@
   }
 
   /* Find position in list */
-  Port **prev = &BRIDGE->port_list;
+  prev = &BRIDGE->port_list;
   while (*prev != PORT && *prev != NULL)
     prev = &(*prev)->port_next;
 
