diff --git a/include/l2.h b/include/l2.h index e0533c4..d1818e5 100755 --- a/include/l2.h +++ b/include/l2.h @@ -74,7 +74,7 @@ BYTE destination_address_DSAP; BYTE source_address_SSAP; BYTE llc_frame_type; - } __attribute__((aligned(1))) LLC_HEADER; + } __attribute__((__packed__)) LLC_HEADER; typedef struct SNAP_HEADER { @@ -85,13 +85,13 @@ BYTE protocol_id_filler[3]; UINT16 protocol_id; - } __attribute__((aligned(2))) SNAP_HEADER; + } __attribute__((__packed__)) SNAP_HEADER; typedef struct MAC_ADDRESS { UINT32 _ulong; UINT16 _ushort; - } __attribute__((aligned(4))) MAC_ADDRESS; + } __attribute__((__packed__)) MAC_ADDRESS; #define COPY_MAC(sptr_mac2, sptr_mac1) \ (memcpy(sptr_mac2, sptr_mac1, sizeof(MAC_ADDRESS))) @@ -111,7 +111,7 @@ MAC_ADDRESS source_address; USHORT length; - } __attribute__((aligned(4))) MAC_HEADER; + } __attribute__((__packed__)) MAC_HEADER; #define STP_BPDU_OFFSET (sizeof(MAC_HEADER) + sizeof(LLC_HEADER)) #define PVST_BPDU_OFFSET (sizeof(MAC_HEADER) + sizeof(SNAP_HEADER)) @@ -186,4 +186,4 @@ memset(_instance_mask_ptr_, 0, sizeof(L2_PROTO_INSTANCE_MASK)) #endif //__L2_H__ - \ No newline at end of file + diff --git a/include/mstp_common.h b/include/mstp_common.h index a15b69a..4f033a6 100755 --- a/include/mstp_common.h +++ b/include/mstp_common.h @@ -45,7 +45,7 @@ typedef struct // mac-address for the bridge MAC_ADDRESS address; -}__attribute__((aligned(4))) MSTP_BRIDGE_IDENTIFIER; +}__attribute__((__packed__)) MSTP_BRIDGE_IDENTIFIER; /*****************************************************************************/ /* msti configuration message structure */ @@ -69,7 +69,7 @@ typedef struct UINT8 agreement:1; UINT8 master:1; #endif -} __attribute__((aligned(4)))MSTI_FLAGS; +} __attribute__((__packed__))MSTI_FLAGS; /*****************************************************************************/ /* msti configuration message structure */ @@ -106,7 +106,7 @@ typedef struct // mst instance remaining hops UINT8 msti_remaining_hops; -} __attribute__((aligned(4))) MSTI_CONFIG_MESSAGE; +} __attribute__((__packed__)) MSTI_CONFIG_MESSAGE; /*****************************************************************************/ /* mst configuration identification */ @@ -131,7 +131,7 @@ typedef struct // the mst configuration table. UINT8 config_digest[16]; -} __attribute__((aligned(4))) MSTP_CONFIG_IDENTIFIER; +} __attribute__((__packed__)) MSTP_CONFIG_IDENTIFIER; typedef struct RSTP_BPDU_FLAGS { @@ -152,7 +152,7 @@ typedef struct RSTP_BPDU_FLAGS UINT8 agreement:1; UINT8 topology_change_acknowledgement:1; #endif -} __attribute__((aligned(4))) RSTP_BPDU_FLAGS; +} __attribute__((__packed__)) RSTP_BPDU_FLAGS; /*****************************************************************************/ @@ -223,7 +223,7 @@ typedef struct // a sequence of zero or more msti configuration messages MSTI_CONFIG_MESSAGE msti_msgs[MSTP_MAX_INSTANCES_PER_REGION]; -} __attribute__((aligned(4))) MSTP_BPDU; +} __attribute__((__packed__)) MSTP_BPDU; // rstp bpdu typedef struct RSTP_BPDU @@ -243,6 +243,6 @@ typedef struct RSTP_BPDU UINT16 hello_time; UINT16 forward_delay; UINT8 version1_length; -} __attribute__((aligned(4))) RSTP_BPDU; +} __attribute__((__packed__)) RSTP_BPDU; -#endif // //__MSTP_COMMON_H__ \ No newline at end of file +#endif // //__MSTP_COMMON_H__ diff --git a/include/stp_common.h b/include/stp_common.h index 376e530..5a2d377 100755 --- a/include/stp_common.h +++ b/include/stp_common.h @@ -68,7 +68,7 @@ typedef struct BRIDGE_BPDU_FLAGS UINT8 blank : 6; UINT8 topology_change_acknowledgement : 1; #endif -} __attribute__((aligned(1))) BRIDGE_BPDU_FLAGS; +} __attribute__((__packed__)) BRIDGE_BPDU_FLAGS; typedef struct BRIDGE_IDENTIFIER { @@ -82,7 +82,7 @@ typedef struct BRIDGE_IDENTIFIER MAC_ADDRESS address; -} __attribute__((aligned(4))) BRIDGE_IDENTIFIER; +} __attribute__((__packed__)) BRIDGE_IDENTIFIER; typedef struct PORT_IDENTIFIER { @@ -93,7 +93,7 @@ typedef struct PORT_IDENTIFIER UINT16 number : 12; UINT16 priority : 4; #endif // BIG_ENDIAN -} __attribute__((aligned(2))) PORT_IDENTIFIER; +} __attribute__((__packed__)) PORT_IDENTIFIER; // spanning-tree configuration bpdu typedef struct STP_CONFIG_BPDU @@ -112,7 +112,7 @@ typedef struct STP_CONFIG_BPDU UINT16 max_age; UINT16 hello_time; UINT16 forward_delay; -} __attribute__((aligned(4))) STP_CONFIG_BPDU; +} __attribute__((__packed__)) STP_CONFIG_BPDU; // spanning-tree topology change notification bpdu typedef struct STP_TCN_BPDU @@ -123,7 +123,7 @@ typedef struct STP_TCN_BPDU UINT8 protocol_version_id; UINT8 type; UINT8 padding[3]; -} __attribute__((aligned(4))) STP_TCN_BPDU; +} __attribute__((__packed__)) STP_TCN_BPDU; // pvst configuration bpdu typedef struct PVST_CONFIG_BPDU @@ -145,7 +145,7 @@ typedef struct PVST_CONFIG_BPDU UINT8 padding[3]; UINT16 tag_length; UINT16 vlan_id; -} __attribute__((aligned(4))) PVST_CONFIG_BPDU; +} __attribute__((__packed__)) PVST_CONFIG_BPDU; // pvst topology change notification bpdu typedef struct PVST_TCN_BPDU @@ -156,6 +156,6 @@ typedef struct PVST_TCN_BPDU UINT8 protocol_version_id; UINT8 type; UINT8 padding[38]; -} __attribute__((aligned(4))) PVST_TCN_BPDU; +} __attribute__((__packed__)) PVST_TCN_BPDU; #endif //__STP_COMMON_H__ diff --git a/include/stp_ipc.h b/include/stp_ipc.h index c92e108..c535dfe 100644 --- a/include/stp_ipc.h +++ b/include/stp_ipc.h @@ -62,6 +62,12 @@ typedef enum STP_CTL_TYPE STP_CTL_MAX } STP_CTL_TYPE; +typedef enum LinkType { + AUTO = 0, // Auto + POINT_TO_POINT = 1, // Point-to-point + SHARED = 2 // Shared +} LinkType; + typedef struct STP_IPC_MSG { int msg_type; @@ -137,8 +143,8 @@ typedef struct STP_PORT_CONFIG_MSG uint8_t bpdu_guard_do_disable; uint8_t portfast; uint8_t uplink_fast; - int edge; - uint16_t padding; + uint8_t edge; + LinkType link_type; // MSTP only int path_cost; int priority; int count; diff --git a/stp/stp_mgr.c b/stp/stp_mgr.c index bf196ad..21f438a 100755 --- a/stp/stp_mgr.c +++ b/stp/stp_mgr.c @@ -1899,14 +1899,15 @@ static void stpmgr_process_ipc_msg(STP_IPC_MSG *msg, int len, struct sockaddr_un } case STP_BRIDGE_CONFIG: { - if(msg->proto_mode == L2_PVSTP) + stpmgr_process_bridge_config_msg(msg->data); + /*if(msg->proto_mode == L2_PVSTP) { stpmgr_process_bridge_config_msg(msg->data); } else if(msg->proto_mode == L2_MSTP) { mstpmgr_process_bridge_config_msg(msg->data); - } + }*/ break; } case STP_VLAN_CONFIG: @@ -1921,14 +1922,15 @@ static void stpmgr_process_ipc_msg(STP_IPC_MSG *msg, int len, struct sockaddr_un } case STP_PORT_CONFIG: { - if(msg->proto_mode == L2_PVSTP) + stpmgr_process_intf_config_msg(msg->data); + /*if(msg->proto_mode == L2_PVSTP) { stpmgr_process_intf_config_msg(msg->data); } else if(msg->proto_mode == L2_MSTP) { mstpmgr_process_intf_config_msg(msg->data); - } + }*/ break; } case STP_VLAN_MEM_CONFIG: