diff --git a/ipacm/inc/IPACM_Config.h b/ipacm/inc/IPACM_Config.h
index 0f58018..11f5f07 100644
--- a/ipacm/inc/IPACM_Config.h
+++ b/ipacm/inc/IPACM_Config.h
@@ -139,10 +139,7 @@
 	/* IPACM routing table name for v4/v6 */
 	struct ipa_ioc_get_rt_tbl rt_tbl_lan_v4, rt_tbl_wan_v4, rt_tbl_default_v4, rt_tbl_v6, rt_tbl_wan_v6;
 	struct ipa_ioc_get_rt_tbl rt_tbl_wan_dl;
-	struct ipa_ioc_get_rt_tbl rt_tbl_lan2lan_v4, rt_tbl_lan2lan_v6;
 	struct ipa_ioc_get_rt_tbl rt_tbl_odu_v4, rt_tbl_odu_v6;
-	struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v4, rt_tbl_eth_bridge_lan_wlan_v4, rt_tbl_eth_bridge_wlan_wlan_v4;
-	struct ipa_ioc_get_rt_tbl rt_tbl_eth_bridge_lan_lan_v6, rt_tbl_eth_bridge_lan_wlan_v6, rt_tbl_eth_bridge_wlan_wlan_v6;
 
 	bool isMCC_Mode;
 
diff --git a/ipacm/inc/IPACM_Defs.h b/ipacm/inc/IPACM_Defs.h
index ab11a47..a6e76d1 100644
--- a/ipacm/inc/IPACM_Defs.h
+++ b/ipacm/inc/IPACM_Defs.h
@@ -89,37 +89,16 @@
 #define WAN_DL_ROUTE_TABLE_NAME "ipa_dflt_wan_rt"
 #define V6_COMMON_ROUTE_TABLE_NAME  "COMRTBLv6"
 #define V6_WAN_ROUTE_TABLE_NAME  "WANRTBLv6"
-#define V4_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv4"
-#define V6_LAN_TO_LAN_ROUTE_TABLE_NAME "LANTOLANRTBLv6"
 #define V4_ODU_ROUTE_TABLE_NAME  "ODURTBLv4"
 #define V6_ODU_ROUTE_TABLE_NAME  "ODURTBLv6"
 
-#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_LAN_RTBLv4"
-#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_LAN_WLAN_RTBLv4"
-#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4 "ETH_BRIDGE_WLAN_WLAN_RTBLv4"
-#define ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_LAN_RTBLv6"
-#define ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_LAN_WLAN_RTBLv6"
-#define ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6 "ETH_BRIDGE_WLAN_WLAN_RTBLv6"
-
 #define WWAN_QMI_IOCTL_DEVICE_NAME "/dev/wwan_ioctl"
 #define IPA_DEVICE_NAME "/dev/ipa"
+#define MAX_NUM_PROP 2
 #define IPA_MAX_FLT_RULE 50
-
-#define MAX_OFFLOAD_PAIR 3
-#define MAX_NUM_PROP 8
-#define IPA_LAN_TO_LAN_USB_HDR_NAME_V4 "Lan2Lan_USB_v4"
-#define IPA_LAN_TO_LAN_USB_HDR_NAME_V6 "Lan2Lan_USB_v6"
-#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4 "Lan2Lan_Wlan_v4"
-#define IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6 "Lan2Lan_Wlan_v6"
-#define IPA_LAN_TO_LAN_MAX_WLAN_CLIENT 16
-#define IPA_LAN_TO_LAN_MAX_USB_CLIENT 1
-#define IPA_LAN_TO_LAN_MAX_CPE_CLIENT 15
-#define IPA_LAN_TO_LAN_MAX_LAN_CLIENT (IPA_LAN_TO_LAN_MAX_USB_CLIENT + IPA_LAN_TO_LAN_MAX_CPE_CLIENT)
-#define IPA_LAN_TO_LAN_MAX_CLIENT (IPA_LAN_TO_LAN_MAX_LAN_CLIENT + IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
 #define TCP_FIN_SHIFT 16
 #define TCP_SYN_SHIFT 17
 #define TCP_RST_SHIFT 18
-#define NUM_TCP_CTL_FLT_RULE 3
 #define NUM_IPV6_PREFIX_FLT_RULE 1
 
 /*---------------------------------------------------------------------------
@@ -143,7 +122,7 @@
 ===========================================================================*/
 typedef enum
 {
-	IPA_CFG_CHANGE_EVENT = 1,                 /* NULL */
+	IPA_CFG_CHANGE_EVENT,                 /* NULL */
 	IPA_PRIVATE_SUBNET_CHANGE_EVENT,          /* ipacm_event_data_fid */
 	IPA_FIREWALL_CHANGE_EVENT,                /* NULL */
 	IPA_LINK_UP_EVENT,                        /* ipacm_event_data_fid */
@@ -182,7 +161,7 @@
 	IPA_TETHERING_STATS_UPDATE_EVENT,         /* ipacm_event_data_fid */
 	IPA_NETWORK_STATS_UPDATE_EVENT,           /* ipacm_event_data_fid */
 
-	IPA_EXTERNAL_EVENT_MAX = 500,
+	IPA_EXTERNAL_EVENT_MAX,
 
 	IPA_HANDLE_WAN_UP,                        /* ipacm_event_iface_up  */
 	IPA_HANDLE_WAN_DOWN,                      /* ipacm_event_iface_up  */
@@ -194,16 +173,12 @@
 	IPA_HANDLE_WAN_DOWN_V6_TETHER,            /* ipacm_event_iface_up_tehter */
 	IPA_HANDLE_WLAN_UP,                       /* ipacm_event_iface_up */
 	IPA_HANDLE_LAN_UP,                        /* ipacm_event_iface_up */
-	IPA_LAN_CLIENT_ACTIVE,                    /* ipacm_event_lan_client*/
-	IPA_LAN_CLIENT_INACTIVE,                  /* ipacm_event_lan_client*/
-	IPA_LAN_CLIENT_DISCONNECT,                /* ipacm_event_lan_client*/
-	IPA_LAN_CLIENT_POWER_SAVE,                /* ipacm_event_lan_client*/
-	IPA_LAN_CLIENT_POWER_RECOVER,             /* ipacm_event_lan_client*/
+	IPA_ETH_BRIDGE_IFACE_UP,                  /* ipacm_event_eth_bridge*/
+	IPA_ETH_BRIDGE_IFACE_DOWN,                /* ipacm_event_eth_bridge*/
+	IPA_ETH_BRIDGE_CLIENT_ADD,                /* ipacm_event_eth_bridge */
+	IPA_ETH_BRIDGE_CLIENT_DEL,                /* ipacm_event_eth_bridge*/
+	IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH,       /* ipacm_event_eth_bridge*/
 	IPA_LAN_DELETE_SELF,                      /* ipacm_event_data_fid */
-	IPA_ETH_BRIDGE_CLIENT_ADD_EVENT,          /* ipacm_event_data_mac */
-	IPA_ETH_BRIDGE_CLIENT_DEL_EVENT,          /* ipacm_event_data_mac */
-	IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT,    /* ipacm_event_data_if_cat */
-	IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT,  /* ipacm_event_data_if_cat */
 	IPACM_EVENT_MAX
 } ipa_cm_event_id;
 
@@ -277,12 +252,10 @@
 
 typedef struct
 {
-	enum ipa_ip_type iptype;
-	uint32_t ipv4_addr;
-	uint32_t ipv6_addr[4];
+	IPACM_Lan *p_iface;
+	ipa_ip_type iptype;
 	uint8_t mac_addr[6];
-	IPACM_Lan* p_iface;
-} ipacm_event_lan_client;
+} ipacm_event_eth_bridge;
 
 typedef struct
 {
diff --git a/ipacm/inc/IPACM_Lan.h b/ipacm/inc/IPACM_Lan.h
index 7a93b12..0076a01 100644
--- a/ipacm/inc/IPACM_Lan.h
+++ b/ipacm/inc/IPACM_Lan.h
@@ -73,18 +73,6 @@
 	uint32_t rt_rule_hdl[0];
 };
 
-typedef enum
-{
-	SRC_WLAN,
-	SRC_LAN
-} eth_bridge_src_iface;
-
-typedef enum
-{
-	DST_WLAN,
-	DST_LAN
-} eth_bridge_dst_iface;
-
 /* Support multiple eth client */
 typedef struct _eth_client_rt_hdl
 {
@@ -109,45 +97,6 @@
 	eth_client_rt_hdl eth_rt_hdl[0]; /* depends on number of tx properties */
 }ipa_eth_client;
 
-struct lan2lan_flt_rule_hdl
-{
-	uint32_t rule_hdl;
-	bool valid;
-};
-
-struct lan2lan_hdr_hdl
-{
-	uint32_t hdr_hdl;
-	bool valid;
-};
-
-struct eth_bridge_subnet_client_flt_info
-{
-	uint8_t mac[IPA_MAC_ADDR_SIZE];
-	uint32_t flt_rule_hdl_v4;
-	bool flt_rule_set_v4;
-	uint32_t flt_rule_hdl_v6;
-	bool flt_rule_set_v6;
-};
-
-struct eth_bridge_client_rt_info
-{
-	uint8_t mac[IPA_MAC_ADDR_SIZE];
-	uint32_t rt_rule_hdl[0];
-};
-
-struct hdr_proc_ctx_info
-{
-	uint32_t proc_ctx_hdl;
-	bool valid;
-};
-
-struct eth_bridge_subnet_client_info
-{
-	uint8_t mac[IPA_MAC_ADDR_SIZE];
-	int ipa_if_num;
-	int ipa_if_cate;
-};
 
 /* lan iface */
 class IPACM_Lan : public IPACM_Iface
@@ -192,109 +141,53 @@
 	/* install UL filter rule from Q6 */
 	virtual int handle_uplink_filter_rule(ipacm_ext_prop* prop, ipa_ip_type iptype, uint8_t xlat_mux_id);
 
-	int add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl);
-
-	int del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
-
-	virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);
-
-	int add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr,
-								uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl);
-
-	int del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl);
-
-	int del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl);
-
 	int handle_cradle_wan_mode_switch(bool is_wan_bridge_mode);
 
 	int install_ipv4_icmp_flt_rule();
 
-	static ipa_hdr_l2_type lan_hdr_type;
-	static ipa_hdr_l2_type wlan_hdr_type;
 
-	static uint32_t usb_hdr_template_hdl;
-	static uint32_t wlan_hdr_template_hdl;
-	static uint32_t cpe_hdr_template_hdl;
+	/* add header processing context and return handle to lan2lan controller */
+	int eth_bridge_add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_hdr_type, uint32_t *hdl);
 
-	static hdr_proc_ctx_info lan_to_wlan_hdr_proc_ctx, wlan_to_usb_hdr_proc_ctx, wlan_to_cpe_hdr_proc_ctx;
-	static hdr_proc_ctx_info wlan_to_wlan_hdr_proc_ctx;
-	static hdr_proc_ctx_info cpe_to_usb_hdr_proc_ctx, usb_to_cpe_hdr_proc_ctx;
+	/* add routing rule and return handle to lan2lan controller */
+	int eth_bridge_add_rt_rule(uint8_t *mac, char *rt_tbl_name, uint32_t hdr_proc_ctx_hdl,
+		ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int *rt_rule_count);
 
-	static eth_bridge_subnet_client_info eth_bridge_client[IPA_LAN_TO_LAN_MAX_CLIENT];
+	/* modify routing rule*/
+	int eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl,
+		ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int rt_rule_count);
 
-	static int eth_bridge_num_client;
+	/* add filtering rule and return handle to lan2lan controller */
+	int eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl);
 
-	static bool is_usb_up;
-	static bool is_cpe_up;
+	/* delete filtering rule */
+	int eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype);
+
+	/* delete routing rule */
+	int eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype);
+
+	/* delete header processing context */
+	int eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl);
+
+
 
 protected:
 
-	eth_bridge_subnet_client_flt_info eth_bridge_client_flt_info[IPA_LAN_TO_LAN_MAX_CLIENT];
+	int each_client_rt_rule_count[IPA_IP_MAX];
 
-	int client_flt_info_count;
+	uint32_t eth_bridge_flt_rule_offset[IPA_IP_MAX];
 
-	int client_rt_info_size_v4;
-	int client_rt_info_size_v6;
-
-	eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v4;
-	int lan_client_rt_from_lan_info_count_v4;
-	eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_lan_info_v6;
-	int lan_client_rt_from_lan_info_count_v6;
-	eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v4;
-	int lan_client_rt_from_wlan_info_count_v4;
-	eth_bridge_client_rt_info* eth_bridge_lan_client_rt_from_wlan_info_v6;
-	int lan_client_rt_from_wlan_info_count_v6;
-
-	int each_client_rt_rule_count_v4;
-	int each_client_rt_rule_count_v6;
-
-	int eth_bridge_add_client_flt_rule(uint8_t* mac, ipa_ip_type iptype, int dest_if_cate);
-
-	int eth_bridge_del_client_flt_rule(uint8_t* mac);
-
-	int eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt);
-
-	int add_hdr_proc_ctx();
-
-	int del_hdr_proc_ctx();
-
-	ipa_hdr_proc_type get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2);
-
-	virtual int eth_bridge_install_cache_client_flt_rule(ipa_ip_type iptype);
-
-	int eth_bridge_add_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype);
-
-	int eth_bridge_del_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src);
-
-	eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype);
-
-	void eth_bridge_add_client(uint8_t* mac);
-
-	void eth_bridge_del_client(uint8_t* mac);
-
-	int eth_bridge_remove_all_client_flt_rule(ipa_ip_type iptype);
-
-	int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl);
-
-	bool eth_bridge_is_lan_client(int ipa_if_cate);
-
-	enum ipa_hdr_l2_type eth_bridge_get_l2_hdr_type();
-
-	void eth_bridge_get_rt_tbl_name(ipa_ip_type iptype, struct ipa_ioc_get_rt_tbl *rt_tbl, int dest_if_cate);
+	/* mac address has to be provided for client related events */
+	void eth_bridge_post_event(ipa_cm_event_id evt, ipa_ip_type iptype, uint8_t *mac);
 
 
 
-	virtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);
-
 	virtual int add_dummy_private_subnet_flt_rule(ipa_ip_type iptype);
 
 	int handle_private_subnet_android(ipa_ip_type iptype);
 
 	int reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
 
-	/*handle lan2lan client active*/
-	int handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event);
-
 	virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix);
 
 	virtual void delete_ipv6_prefix_flt_rule();
@@ -309,26 +202,13 @@
 	/* handle tethering client */
 	int handle_tethering_client(bool reset, ipacm_client_enum ipa_client);
 
-	lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v4[MAX_OFFLOAD_PAIR];
-	lan2lan_flt_rule_hdl lan2lan_flt_rule_hdl_v6[MAX_OFFLOAD_PAIR];
-
-	uint8_t num_lan2lan_flt_rule_v4;
-	uint8_t num_lan2lan_flt_rule_v6;
-
-	lan2lan_hdr_hdl lan2lan_hdr_hdl_v4[MAX_OFFLOAD_PAIR];
-	lan2lan_hdr_hdl lan2lan_hdr_hdl_v6[MAX_OFFLOAD_PAIR];
-
 	/* store ipv4 UL filter rule handlers from Q6*/
 	uint32_t wan_ul_fl_rule_hdl_v4[MAX_WAN_UL_FILTER_RULES];
 
 	/* store ipv6 UL filter rule handlers from Q6*/
 	uint32_t wan_ul_fl_rule_hdl_v6[MAX_WAN_UL_FILTER_RULES];
 
-	virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);
-
 	uint32_t ipv4_icmp_flt_rule_hdl[NUM_IPV4_ICMP_FLT_RULE];
-	uint32_t tcp_ctl_flt_rule_hdl_v4[NUM_TCP_CTL_FLT_RULE];
-	uint32_t tcp_ctl_flt_rule_hdl_v6[NUM_TCP_CTL_FLT_RULE];
 
 	uint32_t ipv6_prefix_flt_rule_hdl[NUM_IPV6_PREFIX_FLT_RULE];
 	uint32_t ipv6_icmp_flt_rule_hdl[NUM_IPV6_ICMP_FLT_RULE];
@@ -342,11 +222,15 @@
 
 	uint32_t if_ipv4_subnet;
 
-	uint32_t eth_bridge_flt_rule_offset_v4;
-	uint32_t eth_bridge_flt_rule_offset_v6;
-
 private:
 
+	/* get hdr proc ctx type given source and destination l2 hdr type */
+	ipa_hdr_proc_type eth_bridge_get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2);
+
+	/* get partial header (header template of hdr proc ctx) */
+	int eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl);
+
+
 	/* dynamically allocate lan iface's unicast routing rule structure */
 
 	bool is_mode_switch; /* indicate mode switch, need post internal up event */
@@ -497,9 +381,6 @@
 	/*handle lan iface down event*/
 	int handle_down_evt();
 
-	/*handle lan2lan internal mesg posting*/
-	int post_lan2lan_client_disconnect_msg(ipa_ip_type iptype);
-
 	/*handle reset usb-client rt-rules */
 	int handle_lan_client_reset_rt(ipa_ip_type iptype);
 };
diff --git a/ipacm/inc/IPACM_LanToLan.h b/ipacm/inc/IPACM_LanToLan.h
index 06d5832..a28631e 100644
--- a/ipacm/inc/IPACM_LanToLan.h
+++ b/ipacm/inc/IPACM_LanToLan.h
@@ -42,7 +42,6 @@
 #include "IPACM_Iface.h"
 #include "IPACM_Defs.h"
 #include "IPACM_Lan.h"
-#include <unordered_map>
 
 #ifdef FEATURE_IPA_ANDROID
 #include <libxml/list.h>
@@ -50,125 +49,153 @@
 #include <list>
 #endif /* ndefined(FEATURE_IPA_ANDROID)*/
 
-struct client_info;
+#define MAX_NUM_CACHED_CLIENT_ADD_EVENT 10
+#define MAX_NUM_IFACE 10
+#define MAX_NUM_CLIENT 16
 
-struct peer_info
+struct rt_rule_info
 {
-	struct client_info* peer_pointer;
-	int num_connection;
+	int num_hdl[IPA_IP_MAX];	/* one client may need more than one routing rules on the same routing table depending on tx_prop */
+	uint32_t  rule_hdl[IPA_IP_MAX][MAX_NUM_PROP];
 };
 
-//used to store rule handles for offload link (one direction)
-struct offload_link_info
-{
-	struct client_info* peer_pointer;
-	uint32_t flt_rule_hdl;
-	lan_to_lan_rt_rule_hdl rt_rule_hdl;
-	uint32_t hdr_hdl;
-};
-
-typedef list<peer_info> peer_info_list;
-typedef list<offload_link_info> offload_link_info_list;
-typedef list<ipacm_event_connection> connection_list;
-
 struct client_info
 {
-	union
-	{
-		uint32_t ipv4_addr;
-		uint32_t ipv6_addr[4];
-	} ip;
 	uint8_t mac_addr[6];
-	bool is_active;
-	bool is_powersave;
-	IPACM_Lan* p_iface;
-	peer_info_list peer;
-	offload_link_info_list link;
+	rt_rule_info inter_iface_rt_rule_hdl[IPA_HDR_L2_MAX];	/* routing rule handles of inter interface communication based on source l2 header type */
+	rt_rule_info intra_iface_rt_rule_hdl;	/* routing rule handles of inter interface communication */
 };
 
-struct v6_addr
+struct flt_rule_info
 {
-	uint32_t ipv6_addr[4];
+	client_info *p_client;
+	uint32_t flt_rule_hdl[IPA_IP_MAX];
 };
 
-typedef unordered_map<uint32_t, client_info> client_table_v4;
-typedef unordered_map<uint64_t, client_info> client_table_v6;
+struct peer_iface_info
+{
+	class IPACM_LanToLan_Iface *peer;
+	char rt_tbl_name_for_rt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
+	char rt_tbl_name_for_flt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
+	list<flt_rule_info> flt_rule;
+};
 
+class IPACM_LanToLan_Iface
+{
+public:
+	IPACM_LanToLan_Iface(IPACM_Lan *p_iface);
+	~IPACM_LanToLan_Iface();
+
+	void add_client_rt_rule_for_new_iface();
+
+	void add_all_inter_interface_client_flt_rule(ipa_ip_type iptype);
+
+	void add_all_intra_interface_client_flt_rule(ipa_ip_type iptype);
+
+	void handle_down_event();
+
+	void handle_wlan_scc_mcc_switch();
+
+	void handle_intra_interface_info();
+
+	void handle_new_iface_up(char rt_tbl_name_for_flt[][IPA_RESOURCE_NAME_MAX], char rt_tbl_name_for_rt[][IPA_RESOURCE_NAME_MAX],
+		IPACM_LanToLan_Iface *peer_iface);
+
+	void handle_client_add(uint8_t *mac);
+
+	void handle_client_del(uint8_t *mac);
+
+	void print_data_structure_info();
+
+	IPACM_Lan* get_iface_pointer();
+
+	bool get_m_is_ip_addr_assigned(ipa_ip_type iptype);
+
+	void set_m_is_ip_addr_assigned(ipa_ip_type iptype, bool value);
+
+	bool get_m_support_inter_iface_offload();
+
+	bool get_m_support_intra_iface_offload();
+
+	void increment_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type);
+
+	void decrement_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type);
+
+private:
+
+	IPACM_Lan *m_p_iface;
+	bool m_is_ip_addr_assigned[IPA_IP_MAX];
+	bool m_support_inter_iface_offload;
+	bool m_support_intra_iface_offload;
+
+	int ref_cnt_peer_l2_hdr_type[IPA_HDR_L2_MAX];	/* reference count of l2 header type of peer interfaces */
+	uint32_t hdr_proc_ctx_for_inter_interface[IPA_HDR_L2_MAX];
+	uint32_t hdr_proc_ctx_for_intra_interface;
+
+	list<client_info> m_client_info;	/* client list */
+	list<peer_iface_info> m_peer_iface_info;	/* peer information list */
+
+	/* The following members are for intra-interface communication*/
+	peer_iface_info m_intra_interface_info;
+
+	void add_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client);
+
+	void add_client_flt_rule(peer_iface_info *peer, client_info *client, ipa_ip_type iptype);
+
+	void del_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client);
+
+	void del_client_flt_rule(peer_iface_info *peer, client_info *client);
+
+	void add_client_rt_rule(peer_iface_info *peer, client_info *client);
+
+	void del_client_rt_rule(peer_iface_info *peer, client_info *client);
+
+	void clear_all_flt_rule_for_one_peer_iface(peer_iface_info *peer);
+
+	void clear_all_rt_rule_for_one_peer_iface(peer_iface_info *peer);
+
+	void add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type);
+
+	void del_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type);
+
+	void print_peer_info(peer_iface_info *peer_info);
+
+};
 
 class IPACM_LanToLan : public IPACM_Listener
 {
 
 public:
 
-		IPACM_LanToLan();
-		~IPACM_LanToLan();
-
-		void handle_new_connection(ipacm_event_connection* new_conn);
-		void handle_del_connection(ipacm_event_connection* del_conn);
-
-		static IPACM_LanToLan* getLan2LanInstance();
+	IPACM_LanToLan();
 
 private:
 
-		uint8_t num_offload_pair_v4_;
-		uint8_t num_offload_pair_v6_;
-		client_table_v4 client_info_v4_;
-		client_table_v6 client_info_v6_;
+	~IPACM_LanToLan();
 
-		connection_list connection_v4_;
-		connection_list connection_v6_;
+	list<class IPACM_LanToLan_Iface> m_iface;
 
-		static IPACM_LanToLan* p_instance;
+	list<ipacm_event_eth_bridge> m_cached_client_add_event;
 
-		void event_callback(ipa_cm_event_id event, void* param);
+	void handle_iface_up(ipacm_event_eth_bridge *data);
 
-		void handle_client_active(ipacm_event_lan_client* data);
+	void handle_iface_down(ipacm_event_eth_bridge *data);
 
-		void check_potential_link(ipa_ip_type iptype, client_info* client);
+	void handle_client_add(ipacm_event_eth_bridge *data);
 
-		int add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer);
+	void handle_client_del(ipacm_event_eth_bridge *data);
 
-		void handle_client_inactive(ipacm_event_lan_client* data);
+	void handle_wlan_scc_mcc_switch(ipacm_event_eth_bridge *data);
 
-		int turnoff_offload_links(ipa_ip_type iptype, client_info* client);
+	void handle_new_iface_up(IPACM_LanToLan_Iface *new_iface, IPACM_LanToLan_Iface *exist_iface);
 
-		int del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link);
+	void event_callback(ipa_cm_event_id event, void* param);
 
-		void handle_client_disconnect(ipacm_event_lan_client* data);
+	void handle_cached_client_add_event(IPACM_Lan *p_iface);
 
-		int clear_peer_list(client_info* client);
+	void clear_cached_client_add_event(IPACM_Lan *p_iface);
 
-		void handle_client_power_save(ipacm_event_lan_client* data);
-
-		void handle_client_power_recover(ipacm_event_lan_client* data);
-
-		int remove_flt_rules(ipa_ip_type iptype, client_info* client);
-
-		int add_flt_rules(ipa_ip_type iptype, client_info* client);
-
-//the following are for connections
-
-		void handle_new_lan2lan_connection(ipacm_event_connection* data);
-
-		bool add_connection(client_info* src_client, client_info* dst_client);
-
-		void handle_del_lan2lan_connection(ipacm_event_connection* data);
-
-		bool remove_connection(client_info* src_client, client_info* dst_client);
-
-		void erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client);
-
-		void generate_new_connection(ipa_ip_type iptype, client_info* client);
-
-		bool is_lan2lan_connection(ipacm_event_connection* data);
-
-		bool is_potential_lan2lan_connection(ipacm_event_connection* new_conn);
-
-		void cache_new_connection(ipacm_event_connection* new_conn);
-
-		void remove_cache_connection(ipacm_event_connection* del_conn);
-
-		void check_cache_connection(ipa_ip_type iptype, client_info* client);
+	void print_data_structure_info();
 
 };
 
diff --git a/ipacm/inc/IPACM_Log.h b/ipacm/inc/IPACM_Log.h
index 8fce44e..dab0280 100644
--- a/ipacm/inc/IPACM_Log.h
+++ b/ipacm/inc/IPACM_Log.h
@@ -1,4 +1,4 @@
-/* 
+/*
 Copyright (c) 2013, The Linux Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -68,7 +68,9 @@
 static char dmesg_cmd[MAX_BUF_LEN];
 
 #define IPACMDBG_DMESG(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
-							     snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s: " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+								 snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s: " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+								 ipacm_log_send (buffer_send);\
+								 printf("%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__); \
 								 memset(dmesg_cmd, 0, MAX_BUF_LEN);\
 								 snprintf(dmesg_cmd, MAX_BUF_LEN, "echo %s > /dev/kmsg", buffer_send);\
 								 system(dmesg_cmd);
@@ -78,9 +80,9 @@
 					  ipacm_log_send (buffer_send); \
                       perror(fmt);
 #define IPACMERR(fmt, ...)	memset(buffer_send, 0, MAX_BUF_LEN);\
-							snprintf(buffer_send,MAX_BUF_LEN,"ERR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+							snprintf(buffer_send,MAX_BUF_LEN,"ERROR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
 							ipacm_log_send (buffer_send);\
-							printf("ERR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
+							printf("ERROR: %s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);
 #define IPACMDBG_H(fmt, ...) memset(buffer_send, 0, MAX_BUF_LEN);\
 							 snprintf(buffer_send,MAX_BUF_LEN,"%s:%d %s() " fmt, __FILE__,  __LINE__, __FUNCTION__, ##__VA_ARGS__);\
 							 ipacm_log_send (buffer_send);\
diff --git a/ipacm/inc/IPACM_Wlan.h b/ipacm/inc/IPACM_Wlan.h
index c1fce13..eb911ac 100644
--- a/ipacm/inc/IPACM_Wlan.h
+++ b/ipacm/inc/IPACM_Wlan.h
@@ -85,38 +85,15 @@
 
 	static int total_num_wifi_clients;
 
-	void event_callback(ipa_cm_event_id event,
-											void *data);
+	void event_callback(ipa_cm_event_id event, void *data);
 
-	virtual int add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl);
+	bool is_guest_ap();
 
 private:
 
-	bool is_guest_ap;
+	bool m_is_guest_ap;
 
-	eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v4;
-	int wlan_client_rt_from_lan_info_count_v4;
-	eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_lan_info_v6;
-	int wlan_client_rt_from_lan_info_count_v6;
-
-	eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v4;
-	int wlan_client_rt_from_wlan_info_count_v4;
-	eth_bridge_client_rt_info* eth_bridge_wlan_client_rt_from_wlan_info_v6;
-	int wlan_client_rt_from_wlan_info_count_v6;
-
-	virtual int eth_bridge_install_cache_client_flt_rule(ipa_ip_type iptype);
-
-	int eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype);
-
-	int eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src);
-
-	eth_bridge_client_rt_info* eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype);
-
-	void eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype);
-
-	int eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptyp);
-
-	/*handle wlan access mode switch */
+	/* handle wlan access mode switch in ethernet bridging*/
 	void eth_bridge_handle_wlan_mode_switch();
 
 
@@ -128,9 +105,6 @@
 
 	int wlan_ap_index;
 
-	static uint32_t* dummy_flt_rule_hdl_v4;
-	static uint32_t* dummy_flt_rule_hdl_v6;
-
 	static int num_wlan_ap_iface;
 
 	NatApp *Nat_App;
@@ -240,9 +214,6 @@
 	/* for handle wifi client initial,copy all partial headers (tx property) */
 	int handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data);
 
-	/*handle lan2lan internal mesg posting*/
-	int handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event, ipa_ip_type iptype);
-
 	/*handle wifi client */
 	int handle_wlan_client_ipaddr(ipacm_event_data_all *data);
 
@@ -258,11 +229,6 @@
 	/*handle wlan iface down event*/
 	int handle_down_evt();
 
-	virtual int add_dummy_lan2lan_flt_rule(ipa_ip_type iptype);
-
-	/* install TCP control filter rules */
-	virtual void install_tcp_ctl_flt_rule(ipa_ip_type iptype);
-
 	/*handle reset wifi-client rt-rules */
 	int handle_wlan_client_reset_rt(ipa_ip_type iptype);
 
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index 5371202..a84f64c 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -99,16 +99,12 @@
 	__stringify(IPA_HANDLE_WAN_DOWN_V6_TETHER),            /* ipacm_event_iface_up_tehter */
 	__stringify(IPA_HANDLE_WLAN_UP),                       /* ipacm_event_iface_up */
 	__stringify(IPA_HANDLE_LAN_UP),                        /* ipacm_event_iface_up */
-	__stringify(IPA_LAN_CLIENT_ACTIVE),                    /* ipacm_event_lan_client*/
-	__stringify(IPA_LAN_CLIENT_INACTIVE),                  /* ipacm_event_lan_client*/
-	__stringify(IPA_LAN_CLIENT_DISCONNECT),                /* ipacm_event_lan_client*/
-	__stringify(IPA_LAN_CLIENT_POWER_SAVE),                /* ipacm_event_lan_client*/
-	__stringify(IPA_LAN_CLIENT_POWER_RECOVER),             /* ipacm_event_lan_client*/
+	__stringify(IPA_ETH_BRIDGE_IFACE_UP),                  /* ipacm_event_eth_bridge*/
+	__stringify(IPA_ETH_BRIDGE_IFACE_DOWN),                /* ipacm_event_eth_bridge*/
+	__stringify(IPA_ETH_BRIDGE_CLIENT_ADD),                /* ipacm_event_eth_bridge*/
+	__stringify(IPA_ETH_BRIDGE_CLIENT_DEL),                /* ipacm_event_eth_bridge*/
+	__stringify(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH),       /* ipacm_event_eth_bridge*/
 	__stringify(IPA_LAN_DELETE_SELF),                      /* ipacm_event_data_fid */
-	__stringify(IPA_ETH_BRIDGE_CLIENT_ADD_EVENT),          /* ipacm_event_data_mac */
-	__stringify(IPA_ETH_BRIDGE_CLIENT_DEL_EVENT),          /* ipacm_event_data_mac */
-	__stringify(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT),    /* ipacm_event_data_if_cat */
-	__stringify(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT),  /* ipacm_event_data_if_cat */
 	__stringify(IPACM_EVENT_MAX),
 };
 
@@ -145,11 +141,6 @@
 	memset(&ext_prop_v4, 0, sizeof(ext_prop_v4));
 	memset(&ext_prop_v6, 0, sizeof(ext_prop_v6));
 
-	memset(&rt_tbl_eth_bridge_lan_wlan_v4, 0, sizeof(rt_tbl_eth_bridge_lan_wlan_v4));
-	memset(&rt_tbl_eth_bridge_wlan_wlan_v4, 0, sizeof(rt_tbl_eth_bridge_wlan_wlan_v4));
-	memset(&rt_tbl_eth_bridge_lan_wlan_v6, 0, sizeof(rt_tbl_eth_bridge_lan_wlan_v6));
-	memset(&rt_tbl_eth_bridge_wlan_wlan_v6, 0, sizeof(rt_tbl_eth_bridge_wlan_wlan_v6));
-
 	qmap_id = ~0;
 
 	memset(flt_rule_count_v4, 0, (IPA_CLIENT_CONS - IPA_CLIENT_PROD)*sizeof(int));
@@ -341,30 +332,6 @@
 	rt_tbl_wan_dl.ip = IPA_IP_MAX;
 	strncpy(rt_tbl_wan_dl.name, WAN_DL_ROUTE_TABLE_NAME, sizeof(rt_tbl_wan_dl.name));
 
-	rt_tbl_lan2lan_v4.ip = IPA_IP_v4;
-	strncpy(rt_tbl_lan2lan_v4.name, V4_LAN_TO_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan2lan_v4.name));
-
-	rt_tbl_lan2lan_v6.ip = IPA_IP_v6;
-	strncpy(rt_tbl_lan2lan_v6.name, V6_LAN_TO_LAN_ROUTE_TABLE_NAME, sizeof(rt_tbl_lan2lan_v6.name));
-
-	rt_tbl_eth_bridge_lan_lan_v4.ip = IPA_IP_v4;
-	strncpy(rt_tbl_eth_bridge_lan_lan_v4.name, ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V4, sizeof(rt_tbl_eth_bridge_lan_lan_v4.name));
-
-	rt_tbl_eth_bridge_lan_wlan_v4.ip = IPA_IP_v4;
-	strncpy(rt_tbl_eth_bridge_lan_wlan_v4.name, ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V4, sizeof(rt_tbl_eth_bridge_lan_wlan_v4.name));
-
-	rt_tbl_eth_bridge_wlan_wlan_v4.ip = IPA_IP_v4;
-	strncpy(rt_tbl_eth_bridge_wlan_wlan_v4.name, ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V4, sizeof(rt_tbl_eth_bridge_wlan_wlan_v4.name));
-
-	rt_tbl_eth_bridge_lan_lan_v6.ip = IPA_IP_v6;
-	strncpy(rt_tbl_eth_bridge_lan_lan_v6.name, ETH_BRIDGE_USB_CPE_ROUTE_TABLE_NAME_V6, sizeof(rt_tbl_eth_bridge_lan_lan_v6.name));
-
-	rt_tbl_eth_bridge_lan_wlan_v6.ip = IPA_IP_v6;
-	strncpy(rt_tbl_eth_bridge_lan_wlan_v6.name, ETH_BRIDGE_USB_WLAN_ROUTE_TABLE_NAME_V6, sizeof(rt_tbl_eth_bridge_lan_wlan_v6.name));
-
-	rt_tbl_eth_bridge_wlan_wlan_v6.ip = IPA_IP_v6;
-	strncpy(rt_tbl_eth_bridge_wlan_wlan_v6.name, ETH_BRIDGE_WLAN_WLAN_ROUTE_TABLE_NAME_V6, sizeof(rt_tbl_eth_bridge_wlan_wlan_v6.name));
-
 	/* Construct IPACM ipa_client map to rm_resource table */
 	ipa_client_rm_map_tbl[IPA_CLIENT_WLAN1_PROD]= IPA_RM_RESOURCE_WLAN_PROD;
 	ipa_client_rm_map_tbl[IPA_CLIENT_USB_PROD]= IPA_RM_RESOURCE_USB_PROD;
@@ -844,7 +811,7 @@
 {
 	if(event_id >= sizeof(ipacm_event_name)/sizeof(ipacm_event_name[0]))
 	{
-		IPACMDBG_DMESG("ERROR: Event name array is not consistent with event array!\n");
+		IPACMERR("Event name array is not consistent with event array!\n");
 		return NULL;
 	}
 
diff --git a/ipacm/src/IPACM_Header.cpp b/ipacm/src/IPACM_Header.cpp
index 5e56a49..c77c69c 100644
--- a/ipacm/src/IPACM_Header.cpp
+++ b/ipacm/src/IPACM_Header.cpp
@@ -1,4 +1,4 @@
-/* 
+/*
 Copyright (c) 2013, The Linux Foundation. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -203,7 +203,7 @@
 	int ret = 0;
 	//call the Driver ioctl to add header processing context
 	ret = ioctl(m_fd, IPA_IOC_ADD_HDR_PROC_CTX, pHeader);
-	return (ret != -1);
+	return (ret == 0);
 }
 
 bool IPACM_Header::DeleteHeaderProcCtx(uint32_t hdl)
@@ -225,7 +225,12 @@
 	pHeaderTable->hdl[0].hdl = hdl;
 
 	ret = ioctl(m_fd, IPA_IOC_DEL_HDR_PROC_CTX, pHeaderTable);
+	if(ret != 0)
+	{
+		IPACMERR("Failed to delete hdr proc ctx: return value %d, status %d\n",
+			ret, pHeaderTable->hdl[0].status);
+	}
 	free(pHeaderTable);
-	return (ret != -1);
+	return (ret == 0);
 }
 
diff --git a/ipacm/src/IPACM_IfaceManager.cpp b/ipacm/src/IPACM_IfaceManager.cpp
index 259532d..d6ad9a5 100644
--- a/ipacm/src/IPACM_IfaceManager.cpp
+++ b/ipacm/src/IPACM_IfaceManager.cpp
@@ -245,12 +245,6 @@
 #endif
 				IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, lan); 				// register for IPA_CFG_CHANGE event
 				IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, lan); 	// register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
-#ifdef FEATURE_ETH_BRIDGE_LE
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_ADD_EVENT, lan);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_DEL_EVENT, lan);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, lan);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, lan);
-#endif
 #ifdef FEATURE_IPA_ANDROID
 				IPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, lan);
 #endif
@@ -301,12 +295,6 @@
 					IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_UP_V6, odu);
 					IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN, odu);
 					IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, odu);
-#ifdef FEATURE_ETH_BRIDGE_LE
-					IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_ADD_EVENT, odu);
-					IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_DEL_EVENT, odu);
-					IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, odu);
-					IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, odu);
-#endif
 					IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, odu);
 					IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, odu);
 					IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, odu);
@@ -360,10 +348,6 @@
 #endif
 				IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); 	// register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event
 #ifdef FEATURE_ETH_BRIDGE_LE
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_ADD_EVENT, wl);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_DEL_EVENT, wl);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT, wl);
-				IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT, wl);
 				IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, wl);
 #endif
 				IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, wl);
@@ -417,7 +401,7 @@
 					if(is_sta_mode == WLAN_WAN)
 					{
 						IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, w); // for STA mode
-#ifndef FEATURE_IPA_ANDROI
+#ifndef FEATURE_IPA_ANDROID
 						IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_SCC, w);
 						IPACM_EvtDispatcher::registr(IPA_WLAN_SWITCH_TO_MCC, w);
 #endif
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index d5a98d2..6085aca 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -55,26 +55,6 @@
 
 bool IPACM_Lan::odu_up = false;
 
-ipa_hdr_l2_type IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
-ipa_hdr_l2_type IPACM_Lan::wlan_hdr_type = IPA_HDR_L2_NONE;
-
-uint32_t IPACM_Lan::usb_hdr_template_hdl = 0;
-uint32_t IPACM_Lan::wlan_hdr_template_hdl = 0;
-uint32_t IPACM_Lan::cpe_hdr_template_hdl = 0;
-
-hdr_proc_ctx_info IPACM_Lan::lan_to_wlan_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_usb_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_cpe_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::wlan_to_wlan_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::usb_to_cpe_hdr_proc_ctx;
-hdr_proc_ctx_info IPACM_Lan::cpe_to_usb_hdr_proc_ctx;
-
-eth_bridge_subnet_client_info IPACM_Lan::eth_bridge_client[IPA_LAN_TO_LAN_MAX_CLIENT];
-
-int IPACM_Lan::eth_bridge_num_client = 0;
-bool IPACM_Lan::is_usb_up = false;
-bool IPACM_Lan::is_cpe_up = false;
-
 IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index)
 {
 	num_eth_client = 0;
@@ -85,8 +65,7 @@
 	odu_route_rule_v4_hdl = NULL;
 	odu_route_rule_v6_hdl = NULL;
 	eth_client = NULL;
-	int m_fd_odu, ret = IPACM_SUCCESS;
-	uint32_t* hdr_template_ptr;
+	int i, m_fd_odu, ret = IPACM_SUCCESS;
 
 	Nat_App = NatApp::GetInstance();
 	if (Nat_App == NULL)
@@ -111,39 +90,7 @@
 
 		IPACMDBG_H(" IPACM->IPACM_Lan(%d) constructor: Tx:%d Rx:%d \n", ipa_if_num,
 					 iface_query->num_tx_props, iface_query->num_rx_props);
-#ifdef FEATURE_ETH_BRIDGE_LE
-		if((ipa_if_cate == LAN_IF || ipa_if_cate == ODU_IF) && tx_prop != NULL)
-		{
-			if (IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE && tx_prop->tx[0].hdr_l2_type != IPACM_Lan::lan_hdr_type)
-			{
-				IPACMERR("The LAN header format is not consistent! Now header format is %d.\n", tx_prop->tx[0].hdr_l2_type);
-			}
-			else
-			{
-				if(ipa_if_cate == LAN_IF)
-				{
-					hdr_template_ptr = &IPACM_Lan::usb_hdr_template_hdl;
-					IPACM_Lan::is_usb_up = true;
-				}
-				else //else it is ODU_IF (cpe)
-				{
-					hdr_template_ptr = &IPACM_Lan::cpe_hdr_template_hdl;
-					IPACM_Lan::is_cpe_up = true;
-				}
 
-				if(eth_bridge_get_hdr_template_hdl(hdr_template_ptr) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to setup lan hdr template.\n");
-				}
-				else
-				{
-					IPACM_Lan::lan_hdr_type = tx_prop->tx[0].hdr_l2_type;
-					IPACMDBG_H("The LAN header format is %d.\n", tx_prop->tx[0].hdr_l2_type);
-					add_hdr_proc_ctx();
-				}
-			}
-		}
-#endif
 		/* ODU routing table initilization */
 		if(ipa_if_cate == ODU_IF)
 		{
@@ -163,19 +110,9 @@
 	memset(wan_ul_fl_rule_hdl_v4, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
 	memset(wan_ul_fl_rule_hdl_v6, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
 
-	memset(lan2lan_flt_rule_hdl_v4, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));
-	num_lan2lan_flt_rule_v4 = 0;
-
-	memset(lan2lan_flt_rule_hdl_v6, 0, MAX_OFFLOAD_PAIR * sizeof(lan2lan_flt_rule_hdl));
-	num_lan2lan_flt_rule_v6 = 0;
-
-	memset(lan2lan_hdr_hdl_v4, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));
-	memset(lan2lan_hdr_hdl_v6, 0, MAX_OFFLOAD_PAIR*sizeof(lan2lan_hdr_hdl));
-
 	is_active = true;
 	memset(ipv4_icmp_flt_rule_hdl, 0, NUM_IPV4_ICMP_FLT_RULE * sizeof(uint32_t));
-	memset(tcp_ctl_flt_rule_hdl_v4, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));
-	memset(tcp_ctl_flt_rule_hdl_v6, 0, NUM_TCP_CTL_FLT_RULE*sizeof(uint32_t));
+
 	is_mode_switch = false;
 	if_ipv4_subnet =0;
 	memset(private_fl_rule_hdl, 0, IPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(uint32_t));
@@ -187,7 +124,6 @@
 	/* ODU routing table initilization */
 	if(ipa_if_cate == ODU_IF)
 	{
-
 		/* only do one time ioctl to odu-driver to infrom in router or bridge mode*/
 		if (IPACM_Lan::odu_up != true)
 		{
@@ -220,47 +156,14 @@
 		}
 	}
 
-	int i;
-	each_client_rt_rule_count_v4 = 0;
-	each_client_rt_rule_count_v6 = 0;
+	each_client_rt_rule_count[IPA_IP_v4] = 0;
+	each_client_rt_rule_count[IPA_IP_v6] = 0;
 	if(iface_query != NULL && tx_prop != NULL)
 	{
 		for(i=0; i<iface_query->num_tx_props; i++)
-		{
-			if(tx_prop->tx[i].ip == IPA_IP_v4)
-			{
-				each_client_rt_rule_count_v4++;
-			}
-			else
-			{
-				each_client_rt_rule_count_v6++;
-			}
-		}
+			each_client_rt_rule_count[tx_prop->tx[i].ip]++;
 	}
-	IPACMDBG_H("Need to add %d IPv4 and %d IPv6 routing rules for eth bridge for each client.\n", each_client_rt_rule_count_v4, each_client_rt_rule_count_v6);
-
-	memset(eth_bridge_client_flt_info, 0, IPA_LAN_TO_LAN_MAX_CLIENT * sizeof(eth_bridge_subnet_client_flt_info));
-
-	eth_bridge_lan_client_rt_from_lan_info_v4 = NULL;
-	eth_bridge_lan_client_rt_from_lan_info_v6 = NULL;
-	eth_bridge_lan_client_rt_from_wlan_info_v4 = NULL;
-	eth_bridge_lan_client_rt_from_wlan_info_v6 = NULL;
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(tx_prop != NULL)
-	{
-		client_rt_info_size_v4 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v4 * sizeof(uint32_t);
-		eth_bridge_lan_client_rt_from_lan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_LAN_CLIENT, client_rt_info_size_v4);
-		eth_bridge_lan_client_rt_from_wlan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_LAN_CLIENT, client_rt_info_size_v4);
-		client_rt_info_size_v6 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v6 * sizeof(uint32_t);
-		eth_bridge_lan_client_rt_from_lan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
-		eth_bridge_lan_client_rt_from_wlan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
-
-	}
-#endif
-	lan_client_rt_from_lan_info_count_v4 = 0;
-	lan_client_rt_from_lan_info_count_v6 = 0;
-	lan_client_rt_from_wlan_info_count_v4 = 0;
-	lan_client_rt_from_wlan_info_count_v6 = 0;
+	IPACMDBG_H("Need to add %d IPv4 and %d IPv6 routing rules for eth bridge for each client.\n", each_client_rt_rule_count[IPA_IP_v4], each_client_rt_rule_count[IPA_IP_v6]);
 
 #ifdef FEATURE_IPA_ANDROID
 	/* set the IPA-client pipe enum */
@@ -760,7 +663,6 @@
 				IPACMDBG_H("ETH iface got client \n");
 				/* first construc ETH full header */
 				handle_eth_hdr_init(data->mac_addr);
-				handle_lan2lan_client_active(data, IPA_LAN_CLIENT_ACTIVE);
 				IPACMDBG_H("construct ETH header and route rules \n");
 				/* Associate with IP and construct RT-rule */
 				if (handle_eth_client_ipaddr(data) == IPACM_FAILURE)
@@ -773,36 +675,7 @@
 					/* Add NAT rules after ipv4 RT rules are set */
 					CtList->HandleNeighIpAddrAddEvt(data);
 				}
-#ifdef FEATURE_ETH_BRIDGE_LE
-				if (ipa_if_cate == LAN_IF)
-				{
-					if (IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v4);
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v6);
-					}
-					if (IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v4);
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v6);
-					}
-				}
-				if (ipa_if_cate == ODU_IF)
-				{
-					if (IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v4);
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_LAN, IPA_IP_v6);
-					}
-					if (IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v4);
-						eth_bridge_add_lan_client_rt_rule(data->mac_addr, SRC_WLAN, IPA_IP_v6);
-					}
-				}
-				eth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_CLIENT_ADD_EVENT);
-				eth_bridge_add_client(data->mac_addr);
-#endif
+				eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_ADD, IPA_IP_MAX, data->mac_addr);
 				return;
 			}
 		}
@@ -829,35 +702,11 @@
 					handle_del_ipv6_addr(data);
 					return;
 				}
-#ifdef FEATURE_ETH_BRIDGE_LE
-				if (ipa_if_cate == LAN_IF)
-				{
-					if (IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_LAN);
-					}
-					if (IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_WLAN);
-					}
-				}
-				if (ipa_if_cate == ODU_IF)
-				{
-					if (IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_LAN);
-					}
-					if (IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_lan_client_rt_rule(data->mac_addr, SRC_WLAN);
-					}
-				}
-				eth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_CLIENT_DEL_EVENT);
-				eth_bridge_del_client(data->mac_addr);
-#endif
+
+				eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_DEL, IPA_IP_MAX, data->mac_addr);
+
 				IPACMDBG_H("LAN iface delete client \n");
 				handle_eth_client_down_evt(data->mac_addr);
-				handle_lan2lan_client_active(data, IPA_LAN_CLIENT_INACTIVE);
 				return;
 			}
 		}
@@ -875,124 +724,6 @@
 		handle_software_routing_disable();
 		break;
 
-	case IPA_ETH_BRIDGE_CLIENT_ADD_EVENT:
-			{
-				IPACMDBG_H("Received IPA_ETH_BRIDGE_CLIENT_ADD_EVENT event.\n");
-				ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
-				if(mac != NULL)
-				{
-					if (mac->if_index == ipa_if_num)
-					{
-						IPACMDBG_H("The event was sent by same interface, if_index: %d ignore. \n", mac->if_index);
-						return;
-					}
-					if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
-					{
-						eth_bridge_add_client_flt_rule(mac->mac_addr, IPA_IP_v4, mac->ipa_if_cate);
-					}
-					if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
-					{
-						eth_bridge_add_client_flt_rule(mac->mac_addr, IPA_IP_v6, mac->ipa_if_cate);
-					}
-				}
-				else
-				{
-					IPACMERR("Event MAC is empty.\n");
-				}
-			}
-			break;
-
-	case IPA_ETH_BRIDGE_CLIENT_DEL_EVENT:
-			{
-				IPACMDBG_H("Received IPA_ETH_BRIDGE_CLIENT_DEL_EVENT event.\n");
-				ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
-				if(mac != NULL)
-				{
-					if (mac->if_index == ipa_if_num)
-					{
-						IPACMDBG_H("The event was sent by same interface, if_index: %d ignore. \n", mac->if_index);
-						return;
-					}
-					if(eth_bridge_del_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)
-					{
-						IPACMDBG_H("Failed to delete client MAC based flt rule.\n");
-					}
-				}
-				else
-				{
-					IPACMERR("Event MAC is empty.\n");
-				}
-			}
-			break;
-
-	case IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT:
-	{
-		IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT event.\n");
-		int i;
-		ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
-		if(cat == NULL)
-		{
-			IPACMERR("Event data is empty.\n");
-			return;
-		}
-		if (cat->if_cat == ipa_if_cate)
-		{
-			IPACMDBG_H("The event was sent by same interface, if_cat: %d ignore. \n", cat->if_cat);
-			return;
-		}
-
-		for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-		{
-			if(IPACM_Lan::eth_bridge_client[i].ipa_if_num == ipa_if_num)
-			{
-				if (cat->if_cat == WLAN_IF)
-				{
-					eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_WLAN, IPA_IP_v4);
-					eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_WLAN, IPA_IP_v6);
-				}
-				else
-				{
-					eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN, IPA_IP_v4);
-					eth_bridge_add_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN, IPA_IP_v6);
-				}
-			}
-		}
-	}
-	break;
-
-	case IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT:
-	{
-		IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT event.\n");
-		int i;
-		ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
-		if(cat == NULL)
-		{
-			IPACMERR("Event data is empty.\n");
-			return;
-		}
-		if (cat->if_cat == ipa_if_cate)
-		{
-			IPACMDBG_H("The event was sent by same interface, if_cat: %d ignore.\n", cat->if_cat);
-			return;
-		}
-
-		for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-		{
-			if(IPACM_Lan::eth_bridge_client[i].ipa_if_num == ipa_if_num)
-			{
-				if (cat->if_cat == WLAN_IF)
-				{
-					eth_bridge_del_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_WLAN);
-				}
-				else
-				{
-					eth_bridge_del_lan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN);
-				}
-			}
-		}
-	}
-	break;
-
 	case IPA_CRADLE_WAN_MODE_SWITCH:
 	{
 		IPACMDBG_H("Received IPA_CRADLE_WAN_MODE_SWITCH event.\n");
@@ -1260,11 +991,10 @@
 
 		init_fl_rule(data->iptype);
 		install_ipv4_icmp_flt_rule();
-#ifdef FEATURE_ETH_BRIDGE_LE
+
 		/* populate the flt rule offset for eth bridge */
-		eth_bridge_flt_rule_offset_v4 = ipv4_icmp_flt_rule_hdl[0];
-		eth_bridge_install_cache_client_flt_rule(data->iptype);
-#endif
+		eth_bridge_flt_rule_offset[data->iptype] = ipv4_icmp_flt_rule_hdl[0];
+		eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v4, NULL);
 	}
 	else
 	{
@@ -1352,10 +1082,11 @@
 		if (num_dft_rt_v6 == 0)
 		{
 			install_ipv6_icmp_flt_rule();
-#ifdef FEATURE_ETH_BRIDGE_LE
-			eth_bridge_flt_rule_offset_v6 = ipv6_icmp_flt_rule_hdl[0];
-			eth_bridge_install_cache_client_flt_rule(data->iptype);
-#endif
+
+			/* populate the flt rule offset for eth bridge */
+			eth_bridge_flt_rule_offset[data->iptype] = ipv6_icmp_flt_rule_hdl[0];
+			eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v6, NULL);
+
 			init_fl_rule(data->iptype);
 		}
 		num_dft_rt_v6++;
@@ -2752,28 +2483,6 @@
 		goto fail;
 	}
 
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(ipa_if_cate == LAN_IF)
-	{
-		IPACM_Lan::usb_hdr_template_hdl = 0;
-		IPACM_Lan::is_usb_up = false;
-		if(IPACM_Lan::is_cpe_up == false) //if all LAN ifaces are down
-		{
-			IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
-		}
-	}
-	if(ipa_if_cate == ODU_IF)
-	{
-		IPACM_Lan::cpe_hdr_template_hdl = 0;
-		IPACM_Lan::is_cpe_up = false;
-		if(IPACM_Lan::is_usb_up == false) //if all LAN ifaces are down
-		{
-			IPACM_Lan::lan_hdr_type = IPA_HDR_L2_NONE;
-		}
-	}
-	del_hdr_proc_ctx();
-#endif
-
 	/* delete wan filter rule */
 	if (IPACM_Wan::isWanUP(ipa_if_num) && rx_prop != NULL)
 	{
@@ -2806,10 +2515,6 @@
 		}
 		IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, IPV4_DEFAULT_FILTERTING_RULES);
 
-#ifdef FEATURE_ETH_BRIDGE_LE
-		eth_bridge_remove_all_client_flt_rule(IPA_IP_v4);
-#endif
-
 		/* free private-subnet ipv4 filter rules */
 		if (IPACM_Iface::ipacmcfg->ipa_num_private_subnet > IPA_PRIV_SUBNET_FILTER_RULE_HANDLES)
 		{
@@ -2856,9 +2561,6 @@
 			goto fail;
 		}
 		IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, IPV6_DEFAULT_FILTERTING_RULES);
-#ifdef FEATURE_ETH_BRIDGE_LE
-		eth_bridge_remove_all_client_flt_rule(IPA_IP_v6);
-#endif
 	}
 	IPACMDBG_H("Finished delete default iface ipv6 filtering rules \n ");
 
@@ -2895,13 +2597,6 @@
 	IPACMDBG_H("left %d eth clients need to be deleted \n ", num_eth_client);
 	for (i = 0; i < num_eth_client; i++)
 	{
-#ifdef FEATURE_ETH_BRIDGE_LE
-			eth_bridge_del_lan_client_rt_rule(get_client_memptr(eth_client, i)->mac, SRC_LAN);
-			eth_bridge_del_lan_client_rt_rule(get_client_memptr(eth_client, i)->mac, SRC_WLAN);
-			eth_bridge_post_lan_client_event(get_client_memptr(eth_client, i)->mac, IPA_ETH_BRIDGE_CLIENT_DEL_EVENT);
-			eth_bridge_del_client(get_client_memptr(eth_client, i)->mac);
-#endif
-
 			/* First reset nat rules and then route rules */
 			if(get_client_memptr(eth_client, i)->ipv4_set == true)
 			{
@@ -2963,9 +2658,7 @@
 		handle_software_routing_disable();
 	}
 
-	/* posting ip to lan2lan module to delete RT/FILTER rules*/
-	post_lan2lan_client_disconnect_msg(IPA_IP_v4);
-	post_lan2lan_client_disconnect_msg(IPA_IP_v6);
+	eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_DOWN, IPA_IP_MAX, NULL);
 
 /* Delete private subnet*/
 #ifdef FEATURE_IPA_ANDROID
@@ -3017,24 +2710,7 @@
 	{
 		free(iface_query);
 	}
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(eth_bridge_lan_client_rt_from_lan_info_v4 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_lan_info_v4);
-	}
-	if(eth_bridge_lan_client_rt_from_lan_info_v6 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_lan_info_v6);
-	}
-	if(eth_bridge_lan_client_rt_from_wlan_info_v4 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_wlan_info_v4);
-	}
-	if(eth_bridge_lan_client_rt_from_wlan_info_v6 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_wlan_info_v6);
-	}
-#endif
+
 	is_active = false;
 	post_del_self_evt();
 
@@ -3319,469 +2995,6 @@
 	return IPACM_SUCCESS;
 }
 
-
-/*handle lan2lan client active*/
-int IPACM_Lan::handle_lan2lan_client_active(ipacm_event_data_all *data, ipa_cm_event_id event)
-{
-	if((tx_prop == NULL) || (rx_prop == NULL))
-	{
-		IPACMDBG_H("No tx/rx properties registered for iface %s, not posting lan2lan event(%d)\n", dev_name, event);
-		return IPACM_SUCCESS;
-	}
-
-	if(data == NULL)
-	{
-		IPACMERR("Event data is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	if(data->iptype == IPA_IP_v4 && ip_type != IPA_IP_v4 && ip_type != IPA_IP_MAX)
-	{
-		IPACMERR("Client has IPv4 addr but iface does not have IPv4 up.\n");
-		return IPACM_FAILURE;
-	}
-	if(data->iptype == IPA_IP_v6 && ip_type != IPA_IP_v6 && ip_type != IPA_IP_MAX)
-	{
-		IPACMERR("Client has IPv6 addr but iface does not have IPv6 up.\n");
-		return IPACM_FAILURE;
-	}
-
-	ipacm_cmd_q_data evt_data;
-	memset(&evt_data, 0, sizeof(evt_data));
-
-	ipacm_event_lan_client* lan_client;
-	lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
-	if(lan_client == NULL)
-	{
-		IPACMERR("Unable to allocate memory.\n");
-		return IPACM_FAILURE;
-	}
-	memset(lan_client, 0, sizeof(ipacm_event_lan_client));
-	lan_client->iptype = data->iptype;
-	lan_client->ipv4_addr = data->ipv4_addr;
-	memcpy(lan_client->ipv6_addr, data->ipv6_addr, 4 * sizeof(uint32_t));
-	memcpy(lan_client->mac_addr, data->mac_addr, 6 * sizeof(uint8_t));
-	lan_client->p_iface = this;
-
-	evt_data.event = event;
-	evt_data.evt_data = (void*)lan_client;
-
-	IPACMDBG_H("Posting event: %d\n", event);
-	IPACM_EvtDispatcher::PostEvt(&evt_data);
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::add_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr, uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t* rule_hdl)
-{
-	if(rx_prop == NULL)
-	{
-		IPACMERR("There is no rx_prop for iface %s, not able to add lan2lan filtering rule.\n", dev_name);
-		return IPACM_FAILURE;
-	}
-	if(rule_hdl == NULL)
-	{
-		IPACMERR("Filteing rule handle is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Got a new lan2lan flt rule with IP type: %d\n", iptype);
-
-	int i, len, res = IPACM_SUCCESS;
-	struct ipa_flt_rule_mdfy flt_rule;
-	struct ipa_ioc_mdfy_flt_rule* pFilteringTable;
-
-	len = sizeof(struct ipa_ioc_mdfy_flt_rule) + sizeof(struct ipa_flt_rule_mdfy);
-
-	pFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
-
-	if (pFilteringTable == NULL)
-	{
-		IPACMERR("Error allocate lan2lan flt rule memory...\n");
-		return IPACM_FAILURE;
-	}
-	memset(pFilteringTable, 0, len);
-
-	pFilteringTable->commit = 1;
-	pFilteringTable->ip = iptype;
-	pFilteringTable->num_rules = 1;
-
-	memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));
-
-	if(iptype == IPA_IP_v4)
-	{
-		IPACMDBG_H("src_v4_addr: %d dst_v4_addr: %d\n", src_v4_addr, dst_v4_addr);
-
-		if(num_lan2lan_flt_rule_v4 >= MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Lan2lan flt rule table is full, not able to add.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-
-		if(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4))
-		{
-			IPACMERR("Failed to get routing table %s handle.\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		IPACMDBG_H("Routing handle for table %s: %d\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name,
-				IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl);
-
-		flt_rule.status = -1;
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_flt_rule_hdl_v4[i].valid == false)
-			{
-				flt_rule.rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;
-				break;
-			}
-		}
-		if(i == MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Failed to find a filtering rule.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-
-		flt_rule.rule.retain_hdr = 0;
-		flt_rule.rule.to_uc = 0;
-		flt_rule.rule.eq_attrib_type = 0;
-		flt_rule.rule.action = IPA_PASS_TO_ROUTING;
-		flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.hdl;
-
-		memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
-					 sizeof(flt_rule.rule.attrib));
-		IPACMDBG_H("Rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
-
-		flt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
-		flt_rule.rule.attrib.u.v4.src_addr = src_v4_addr;
-		flt_rule.rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;
-
-		flt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
-		flt_rule.rule.attrib.u.v4.dst_addr = dst_v4_addr;
-		flt_rule.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
-
-		memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-		if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
-		{
-			IPACMERR("Error modifying filtering rule.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		else
-		{
-			lan2lan_flt_rule_hdl_v4[i].valid = true;
-			*rule_hdl = lan2lan_flt_rule_hdl_v4[i].rule_hdl;
-			num_lan2lan_flt_rule_v4++;
-			IPACMDBG_H("Flt rule modified, hdl: 0x%x, status: %d\n", pFilteringTable->rules[0].rule_hdl,
-						pFilteringTable->rules[0].status);
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		if(num_lan2lan_flt_rule_v6 >= MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Lan2lan flt rule table is full, not able to add.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		if(src_v6_addr == NULL || dst_v6_addr == NULL)
-		{
-			IPACMERR("Got IPv6 flt rule but without IPv6 src/dst addr.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\n", src_v6_addr[0], src_v6_addr[1],
-				src_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);
-
-		if(false == m_routing.GetRoutingTable(&IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6))
-		{
-			IPACMERR("Failed to get routing table %s handle.\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		IPACMDBG_H("Routing handle for table %s: %d\n", IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name,
-				IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl);
-
-		flt_rule.status = -1;
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_flt_rule_hdl_v6[i].valid == false)
-			{
-				flt_rule.rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;
-				break;
-			}
-		}
-		if(i == MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Failed to find a filtering rule handle.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-
-		flt_rule.rule.retain_hdr = 0;
-		flt_rule.rule.to_uc = 0;
-		flt_rule.rule.eq_attrib_type = 0;
-		flt_rule.rule.action = IPA_PASS_TO_ROUTING;
-		flt_rule.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.hdl;
-
-		memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
-					 sizeof(flt_rule.rule.attrib));
-		IPACMDBG_H("Rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
-
-		flt_rule.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
-		flt_rule.rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];
-		flt_rule.rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];
-		flt_rule.rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];
-		flt_rule.rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];
-		flt_rule.rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;
-
-
-		flt_rule.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
-		flt_rule.rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];
-		flt_rule.rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];
-		flt_rule.rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];
-		flt_rule.rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
-
-		memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-		if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
-		{
-			IPACMERR("Error modifying filtering rule.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		else
-		{
-			lan2lan_flt_rule_hdl_v6[i].valid = true;
-			*rule_hdl = lan2lan_flt_rule_hdl_v6[i].rule_hdl;
-			num_lan2lan_flt_rule_v6++;
-			IPACMDBG_H("Flt rule modified, hdl: 0x%x, status: %d\n", pFilteringTable->rules[0].rule_hdl,
-						pFilteringTable->rules[0].status);
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-
-fail:
-	free(pFilteringTable);
-	return res;
-}
-
-int IPACM_Lan::add_dummy_lan2lan_flt_rule(ipa_ip_type iptype)
-{
-	if(rx_prop == NULL)
-	{
-		IPACMDBG_H("There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\n", dev_name);
-		return 0;
-	}
-
-	int i, len, res = IPACM_SUCCESS;
-	struct ipa_flt_rule_add flt_rule;
-	ipa_ioc_add_flt_rule* pFilteringTable;
-
-	len = sizeof(struct ipa_ioc_add_flt_rule) +	MAX_OFFLOAD_PAIR * sizeof(struct ipa_flt_rule_add);
-
-	pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
-	if (pFilteringTable == NULL)
-	{
-		IPACMERR("Error allocate flt table memory...\n");
-		return IPACM_FAILURE;
-	}
-	memset(pFilteringTable, 0, len);
-
-	pFilteringTable->commit = 1;
-	pFilteringTable->ep = rx_prop->rx[0].src_pipe;
-	pFilteringTable->global = false;
-	pFilteringTable->ip = iptype;
-	pFilteringTable->num_rules = MAX_OFFLOAD_PAIR;
-
-	memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
-
-	flt_rule.rule.retain_hdr = 0;
-	flt_rule.at_rear = true;
-	flt_rule.flt_rule_hdl = -1;
-	flt_rule.status = -1;
-	flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
-#ifdef FEATURE_IPA_V3
-	flt_rule.rule.hashable = true;
-#endif
-	memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib,
-			sizeof(flt_rule.rule.attrib));
-
-	if(iptype == IPA_IP_v4)
-	{
-		flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
-		flt_rule.rule.attrib.u.v4.src_addr_mask = ~0;
-		flt_rule.rule.attrib.u.v4.src_addr = ~0;
-		flt_rule.rule.attrib.u.v4.dst_addr_mask = ~0;
-		flt_rule.rule.attrib.u.v4.dst_addr = ~0;
-
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-		}
-
-		if (false == m_filtering.AddFilteringRule(pFilteringTable))
-		{
-			IPACMERR("Error adding dummy lan2lan v4 flt rule\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		else
-		{
-			IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, MAX_OFFLOAD_PAIR);
-			/* copy filter rule hdls */
-			for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
-			{
-				if (pFilteringTable->rules[i].status == 0)
-				{
-					lan2lan_flt_rule_hdl_v4[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
-					IPACMDBG_H("Lan2lan v4 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v4[i].rule_hdl);
-				}
-				else
-				{
-					IPACMERR("Failed adding lan2lan v4 flt rule %d\n", i);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-			}
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		flt_rule.rule.attrib.attrib_mask = IPA_FLT_SRC_ADDR | IPA_FLT_DST_ADDR;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[0] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[1] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[2] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr_mask[3] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr[0] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr[1] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr[2] = ~0;
-		flt_rule.rule.attrib.u.v6.src_addr[3] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[0] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[1] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[2] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr_mask[3] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr[0] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr[1] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr[2] = ~0;
-		flt_rule.rule.attrib.u.v6.dst_addr[3] = ~0;
-
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			memcpy(&(pFilteringTable->rules[i]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-		}
-
-		if (false == m_filtering.AddFilteringRule(pFilteringTable))
-		{
-			IPACMERR("Error adding dummy lan2lan v6 flt rule\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		else
-		{
-			IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, MAX_OFFLOAD_PAIR);
-			/* copy filter rule hdls */
-			for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
-			{
-				if (pFilteringTable->rules[i].status == 0)
-				{
-					lan2lan_flt_rule_hdl_v6[i].rule_hdl = pFilteringTable->rules[i].flt_rule_hdl;
-					IPACMDBG_H("Lan2lan v6 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v6[i].rule_hdl);
-				}
-				else
-				{
-					IPACMERR("Failed adding lan2lan v6 flt rule %d\n", i);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-			}
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		goto fail;
-	}
-
-fail:
-	free(pFilteringTable);
-	return res;
-}
-
-int IPACM_Lan::del_lan2lan_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)
-{
-	int i;
-
-	IPACMDBG_H("Del lan2lan flt rule with IP type: %d hdl: %d\n", iptype, rule_hdl);
-	if(iptype == IPA_IP_v4)
-	{
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_flt_rule_hdl_v4[i].rule_hdl == rule_hdl)
-			{
-				if(reset_to_dummy_flt_rule(IPA_IP_v4, rule_hdl) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to delete lan2lan v4 flt rule %d\n", rule_hdl);
-					return IPACM_FAILURE;
-				}
-				IPACMDBG_H("Deleted lan2lan v4 flt rule %d\n", rule_hdl);
-				lan2lan_flt_rule_hdl_v4[i].valid = false;
-				num_lan2lan_flt_rule_v4--;
-				break;
-			}
-		}
-
-		if(i == MAX_OFFLOAD_PAIR) //not finding the rule
-		{
-			IPACMERR("The rule is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_flt_rule_hdl_v6[i].rule_hdl == rule_hdl)
-			{
-				if(reset_to_dummy_flt_rule(IPA_IP_v6, rule_hdl) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to delete lan2lan v6 flt rule %d\n", rule_hdl);
-					return IPACM_FAILURE;
-				}
-				IPACMDBG_H("Deleted lan2lan v6 flt rule %d\n", rule_hdl);
-				lan2lan_flt_rule_hdl_v6[i].valid = false;
-				num_lan2lan_flt_rule_v6--;
-				break;
-			}
-		}
-
-		if(i == MAX_OFFLOAD_PAIR) //not finding the rule
-		{
-			IPACMERR("The rule is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		return IPACM_FAILURE;
-	}
-
-	return IPACM_SUCCESS;
-}
-
 int IPACM_Lan::reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl)
 {
 	int len, res = IPACM_SUCCESS;
@@ -3881,457 +3094,6 @@
 	return res;
 }
 
-int IPACM_Lan::add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl)
-{
-	if(tx_prop == NULL)
-	{
-		IPACMERR("There is no tx_prop, cannot add header.\n");
-		return IPACM_FAILURE;
-	}
-	if(src_mac == NULL || dst_mac == NULL)
-	{
-		IPACMERR("Either src_mac or dst_mac is null, cannot add header.\n");
-		return IPACM_FAILURE;
-	}
-	if(hdr_hdl == NULL)
-	{
-		IPACMERR("Header handle is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	int i, j, len;
-	int res = IPACM_SUCCESS;
-	char index[4];
-	struct ipa_ioc_copy_hdr sCopyHeader;
-	struct ipa_ioc_add_hdr *pHeader;
-
-	IPACMDBG_H("Get lan2lan header request, src_mac: 0x%02x%02x%02x%02x%02x%02x dst_mac: 0x%02x%02x%02x%02x%02x%02x\n",
-			src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], dst_mac[0], dst_mac[1],
-			dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]);
-
-	len = sizeof(struct ipa_ioc_add_hdr) + sizeof(struct ipa_hdr_add);
-	pHeader = (struct ipa_ioc_add_hdr *)malloc(len);
-	if (pHeader == NULL)
-	{
-		IPACMERR("Failed to allocate header\n");
-		return IPACM_FAILURE;
-	}
-	memset(pHeader, 0, len);
-
-	if(iptype == IPA_IP_v4)
-	{		/* copy partial header for v4*/
-		for(i=0; i<tx_prop->num_tx_props; i++)
-		{
-			if(tx_prop->tx[i].ip == IPA_IP_v4)
-			{
-				IPACMDBG_H("Got v4-header name from %d tx props\n", i);
-				memset(&sCopyHeader, 0, sizeof(sCopyHeader));
-				memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
-				IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
-				if(m_header.CopyHeader(&sCopyHeader) == false)
-				{
-					IPACMERR("Copy header failed\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
-				if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
-				{
-					IPACMERR("Header oversize\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
-				}
-
-				if(sCopyHeader.is_eth2_ofst_valid)
-				{
-					memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);
-					memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);
-				}
-				else
-				{
-					IPACMERR("Ethernet 2 header offset is invalid.\n");
-				}
-
-				pHeader->commit = true;
-				pHeader->num_hdrs = 1;
-
-				memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
-				strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));
-				pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-				for(j=0; j<MAX_OFFLOAD_PAIR; j++)
-				{
-					if( lan2lan_hdr_hdl_v4[j].valid == false)
-					{
-						IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
-						break;
-					}
-				}
-				if(j == MAX_OFFLOAD_PAIR)
-				{
-					IPACMERR("Failed to find an available hdr index.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				lan2lan_hdr_hdl_v4[j].valid = true;
-				snprintf(index,sizeof(index), "%d", j);
-				if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
-				{
-					IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
-				pHeader->hdr[0].is_partial = 0;
-				pHeader->hdr[0].hdr_hdl = -1;
-				pHeader->hdr[0].status = -1;
-
-				if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
-				{
-					IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				IPACMDBG_H("Installed v4 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
-							pHeader->hdr[0].hdr_hdl);
-				*hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				lan2lan_hdr_hdl_v4[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				break;
-			}
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{		/* copy partial header for v6*/
-		for(i=0; i<tx_prop->num_tx_props; i++)
-		{
-			if(tx_prop->tx[i].ip == IPA_IP_v6)
-			{
-				IPACMDBG_H("Got v6-header name from %d tx props\n", i);
-				memset(&sCopyHeader, 0, sizeof(sCopyHeader));
-				memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
-				IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
-				if(m_header.CopyHeader(&sCopyHeader) == false)
-				{
-					IPACMERR("Copy header failed\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
-				if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
-				{
-					IPACMERR("Header oversize\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
-				}
-				if(sCopyHeader.is_eth2_ofst_valid)
-				{
-					memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst], dst_mac, IPA_MAC_ADDR_SIZE);
-					memcpy(&pHeader->hdr[0].hdr[sCopyHeader.eth2_ofst+IPA_MAC_ADDR_SIZE], src_mac, IPA_MAC_ADDR_SIZE);
-				}
-				else
-				{
-					IPACMERR("Ethernet 2 header offset is invalid.\n");
-				}
-
-				pHeader->commit = true;
-				pHeader->num_hdrs = 1;
-
-				memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
-				strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_USB_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));
-				pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-				for(j=0; j<MAX_OFFLOAD_PAIR; j++)
-				{
-					if( lan2lan_hdr_hdl_v6[j].valid == false)
-					{
-						IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
-						break;
-					}
-				}
-				if(j == MAX_OFFLOAD_PAIR)
-				{
-					IPACMERR("Failed to find an available hdr index.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				lan2lan_hdr_hdl_v6[j].valid = true;
-				snprintf(index,sizeof(index), "%d", j);
-				if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
-				{
-					IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
-				pHeader->hdr[0].is_partial = 0;
-				pHeader->hdr[0].hdr_hdl = -1;
-				pHeader->hdr[0].status = -1;
-
-				if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
-				{
-					IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				IPACMDBG_H("Installed v6 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
-							pHeader->hdr[0].hdr_hdl);
-				*hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				lan2lan_hdr_hdl_v6[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				break;
-			}
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-	}
-
-fail:
-	free(pHeader);
-	return res;
-}
-
-int IPACM_Lan::del_lan2lan_hdr(ipa_ip_type iptype, uint32_t hdr_hdl)
-{
-	int i;
-	if (m_header.DeleteHeaderHdl(hdr_hdl) == false)
-	{
-		IPACMERR("Failed to delete header %d\n", hdr_hdl);
-		return IPACM_FAILURE;
-	}
-	IPACMDBG_H("Deleted header %d\n", hdr_hdl);
-
-	if(iptype == IPA_IP_v4)
-	{
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_hdr_hdl_v4[i].hdr_hdl == hdr_hdl)
-			{
-				lan2lan_hdr_hdl_v4[i].valid = false;
-				break;
-			}
-		}
-		if(i == MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Failed to find corresponding hdr hdl.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		for(i=0; i<MAX_OFFLOAD_PAIR; i++)
-		{
-			if(lan2lan_hdr_hdl_v6[i].hdr_hdl == hdr_hdl)
-			{
-				lan2lan_hdr_hdl_v6[i].valid = false;
-				break;
-			}
-		}
-		if(i == MAX_OFFLOAD_PAIR)
-		{
-			IPACMERR("Failed to find corresponding hdr hdl.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		return IPACM_FAILURE;
-	}
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::add_lan2lan_rt_rule(ipa_ip_type iptype, uint32_t src_v4_addr, uint32_t dst_v4_addr,
-			uint32_t* src_v6_addr, uint32_t* dst_v6_addr, uint32_t hdr_hdl, lan_to_lan_rt_rule_hdl* rule_hdl)
-{
-	struct ipa_ioc_add_rt_rule *rt_rule;
-	struct ipa_rt_rule_add *rt_rule_entry;
-	uint32_t tx_index;
-	int len;
-	int res = IPACM_SUCCESS;
-
-	IPACMDBG_H("Got a new lan2lan rt rule with IP type: %d\n", iptype);
-
-	if(rule_hdl == NULL)
-	{
-		IPACMERR("Rule hdl is empty.\n");
-		return IPACM_FAILURE;
-	}
-	memset(rule_hdl, 0, sizeof(lan_to_lan_rt_rule_hdl));
-
-	if(tx_prop == NULL)
-	{
-		IPACMDBG_H("There is no tx_prop for iface %s, not able to add lan2lan routing rule.\n", dev_name);
-		return IPACM_FAILURE;
-	}
-
-	len = sizeof(struct ipa_ioc_add_rt_rule) + sizeof(struct ipa_rt_rule_add);
-	rt_rule = (struct ipa_ioc_add_rt_rule *)malloc(len);
-	if (!rt_rule)
-	{
-		IPACMERR("Failed to allocate memory for rt rule\n");
-		return IPACM_FAILURE;
-	}
-	memset(rt_rule, 0, len);
-
-	rt_rule->commit = 1;
-	rt_rule->num_rules = 1;
-	rt_rule->ip = iptype;
-
-	if(iptype == IPA_IP_v4)
-	{
-		IPACMDBG_H("src_v4_addr: 0x%08x dst_v4_addr: 0x%08x\n", src_v4_addr, dst_v4_addr);
-
-		strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v4.name);
-		rt_rule_entry = &rt_rule->rules[0];
-		rt_rule_entry->at_rear = false;
-		rt_rule_entry->rt_rule_hdl = 0;
-		rt_rule_entry->status = -1;
-
-		for (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)
-		{
-		    if(tx_prop->tx[tx_index].ip != IPA_IP_v4)
-		    {
-		    	IPACMDBG_H("Tx:%d, iptype: %d conflict ip-type: %d bypass\n",
-		    				tx_index, tx_prop->tx[tx_index].ip, IPA_IP_v4);
-		    	continue;
-		    }
-
-			rt_rule_entry->rule.hdr_hdl = hdr_hdl;
-			rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
-			memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,
-					sizeof(rt_rule_entry->rule.attrib));
-
-			rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
-			rt_rule_entry->rule.attrib.u.v4.src_addr      = src_v4_addr;
-			rt_rule_entry->rule.attrib.u.v4.src_addr_mask = 0xFFFFFFFF;
-
-			rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
-			rt_rule_entry->rule.attrib.u.v4.dst_addr      = dst_v4_addr;
-			rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF;
-#ifdef FEATURE_IPA_V3
-			rt_rule_entry->rule.hashable = true;
-#endif
-			if(m_routing.AddRoutingRule(rt_rule) == false)
-			{
-				IPACMERR("Routing rule addition failed\n");
-				res = IPACM_FAILURE;
-				goto fail;
-			}
-			IPACMDBG_H("Added rt rule hdl: 0x%08x\n", rt_rule_entry->rt_rule_hdl);
-			rule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;
-			rule_hdl->num_rule++;
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		if(src_v6_addr == NULL || dst_v6_addr == NULL)
-		{
-			IPACMERR("Got IPv6 rt rule but without IPv6 src/dst addr.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-		IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x\n", src_v6_addr[0], src_v6_addr[1],
-				src_v6_addr[2], src_v6_addr[3], dst_v6_addr[0], dst_v6_addr[1], dst_v6_addr[2], dst_v6_addr[3]);
-
-		strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan2lan_v6.name);
-		rt_rule_entry = &rt_rule->rules[0];
-		rt_rule_entry->at_rear = false;
-		rt_rule_entry->rt_rule_hdl = 0;
-		rt_rule_entry->status = -1;
-
-		for (tx_index = 0; tx_index<iface_query->num_tx_props; tx_index++)
-		{
-		    if(tx_prop->tx[tx_index].ip != IPA_IP_v6)
-		    {
-		    	IPACMDBG_H("Tx:%d, iptype: %d conflict ip-type: %d bypass\n",
-		    				tx_index, tx_prop->tx[tx_index].ip, IPA_IP_v6);
-		    	continue;
-		    }
-
-			rt_rule_entry->rule.hdr_hdl = hdr_hdl;
-			rt_rule_entry->rule.dst = tx_prop->tx[tx_index].dst_pipe;
-			memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[tx_index].attrib,
-					sizeof(rt_rule_entry->rule.attrib));
-
-			rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
-			rt_rule_entry->rule.attrib.u.v6.src_addr[0] = src_v6_addr[0];
-			rt_rule_entry->rule.attrib.u.v6.src_addr[1] = src_v6_addr[1];
-			rt_rule_entry->rule.attrib.u.v6.src_addr[2] = src_v6_addr[2];
-			rt_rule_entry->rule.attrib.u.v6.src_addr[3] = src_v6_addr[3];
-			rt_rule_entry->rule.attrib.u.v6.src_addr_mask[0] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.src_addr_mask[1] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;
-
-			rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR;
-			rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = dst_v6_addr[0];
-			rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = dst_v6_addr[1];
-			rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = dst_v6_addr[2];
-			rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = dst_v6_addr[3];
-			rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF;
-			rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF;
-#ifdef FEATURE_IPA_V3
-			rt_rule_entry->rule.hashable = true;
-#endif
-			if(m_routing.AddRoutingRule(rt_rule) == false)
-			{
-				IPACMERR("Routing rule addition failed\n");
-				res = IPACM_FAILURE;
-				goto fail;
-			}
-			IPACMDBG_H("Added rt rule hdl: 0x%08x\n", rt_rule_entry->rt_rule_hdl);
-			rule_hdl->rule_hdl[rule_hdl->num_rule] = rt_rule_entry->rt_rule_hdl;
-			rule_hdl->num_rule++;
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-	}
-
-fail:
-	free(rt_rule);
-	return res;
-}
-
-int IPACM_Lan::del_lan2lan_rt_rule(ipa_ip_type iptype, lan_to_lan_rt_rule_hdl rule_hdl)
-{
-	if(rule_hdl.num_rule <= 0 || rule_hdl.num_rule > MAX_NUM_PROP)
-	{
-		IPACMERR("The number of rule handles are not correct.\n");
-		return IPACM_FAILURE;
-	}
-
-	int i, res = IPACM_SUCCESS;
-
-	IPACMDBG_H("Get %d rule handles with IP type %d\n", rule_hdl.num_rule, iptype);
-	for(i=0; i<rule_hdl.num_rule; i++)
-	{
-		if(m_routing.DeleteRoutingHdl(rule_hdl.rule_hdl[i], iptype) == false)
-		{
-			IPACMERR("Failed to delete routing rule hdl %d.\n", rule_hdl.rule_hdl[i]);
-			res = IPACM_FAILURE;
-		}
-		IPACMDBG_H("Deleted routing rule handle %d\n",rule_hdl.rule_hdl[i]);
-	}
-	return res;
-}
-
 void IPACM_Lan::post_del_self_evt()
 {
 	ipacm_cmd_q_data evt;
@@ -4371,13 +3133,6 @@
 		}
 	} /* end of for loop */
 
-	/* Pass info to LAN2LAN module */
-	res = post_lan2lan_client_disconnect_msg(iptype);
-	if (res != IPACM_SUCCESS)
-	{
-		IPACMERR("Failed to posting delete old iptype(%d) address.\n", iptype);
-		return res;
-	}
 	/* Reset ip-address */
 	for (i = 0; i < num_eth_client; i++)
 	{
@@ -4393,68 +3148,6 @@
 	return res;
 }
 
-/*handle lan2lan internal mesg posting*/
-int IPACM_Lan::post_lan2lan_client_disconnect_msg(ipa_ip_type iptype)
-{
-	int i, j;
-	ipacm_cmd_q_data evt_data;
-	ipacm_event_lan_client* lan_client;
-
-	for (i = 0; i < num_eth_client; i++)
-	{
-			if((get_client_memptr(eth_client, i)->ipv4_set == true)
-				&& (iptype == IPA_IP_v4))
-			{
-				lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
-				if(lan_client == NULL)
-				{
-					IPACMERR("Failed to allocate memory.\n");
-					return IPACM_FAILURE;
-				}
-				memset(lan_client, 0, sizeof(ipacm_event_lan_client));
-				lan_client->iptype = IPA_IP_v4;
-				lan_client->ipv4_addr = get_client_memptr(eth_client, i)->v4_addr;
-				lan_client->p_iface = this;
-
-				memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-				evt_data.evt_data = (void*)lan_client;
-				evt_data.event = IPA_LAN_CLIENT_DISCONNECT;
-
-				IPACMDBG_H("Posting event IPA_LAN_CLIENT_DISCONNECT\n");
-				IPACM_EvtDispatcher::PostEvt(&evt_data);
-			}
-
-			if((get_client_memptr(eth_client, i)->ipv6_set > 0)
-				&& (iptype == IPA_IP_v6))
-			{
-				for (j = 0; j < get_client_memptr(eth_client, i)->ipv6_set; j++)
-				{
-					lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
-					if(lan_client == NULL)
-					{
-						IPACMERR("Failed to allocate memory.\n");
-						return IPACM_FAILURE;
-					}
-					memset(lan_client, 0, sizeof(ipacm_event_lan_client));
-					lan_client->iptype = IPA_IP_v6;
-					lan_client->ipv6_addr[0] = get_client_memptr(eth_client, i)->v6_addr[j][0];
-					lan_client->ipv6_addr[1] = get_client_memptr(eth_client, i)->v6_addr[j][1];
-					lan_client->ipv6_addr[2] = get_client_memptr(eth_client, i)->v6_addr[j][2];
-					lan_client->ipv6_addr[3] = get_client_memptr(eth_client, i)->v6_addr[j][3];
-					lan_client->p_iface = this;
-
-					memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-					evt_data.evt_data = (void*)lan_client;
-					evt_data.event = IPA_LAN_CLIENT_DISCONNECT;
-
-					IPACMDBG_H("Posting event IPA_LAN_CLIENT_DISCONNECT\n");
-					IPACM_EvtDispatcher::PostEvt(&evt_data);
-				}
-			}
-	} /* end of for loop */
-	return IPACM_SUCCESS;
-}
-
 int IPACM_Lan::install_ipv4_icmp_flt_rule()
 {
 	int len;
@@ -4571,112 +3264,6 @@
 	return IPACM_SUCCESS;
 }
 
-void IPACM_Lan::install_tcp_ctl_flt_rule(ipa_ip_type iptype)
-{
-	if (rx_prop == NULL)
-	{
-		IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
-		return;
-	}
-
-	int len, i;
-	struct ipa_flt_rule_add flt_rule;
-	ipa_ioc_add_flt_rule* pFilteringTable;
-
-	len = sizeof(struct ipa_ioc_add_flt_rule) +	NUM_TCP_CTL_FLT_RULE * sizeof(struct ipa_flt_rule_add);
-
-	pFilteringTable = (struct ipa_ioc_add_flt_rule *)malloc(len);
-	if (pFilteringTable == NULL)
-	{
-		IPACMERR("Error allocate flt table memory...\n");
-		return;
-	}
-	memset(pFilteringTable, 0, len);
-
-	pFilteringTable->commit = 1;
-	pFilteringTable->ip = iptype;
-	pFilteringTable->ep = rx_prop->rx[0].src_pipe;
-	pFilteringTable->global = false;
-	pFilteringTable->num_rules = NUM_TCP_CTL_FLT_RULE;
-
-	memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_add));
-
-	flt_rule.at_rear = true;
-	flt_rule.flt_rule_hdl = -1;
-	flt_rule.status = -1;
-
-	flt_rule.rule.retain_hdr = 1;
-	flt_rule.rule.to_uc = 0;
-	flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
-#ifdef FEATURE_IPA_V3
-	flt_rule.rule.hashable = false;
-#endif
-	flt_rule.rule.eq_attrib_type = 1;
-
-	flt_rule.rule.eq_attrib.rule_eq_bitmap = 0;
-
-	if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)
-	{
-		flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);
-		flt_rule.rule.eq_attrib.metadata_meq32_present = 1;
-		flt_rule.rule.eq_attrib.metadata_meq32.offset = 0;
-		flt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;
-		flt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;
-	}
-
-	flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);
-	flt_rule.rule.eq_attrib.protocol_eq_present = 1;
-	flt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;
-
-	flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);
-	flt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;
-
-	/* add TCP FIN rule*/
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);
-	memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-
-	/* add TCP SYN rule*/
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);
-	memcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-
-	/* add TCP RST rule*/
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);
-	memcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_add));
-
-	if (false == m_filtering.AddFilteringRule(pFilteringTable))
-	{
-		IPACMERR("Error adding tcp control flt rule\n");
-		goto fail;
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
-			{
-				tcp_ctl_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].flt_rule_hdl;
-			}
-			IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, NUM_TCP_CTL_FLT_RULE);
-		}
-		else
-		{
-			for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
-			{
-				tcp_ctl_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].flt_rule_hdl;
-			}
-			IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, NUM_TCP_CTL_FLT_RULE);
-		}
-	}
-
-fail:
-	free(pFilteringTable);
-	return;
-}
-
 int IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)
 {
 	if(rx_prop == NULL)
@@ -4964,427 +3551,7 @@
 	return res;
 }
 
-int IPACM_Lan::eth_bridge_post_lan_client_event(uint8_t* mac_addr, ipa_cm_event_id evt)
-{
-	if(mac_addr == NULL)
-	{
-		IPACMERR("Event mac is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	ipacm_cmd_q_data evt_data;
-	memset(&evt_data, 0, sizeof(evt_data));
-
-	ipacm_event_data_mac* mac;
-	mac = (ipacm_event_data_mac*)malloc(sizeof(ipacm_event_data_mac));
-	if(mac == NULL)
-	{
-		IPACMERR("Unable to allocate memory.\n");
-		return IPACM_FAILURE;
-	}
-	memset(mac, 0, sizeof(ipacm_event_data_mac));
-	memcpy(mac->mac_addr, mac_addr, 6 * sizeof(uint8_t));
-	mac->if_index = ipa_if_num;
-	mac->ipa_if_cate = ipa_if_cate;
-
-	evt_data.event = evt;
-	evt_data.evt_data = (void*)mac;
-	IPACMDBG_H("Posting event: %d if_index: %d if_cate: %d\n", evt, mac->if_index, mac->ipa_if_cate);
-	IPACM_EvtDispatcher::PostEvt(&evt_data);
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::eth_bridge_add_client_flt_rule(uint8_t* mac, ipa_ip_type iptype, int dest_if_cate)
-{
-	int i, len, res = IPACM_SUCCESS, client_position;
-	struct ipa_flt_rule_add flt_rule_entry;
-	struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL;
-	struct ipa_ioc_get_rt_tbl rt_tbl;
-	enum ipa_hdr_l2_type hdr_type;
-	bool client_is_found = false;
-	uint32_t rule_hdl;
-
-#ifdef FEATURE_IPA_V3
-	if (rx_prop == NULL)
-	{
-		IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
-		return IPACM_FAILURE;
-	}
-	if(mac == NULL)
-	{
-		IPACMERR("MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
-	for(i=0; i<client_flt_info_count; i++)
-	{
-		if(memcmp(eth_bridge_client_flt_info[i].mac, mac, sizeof(eth_bridge_client_flt_info[i].mac)) == 0)
-		{
-			client_is_found = true;
-			client_position = i;
-			if( (iptype == IPA_IP_v4 && eth_bridge_client_flt_info[i].flt_rule_set_v4 == true)
-				|| (iptype == IPA_IP_v6 && eth_bridge_client_flt_info[i].flt_rule_set_v6 == true))
-			{
-				IPACMDBG_H("Flt rule for iptype %d has been set.\n", iptype);
-				return IPACM_SUCCESS;
-			}
-			break;
-		}
-	}
-
-	if(client_is_found == false)
-	{
-		if(client_flt_info_count == IPA_LAN_TO_LAN_MAX_CLIENT)
-		{
-			IPACMDBG_H("The client flt table is already full.\n");
-			return IPACM_FAILURE;
-		}
-		else
-		{
-			client_position = client_flt_info_count;
-			client_flt_info_count++;
-		}
-	}
-
-	hdr_type = eth_bridge_get_l2_hdr_type();
-
-	/* fetch appropriate routing table handle */
-	memset(&rt_tbl, 0, sizeof(rt_tbl));
-	rt_tbl.ip = iptype;
-	eth_bridge_get_rt_tbl_name(iptype, &rt_tbl, dest_if_cate);
-	if (false == m_routing.GetRoutingTable(&rt_tbl))
-	{
-		IPACMERR("Failed to get routing table handle.\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-
-	len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add);
-	pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len);
-	if (!pFilteringTable)
-	{
-		IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n");
-		return IPACM_FAILURE;
-	}
-	memset(pFilteringTable, 0, len);
-
-	/* add mac based rule*/
-	pFilteringTable->commit = 1;
-	pFilteringTable->ep = rx_prop->rx[0].src_pipe;
-	pFilteringTable->ip = iptype;
-	pFilteringTable->num_rules = 1;
-	pFilteringTable->add_after_hdl = iptype == IPA_IP_v4?
-		eth_bridge_flt_rule_offset_v4: eth_bridge_flt_rule_offset_v6;
-
-	memset(&flt_rule_entry, 0, sizeof(flt_rule_entry));
-	flt_rule_entry.at_rear = 1;
-
-	flt_rule_entry.rule.retain_hdr = 0;
-	flt_rule_entry.rule.to_uc = 0;
-	flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
-	flt_rule_entry.rule.eq_attrib_type = 0;
-	flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl;
-	IPACMDBG_H("Filtering rule uses routing table: %s\n",rt_tbl.name);
-
-	memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
-	if(hdr_type == IPA_HDR_L2_ETHERNET_II)
-	{
-		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-	}
-	else if(hdr_type == IPA_HDR_L2_802_3)
-	{
-		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-	}
-	else
-	{
-		IPACMERR("hdr type is not expected.\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-	memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr));
-	memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask));
-
-	memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry));
-	if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable))
-	{
-		IPACMERR("Failed to add client filtering rules.\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-	rule_hdl = pFilteringTable->rules[0].flt_rule_hdl;
-
-	memcpy(eth_bridge_client_flt_info[client_position].mac, mac, sizeof(eth_bridge_client_flt_info[client_position].mac));
-	if(iptype == IPA_IP_v4)
-	{
-		eth_bridge_client_flt_info[client_position].flt_rule_set_v4 = true;
-		eth_bridge_client_flt_info[client_position].flt_rule_hdl_v4 = rule_hdl;
-	}
-	else
-	{
-		eth_bridge_client_flt_info[client_position].flt_rule_set_v6 = true;
-		eth_bridge_client_flt_info[client_position].flt_rule_hdl_v6 = rule_hdl;
-	}
-
-fail:
-	if(pFilteringTable)
-		free(pFilteringTable);
-#endif
-	return res;
-}
-
-int IPACM_Lan::eth_bridge_del_client_flt_rule(uint8_t* mac)
-{
-	if(mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
-	int i, j, res = IPACM_SUCCESS;
-	for(i=0; i<client_flt_info_count; i++)
-	{
-		if(memcmp(eth_bridge_client_flt_info[i].mac, mac, sizeof(eth_bridge_client_flt_info[i].mac)) == 0)
-		{
-			break;
-		}
-	}
-
-	if(i == client_flt_info_count)
-	{
-		IPACMERR("Do not find the client.\n");
-		return IPACM_FAILURE;
-	}
-
-	if(eth_bridge_client_flt_info[i].flt_rule_set_v4 == true)
-	{
-		if(m_filtering.DeleteFilteringHdls(&eth_bridge_client_flt_info[i].flt_rule_hdl_v4, IPA_IP_v4, 1) == false)
-		{
-			IPACMERR("Failed to delete the client specific flt rule.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	if(eth_bridge_client_flt_info[i].flt_rule_set_v6 == true)
-	{
-		if(m_filtering.DeleteFilteringHdls(&eth_bridge_client_flt_info[i].flt_rule_hdl_v6, IPA_IP_v6, 1) == false)
-		{
-			IPACMERR("Failed to delete the wlan client specific flt rule.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	memcpy(&(eth_bridge_client_flt_info[i]), &(eth_bridge_client_flt_info[client_flt_info_count-1]), sizeof(eth_bridge_subnet_client_flt_info));
-	memset(&(eth_bridge_client_flt_info[client_flt_info_count-1]), 0, sizeof(eth_bridge_subnet_client_flt_info));
-	client_flt_info_count--;
-
-	return res;
-}
-
-int IPACM_Lan::add_hdr_proc_ctx()
-{
-	int len, res = IPACM_SUCCESS;
-	struct ipa_ioc_add_hdr_proc_ctx* pHeaderProcTable = NULL;
-
-	len = sizeof(struct ipa_ioc_add_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_add);
-	pHeaderProcTable = (ipa_ioc_add_hdr_proc_ctx*)malloc(len);
-	if(pHeaderProcTable == NULL)
-	{
-		IPACMERR("Cannot allocate header processing table.\n");
-		return IPACM_FAILURE;
-	}
-
-	if(IPACM_Lan::wlan_hdr_type != IPA_HDR_L2_NONE)
-	{
-		if(ipa_if_cate == WLAN_IF)
-		{
-			if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)
-			{
-				memset(pHeaderProcTable, 0, len);
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::wlan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding WLAN to WLAN hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-				}
-				else
-				{
-					IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("WLAN to WLAN hdr proc ctx is added successfully. \n");
-				}
-			}
-		}
-
-		if(IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE)
-		{
-			if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == false)
-			{
-				memset(pHeaderProcTable, 0, len);
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::wlan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::wlan_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding LAN to WLAN hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("LAN to WLAN hdr proc ctx is added successfully. \n");
-				}
-
-				ipacm_cmd_q_data evt_data;
-				memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
-				ipacm_event_data_if_cat* cat;
-				cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
-				if(cat == NULL)
-				{
-					IPACMERR("Unable to allocate memory.\n");
-					return IPACM_FAILURE;
-				}
-				memset(cat, 0, sizeof(ipacm_event_data_if_cat));
-				cat->if_cat = ipa_if_cate;
-
-				evt_data.evt_data = cat;
-				evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT;
-				IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT\n");
-				IPACM_EvtDispatcher::PostEvt(&evt_data);
-			}
-
-			if(IPACM_Lan::is_usb_up == true && IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)
-			{
-				memset(pHeaderProcTable, 0, len);
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::lan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::usb_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding WLAN to USB hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("WLAN to USB hdr proc ctx is added successfully. \n");
-				}
-			}
-
-			if(IPACM_Lan::is_cpe_up == true && IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == false)
-			{
-				memset(pHeaderProcTable, 0, len);
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::wlan_hdr_type, IPACM_Lan::lan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::cpe_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding WLAN to CPE hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("WLAN to CPE hdr proc ctx is added successfully. \n");
-
-				}
-			}
-		}
-	}
-
-	if(IPACM_Lan::lan_hdr_type != IPA_HDR_L2_NONE)
-	{
-		if(ipa_if_cate == LAN_IF || ipa_if_cate == ODU_IF)
-		{
-			if(IPACM_Iface::ipacmcfg->ipacm_odu_router_mode == false)
-			{
-				IPACMDBG_H("ODU is in bridge mode, do not set CPE to USB and USB to CPE hdr proc ctx.\n");
-				return res;
-			}
-			if(IPACM_Lan::is_cpe_up == true && IPACM_Lan::is_usb_up == true &&
-				IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == false && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == false)
-			{
-				memset(pHeaderProcTable, 0, len);
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::lan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::usb_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding CPE to USB hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("CPE to USB hdr proc ctx is added successfully. \n");
-				}
-
-				pHeaderProcTable->commit = 1;
-				pHeaderProcTable->num_proc_ctxs = 1;
-				pHeaderProcTable->proc_ctx[0].type = get_hdr_proc_type(IPACM_Lan::lan_hdr_type, IPACM_Lan::lan_hdr_type);
-				pHeaderProcTable->proc_ctx[0].hdr_hdl = IPACM_Lan::cpe_hdr_template_hdl;
-				if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
-				{
-					IPACMERR("Adding USB to CPE hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
-					IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid = true;
-					IPACMDBG_H("USB to CPE hdr proc ctx is added successfully. \n");
-				}
-
-				ipacm_cmd_q_data evt_data;
-				memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
-				ipacm_event_data_if_cat* cat;
-				cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
-				if(cat == NULL)
-				{
-					IPACMERR("Unable to allocate memory.\n");
-					return IPACM_FAILURE;
-				}
-				memset(cat, 0, sizeof(ipacm_event_data_if_cat));
-				cat->if_cat = ipa_if_cate;
-
-				evt_data.evt_data = cat;
-				evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT;
-				IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT\n");
-				IPACM_EvtDispatcher::PostEvt(&evt_data);
-			}
-		}
-	}
-	else
-	{
-		IPACMDBG_H("Not adding header processing context.\n");
-	}
-
-fail:
-	free(pHeaderProcTable);
-	return res;
-}
-
-ipa_hdr_proc_type IPACM_Lan::get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2)
+ipa_hdr_proc_type IPACM_Lan::eth_bridge_get_hdr_proc_type(ipa_hdr_l2_type t1, ipa_hdr_l2_type t2)
 {
 	if(t1 == IPA_HDR_L2_ETHERNET_II)
 	{
@@ -5413,637 +3580,6 @@
 	return IPA_HDR_PROC_NONE;
 }
 
-int IPACM_Lan::eth_bridge_install_cache_client_flt_rule(ipa_ip_type iptype)
-{
-	int i;
-
-	IPACMDBG_H("There are %d clients cached.\n",IPACM_Lan::eth_bridge_num_client);
-	for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-	{
-		if(ipa_if_num != IPACM_Lan::eth_bridge_client[i].ipa_if_num)
-		{
-			eth_bridge_add_client_flt_rule(IPACM_Lan::eth_bridge_client[i].mac, iptype,
-				IPACM_Lan::eth_bridge_client[i].ipa_if_cate);
-		}
-	}
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Lan::eth_bridge_add_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
-	if (tx_prop == NULL)
-	{
-		IPACMDBG_H("Tx prop is empty, not adding routing rule.\n");
-		return IPACM_SUCCESS;
-	}
-	if (mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x. src_iface: %d if_cat: %d \n",
-			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src, ipa_if_cate);
-
-	if (src == SRC_WLAN && ipa_if_cate == LAN_IF
-			&& IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == false)
-	{
-		IPACMDBG_H("WLAN to USB hdr proc ctx has not been set, don't add USB routing rule.\n");
-		return IPACM_FAILURE;
-	}
-	if (src == SRC_WLAN && ipa_if_cate == ODU_IF
-			&& IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == false)
-	{
-		IPACMDBG_H("WLAN to CPE hdr proc ctx has not been set, don't add CPE routing rule.\n");
-		return IPACM_FAILURE;
-	}
-
-	if (src == SRC_LAN && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == false
-			&& IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == false)
-	{
-		IPACMDBG_H("hdr proc ctx between USB and CPE has not been set, don't add routing rule.\n");
-		return IPACM_FAILURE;
-	}
-
-	if(iptype == IPA_IP_v4)
-	{
-		if((src == SRC_LAN && lan_client_rt_from_lan_info_count_v4 == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
-			|| (src == SRC_WLAN && lan_client_rt_from_wlan_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
-		{
-			IPACMDBG_H("client number has reached maximum.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		if ((src == SRC_LAN && lan_client_rt_from_lan_info_count_v6 == IPA_LAN_TO_LAN_MAX_LAN_CLIENT)
-			|| (src == SRC_WLAN && lan_client_rt_from_wlan_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
-		{
-			IPACMDBG_H("client number has reached maximum.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	int i, len, res = IPACM_SUCCESS;
-	struct ipa_ioc_add_rt_rule* rt_rule_table = NULL;
-	struct ipa_rt_rule_add rt_rule;
-	int position, num_rt_rule;
-
-	if (src == SRC_LAN)
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			for (i=0; i<lan_client_rt_from_lan_info_count_v4; i++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->mac));
-		}
-		else
-		{
-			for (i=0; i<lan_client_rt_from_lan_info_count_v6; i++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->mac));
-		}
-	}
-	else
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			for (i=0; i<lan_client_rt_from_wlan_info_count_v4; i++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->mac));
-		}
-		else
-		{
-			for (i=0; i<lan_client_rt_from_wlan_info_count_v6; i++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->mac));
-		}
-	}
-
-	if (iptype == IPA_IP_v4)
-	{
-		num_rt_rule = each_client_rt_rule_count_v4;
-	}
-	else
-	{
-		num_rt_rule = each_client_rt_rule_count_v6;
-	}
-
-	len = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);
-	rt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);
-	if (rt_rule_table == NULL)
-	{
-		IPACMERR("Failed to allocate memory.\n");
-		return IPACM_FAILURE;
-	}
-	memset(rt_rule_table, 0, len);
-
-	rt_rule_table->commit = 1;
-	rt_rule_table->ip = iptype;
-	rt_rule_table->num_rules = num_rt_rule;
-	if (src == SRC_LAN)
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-		else
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-	}
-	else
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-		else
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-	}
-	rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-	memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
-	rt_rule.at_rear = false;
-	rt_rule.status = -1;
-	rt_rule.rt_rule_hdl = -1;
-#ifdef FEATURE_IPA_V3
-	rt_rule.rule.hashable = true;
-#endif
-	rt_rule.rule.hdr_hdl = 0;
-	if(src == SRC_LAN)
-	{
-		if (ipa_if_cate == LAN_IF)
-		{
-			rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl;
-		}
-		else if (ipa_if_cate == ODU_IF)
-		{
-			rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl;
-		}
-		else
-		{
-			IPACMERR("Iface category is not expected.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-	}
-	else
-	{
-		if(ipa_if_cate == LAN_IF)
-		{
-			rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl;
-		}
-		else if(ipa_if_cate == ODU_IF)
-		{
-			rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl;
-		}
-		else
-		{
-			IPACMERR("Iface category is not expected.\n");
-			res = IPACM_FAILURE;
-			goto fail;
-		}
-	}
-	position = 0;
-	for(i=0; i<iface_query->num_tx_props; i++)
-	{
-		if(tx_prop->tx[i].ip == iptype)
-		{
-			if(position >= num_rt_rule)
-			{
-				IPACMERR("Number of routing rules already exceeds limit.\n");
-				res = IPACM_FAILURE;
-				goto fail;
-			}
-			rt_rule.rule.dst = tx_prop->tx[i].dst_pipe;
-
-			memcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));
-			if(src == SRC_WLAN)	//src is WLAN means packet is from WLAN
-			{
-				if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			else	//packet is from LAN
-			{
-				if(IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			memcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));
-			memset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));
-
-			memcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));
-			position++;
-		}
-	}
-	if(false == m_routing.AddRoutingRule(rt_rule_table))
-	{
-		IPACMERR("Routing rule addition failed!\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-	else
-	{
-		if(src == SRC_LAN)
-		{
-			for(i=0; i<num_rt_rule; i++)
-			{
-				if(iptype == IPA_IP_v4)
-				{
-					eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-				else
-				{
-					eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-			}
-			if(iptype == IPA_IP_v4)
-			{
-				lan_client_rt_from_lan_info_count_v4++;
-				IPACMDBG_H("Now the number of IPv4 rt rule on lan-lan rt table is %d.\n", lan_client_rt_from_lan_info_count_v4);
-			}
-			else
-			{
-				lan_client_rt_from_lan_info_count_v6++;
-				IPACMDBG_H("Now the number of IPv6 rt rule on lan-lan rt table is %d.\n", lan_client_rt_from_lan_info_count_v6);
-			}
-		}
-		else
-		{
-			for(i=0; i<num_rt_rule; i++)
-			{
-				if(iptype == IPA_IP_v4)
-				{
-					eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-				else
-				{
-					eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-			}
-			if(iptype == IPA_IP_v4)
-			{
-				lan_client_rt_from_wlan_info_count_v4++;
-				IPACMDBG_H("Now the number of IPv4 rt rule on lan-wlan rt table is %d.\n", lan_client_rt_from_wlan_info_count_v4);
-			}
-			else
-			{
-				lan_client_rt_from_wlan_info_count_v6++;
-				IPACMDBG_H("Now the number of IPv6 rt rule on lan-wlan rt table is %d.\n", lan_client_rt_from_wlan_info_count_v6);
-			}
-		}
-	}
-
-fail:
-	if(rt_rule_table != NULL)
-	{
-		free(rt_rule_table);
-	}
-	return res;
-}
-
-int IPACM_Lan::eth_bridge_del_lan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src)
-{
-	if(tx_prop == NULL)
-	{
-		IPACMDBG_H("Tx prop is empty, not deleting routing rule.\n");
-		return IPACM_SUCCESS;
-	}
-	if(mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x. src_iface: %d \n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src);
-
-	int i, position;
-
-	/* first delete the rt rules from IPv4 rt table*/
-	if(src == SRC_LAN)
-	{
-		for(i=0; i<lan_client_rt_from_lan_info_count_v4; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == lan_client_rt_from_lan_info_count_v4)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		for(i=0; i<lan_client_rt_from_wlan_info_count_v4; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == lan_client_rt_from_wlan_info_count_v4)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	for(i=0; i<each_client_rt_rule_count_v4; i++)
-	{
-		if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v4)->rt_rule_hdl[i], IPA_IP_v4) == false)
-		{
-			IPACMERR("Failed to delete routing rule %d.\n", i);
-			return IPACM_FAILURE;
-		}
-	}
-
-	if(src == SRC_LAN)
-	{
-		for(i=position+1; i<lan_client_rt_from_lan_info_count_v4; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
-		lan_client_rt_from_lan_info_count_v4--;
-		IPACMDBG_H("Now the number of IPv4 rt rule from lan info is %d.\n", lan_client_rt_from_lan_info_count_v4);
-	}
-	else
-	{
-		for(i=position+1; i<lan_client_rt_from_wlan_info_count_v4; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
-		lan_client_rt_from_wlan_info_count_v4--;
-		IPACMDBG_H("Now the number of IPv4 rt rule from wlan info is %d.\n", lan_client_rt_from_wlan_info_count_v4);
-	}
-
-	/*delete rt rules from IPv6 rt table */
-	if(src == SRC_LAN)
-	{
-		for(i=0; i<lan_client_rt_from_lan_info_count_v6; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == lan_client_rt_from_lan_info_count_v6)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		for(i=0; i<lan_client_rt_from_wlan_info_count_v6; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == lan_client_rt_from_wlan_info_count_v6)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	for(i=0; i<each_client_rt_rule_count_v6; i++)
-	{
-		if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v6)->rt_rule_hdl[i], IPA_IP_v6) == false)
-		{
-			IPACMERR("Failed to delete routing rule %d.\n", i);
-			return IPACM_FAILURE;
-		}
-	}
-
-	if(src == SRC_LAN)
-	{
-		for(i=position+1; i<lan_client_rt_from_lan_info_count_v6; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_lan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
-		lan_client_rt_from_lan_info_count_v6--;
-		IPACMDBG_H("Now the number of IPv6 rt rule from lan info is %d.\n", lan_client_rt_from_lan_info_count_v6);
-	}
-	else
-	{
-		for(i=position+1; i<lan_client_rt_from_wlan_info_count_v6; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(lan_client_rt_from_wlan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
-		lan_client_rt_from_wlan_info_count_v6--;
-		IPACMDBG_H("Now the number of IPv6 rt rule from wlan info is %d.\n", lan_client_rt_from_wlan_info_count_v6);
-	}
-
-	return IPACM_SUCCESS;
-}
-
-eth_bridge_client_rt_info* IPACM_Lan::eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
-	char* result;
-
-	if(src == SRC_LAN)
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			result = (char *)eth_bridge_lan_client_rt_from_lan_info_v4 + index * client_rt_info_size_v4;
-		}
-		else
-		{
-			result = (char *)eth_bridge_lan_client_rt_from_lan_info_v6 + index * client_rt_info_size_v6;
-		}
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			result = (char *)eth_bridge_lan_client_rt_from_wlan_info_v4 + index * client_rt_info_size_v4;
-		}
-		else
-		{
-			result = (char *)eth_bridge_lan_client_rt_from_wlan_info_v6 + index * client_rt_info_size_v6;
-		}
-	}
-	return (eth_bridge_client_rt_info*)result;
-}
-
-
-void IPACM_Lan::eth_bridge_add_client(uint8_t* mac)
-{
-	int i;
-	int num_client = IPACM_Lan::eth_bridge_num_client;
-	if(num_client == IPA_LAN_TO_LAN_MAX_CLIENT)
-	{
-		IPACMDBG_H("Client table is already full.\n");
-		return;
-	}
-
-	if(mac == NULL)
-	{
-		IPACMERR("Mac address is empty.\n");
-		return;
-	}
-
-	for(i=0; i<num_client; i++)
-	{
-		if(memcmp(IPACM_Lan::eth_bridge_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_client[i].mac)) == 0)
-		{
-			IPACMDBG_H("The client mac has been added before at position %d.\n", i);
-			return;
-		}
-	}
-
-	memcpy(IPACM_Lan::eth_bridge_client[num_client].mac, mac, sizeof(IPACM_Lan::eth_bridge_client[num_client].mac));
-	IPACM_Lan::eth_bridge_client[num_client].ipa_if_num = ipa_if_num;
-	IPACM_Lan::eth_bridge_client[num_client].ipa_if_cate = ipa_if_cate;
-	IPACM_Lan::eth_bridge_num_client++;
-	IPACMDBG_H("Now total num of clients is %d\n", IPACM_Lan::eth_bridge_num_client);
-	return;
-}
-
-void IPACM_Lan::eth_bridge_del_client(uint8_t* mac)
-{
-	int i, j, mem_size;
-	int num_client = IPACM_Lan::eth_bridge_num_client;
-	if(mac == NULL)
-	{
-		IPACMERR("Mac address is empty.\n");
-		return;
-	}
-
-	for(i=0; i<num_client; i++)
-	{
-		if(memcmp(IPACM_Lan::eth_bridge_client[i].mac, mac, sizeof(IPACM_Lan::eth_bridge_client[i].mac)) == 0)
-		{
-			IPACMDBG_H("Found LAN client at position %d.\n", i);
-			break;
-		}
-	}
-
-	if(i == num_client)
-	{
-		IPACMDBG_H("Not finding the LAN client.\n");
-		return;
-	}
-
-	mem_size = sizeof(eth_bridge_subnet_client_info);
-	for(j=i+1; j<num_client; j++)
-	{
-		memcpy(&IPACM_Lan::eth_bridge_client[j-1], &IPACM_Lan::eth_bridge_client[j], mem_size);
-	}
-	IPACM_Lan::eth_bridge_num_client--;
-	IPACMDBG_H("Now total num of clients is %d\n", IPACM_Lan::eth_bridge_num_client);
-	return;
-}
-
-int IPACM_Lan::eth_bridge_remove_all_client_flt_rule(ipa_ip_type iptype)
-{
-	int i, j;
-	uint32_t temp_eth_bridge_flt_rule[IPA_LAN_TO_LAN_MAX_CLIENT];
-
-	if(rx_prop == NULL)
-	{
-		IPACMDBG_H("No rx property, return.\n");
-		return IPACM_SUCCESS;
-	}
-
-	i = 0;
-	j = 0;
-	while(i<client_flt_info_count && j<IPA_LAN_TO_LAN_MAX_CLIENT)
-	{
-		if(iptype == IPA_IP_v4 && eth_bridge_client_flt_info[i].flt_rule_set_v4)
-		{
-			temp_eth_bridge_flt_rule[j] = eth_bridge_client_flt_info[i].flt_rule_hdl_v4;
-			eth_bridge_client_flt_info[i].flt_rule_set_v4 = false;
-			j++;
-		}
-		if(iptype == IPA_IP_v6 && eth_bridge_client_flt_info[i].flt_rule_set_v6)
-		{
-			temp_eth_bridge_flt_rule[j] = eth_bridge_client_flt_info[i].flt_rule_hdl_v6;
-			eth_bridge_client_flt_info[i].flt_rule_set_v6 = false;
-			j++;
-		}
-
-		/* if both IPv4/IPv6 flt rules have been removed, remove the client info from the array */
-		if(!eth_bridge_client_flt_info[i].flt_rule_set_v4 || !eth_bridge_client_flt_info[i].flt_rule_set_v6)
-		{
-			memcpy(&(eth_bridge_client_flt_info[i]), &(eth_bridge_client_flt_info[client_flt_info_count-1]), sizeof(eth_bridge_subnet_client_flt_info));
-			memset(&(eth_bridge_client_flt_info[client_flt_info_count-1]), 0, sizeof(eth_bridge_subnet_client_flt_info));
-			client_flt_info_count--;
-			IPACMDBG_H("Now client flt info count: %d\n", client_flt_info_count);
-		}
-		else
-		{
-			i++;
-		}
-	}
-	if (m_filtering.DeleteFilteringHdls(temp_eth_bridge_flt_rule, iptype, j) == false)
-	{
-		IPACMERR("Error Deleting Filtering Rule, aborting...\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, iptype, j);
-	return IPACM_SUCCESS;
-}
-
 int IPACM_Lan::eth_bridge_get_hdr_template_hdl(uint32_t* hdr_hdl)
 {
 	if(hdr_hdl == NULL)
@@ -6066,205 +3602,6 @@
 	return IPACM_SUCCESS;
 }
 
-int IPACM_Lan::del_hdr_proc_ctx()
-{
-	if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-	{
-		if((ipa_if_cate == WLAN_IF)
-			|| (IPACM_Lan::is_usb_up == false && IPACM_Lan::is_cpe_up == false))
-		{
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete usb to wlan hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid = false;
-
-			ipacm_cmd_q_data evt_data;
-			memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
-			ipacm_event_data_if_cat* cat;
-			cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
-			if(cat == NULL)
-			{
-				IPACMERR("Unable to allocate memory.\n");
-				return IPACM_FAILURE;
-			}
-			memset(cat, 0, sizeof(ipacm_event_data_if_cat));
-			cat->if_cat = ipa_if_cate;
-
-			evt_data.evt_data = cat;
-			evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT;
-			IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT\n");
-			IPACM_EvtDispatcher::PostEvt(&evt_data);
-		}
-	}
-
-	if(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid == true)
-	{
-		if(ipa_if_cate == WLAN_IF || IPACM_Lan::is_usb_up == false)
-		{
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_usb_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete wlan to usb hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::wlan_to_usb_hdr_proc_ctx.valid = false;
-		}
-	}
-
-	if(IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid == true)
-	{
-		if(ipa_if_cate == WLAN_IF || IPACM_Lan::is_cpe_up == false)
-		{
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete wlan to cpe hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::wlan_to_cpe_hdr_proc_ctx.valid = false;
-		}
-	}
-
-	if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-	{
-		if(ipa_if_cate == WLAN_IF)
-		{
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete wlan to wlan hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid = false;
-		}
-	}
-
-	if(IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid == true && IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid == true)
-	{
-		if(ipa_if_cate == LAN_IF || ipa_if_cate == ODU_IF)
-		{
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::cpe_to_usb_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete cpe to usb hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::cpe_to_usb_hdr_proc_ctx.valid = false;
-
-			if(m_header.DeleteHeaderProcCtx(IPACM_Lan::usb_to_cpe_hdr_proc_ctx.proc_ctx_hdl) == false)
-			{
-				IPACMERR("Failed to delete usb to cpe hdr proc ctx.\n");
-				return IPACM_FAILURE;
-			}
-			IPACM_Lan::usb_to_cpe_hdr_proc_ctx.valid = false;
-
-			ipacm_cmd_q_data evt_data;
-			memset(&evt_data, 0, sizeof(ipacm_cmd_q_data));
-
-			ipacm_event_data_if_cat* cat;
-			cat = (ipacm_event_data_if_cat*)malloc(sizeof(ipacm_event_data_if_cat));
-			if(cat == NULL)
-			{
-				IPACMERR("Unable to allocate memory.\n");
-				return IPACM_FAILURE;
-			}
-			memset(cat, 0, sizeof(ipacm_event_data_if_cat));
-			cat->if_cat = ipa_if_cate;
-
-			evt_data.evt_data = cat;
-			evt_data.event = IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT;
-			IPACMDBG_H("Posting event IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT\n");
-			IPACM_EvtDispatcher::PostEvt(&evt_data);
-		}
-	}
-	return IPACM_SUCCESS;
-}
-
-bool IPACM_Lan::eth_bridge_is_lan_client(int ipa_if_cate)
-{
-	if(ipa_if_cate == ODU_IF || ipa_if_cate == LAN_IF)
-	{
-		return true;
-	}
-	else
-	{
-		return false;
-	}
-}
-
-void IPACM_Lan::eth_bridge_get_rt_tbl_name(ipa_ip_type iptype, struct ipa_ioc_get_rt_tbl *rt_tbl, int dest_if_cate)
-{
-	if(iptype == IPA_IP_v4) //IPv4 case
-	{
-		if(eth_bridge_is_lan_client(dest_if_cate) != true) //dest is WLAN client
-		{
-			if(eth_bridge_is_lan_client(ipa_if_cate) == true) //self is LAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name,
-						sizeof(rt_tbl->name));
-			}
-			else //self is WLAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name,
-						sizeof(rt_tbl->name));
-			}
-		}
-		else //dest is LAN client
-		{
-			if(eth_bridge_is_lan_client(ipa_if_cate) == true) //self is LAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v4.name,
-						sizeof(rt_tbl->name));
-			}
-			else //self is WLAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name,
-						sizeof(rt_tbl->name));
-			}
-		}
-	}
-	else //IPv6 case
-	{
-		if(eth_bridge_is_lan_client(dest_if_cate) != true) //dest is WLAN client
-		{
-			if(eth_bridge_is_lan_client(ipa_if_cate) == true) //self is LAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name,
-						sizeof(rt_tbl->name));
-			}
-			else //self is WLAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name,
-						sizeof(rt_tbl->name));
-			}
-		}
-		else //dest is LAN client
-		{
-			if(eth_bridge_is_lan_client(ipa_if_cate) == true) //self is LAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_lan_v6.name,
-						sizeof(rt_tbl->name));
-			}
-			else //self is WLAN client
-			{
-				strlcpy(rt_tbl->name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name,
-						sizeof(rt_tbl->name));
-			}
-		}
-	}
-}
-
-enum ipa_hdr_l2_type IPACM_Lan::eth_bridge_get_l2_hdr_type()
-{
-	if(eth_bridge_is_lan_client(ipa_if_cate))
-	{
-		return IPACM_Lan::lan_hdr_type;
-	}
-	else
-	{
-		return IPACM_Lan::wlan_hdr_type;
-	}
-}
-
 int IPACM_Lan::handle_cradle_wan_mode_switch(bool is_wan_bridge_mode)
 {
 	struct ipa_flt_rule_mdfy flt_rule_entry;
@@ -6512,3 +3849,365 @@
 	close(fd_wwan_ioctl);
 	return ret;
 }
+
+/* mac address has to be provided for client related events */
+void IPACM_Lan::eth_bridge_post_event(ipa_cm_event_id evt, ipa_ip_type iptype, uint8_t *mac)
+{
+	ipacm_cmd_q_data eth_bridge_evt;
+	ipacm_event_eth_bridge *evt_data;
+
+	evt_data = (ipacm_event_eth_bridge*)malloc(sizeof(ipacm_event_eth_bridge));
+	if(evt_data == NULL)
+	{
+		IPACMERR("Failed to allocate memory.\n");
+		return;
+	}
+	memset(evt_data, 0, sizeof(ipacm_event_eth_bridge));
+
+	evt_data->p_iface = this;
+	evt_data->iptype = iptype;
+	if(mac)
+	{
+		IPACMDBG_H("Client mac: 0x%02x%02x%02x%02x%02x%02x \n",
+			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+		memcpy(evt_data->mac_addr, mac, sizeof(evt_data->mac_addr));
+	}
+
+	memset(&eth_bridge_evt, 0, sizeof(ipacm_cmd_q_data));
+	eth_bridge_evt.evt_data = (void*)evt_data;
+	eth_bridge_evt.event = evt;
+
+	IPACMDBG_H("Posting event %s\n",
+		IPACM_Iface::ipacmcfg->getEventName(evt));
+	IPACM_EvtDispatcher::PostEvt(&eth_bridge_evt);
+}
+
+/* add header processing context and return handle to lan2lan controller */
+int IPACM_Lan::eth_bridge_add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_hdr_type, uint32_t *hdl)
+{
+	int len, res = IPACM_SUCCESS;
+	uint32_t hdr_template;
+	ipa_ioc_add_hdr_proc_ctx* pHeaderProcTable = NULL;
+
+	len = sizeof(struct ipa_ioc_add_hdr_proc_ctx) + sizeof(struct ipa_hdr_proc_ctx_add);
+	pHeaderProcTable = (ipa_ioc_add_hdr_proc_ctx*)malloc(len);
+	if(pHeaderProcTable == NULL)
+	{
+		IPACMERR("Cannot allocate header processing context table.\n");
+		return IPACM_FAILURE;
+	}
+
+	memset(pHeaderProcTable, 0, len);
+	pHeaderProcTable->commit = 1;
+	pHeaderProcTable->num_proc_ctxs = 1;
+	pHeaderProcTable->proc_ctx[0].type = eth_bridge_get_hdr_proc_type(peer_l2_hdr_type, tx_prop->tx[0].hdr_l2_type);
+	eth_bridge_get_hdr_template_hdl(&hdr_template);
+	pHeaderProcTable->proc_ctx[0].hdr_hdl = hdr_template;
+	if (m_header.AddHeaderProcCtx(pHeaderProcTable) == false)
+	{
+		IPACMERR("Adding hdr proc ctx failed with status: %d\n", pHeaderProcTable->proc_ctx[0].status);
+		res = IPACM_FAILURE;
+		goto end;
+	}
+
+	*hdl = pHeaderProcTable->proc_ctx[0].proc_ctx_hdl;
+
+end:
+	free(pHeaderProcTable);
+	return res;
+}
+
+/* add routing rule and return handle to lan2lan controller */
+int IPACM_Lan::eth_bridge_add_rt_rule(uint8_t *mac, char *rt_tbl_name, uint32_t hdr_proc_ctx_hdl,
+		ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int *rt_rule_count)
+{
+	int i, len, res = IPACM_SUCCESS;
+	struct ipa_ioc_add_rt_rule* rt_rule_table = NULL;
+	struct ipa_rt_rule_add rt_rule;
+	int position, num_rt_rule;
+
+	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n",
+			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+	num_rt_rule = each_client_rt_rule_count[iptype];
+
+	len = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);
+	rt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);
+	if (rt_rule_table == NULL)
+	{
+		IPACMERR("Failed to allocate memory.\n");
+		return IPACM_FAILURE;
+	}
+	memset(rt_rule_table, 0, len);
+
+	rt_rule_table->commit = 1;
+	rt_rule_table->ip = iptype;
+	rt_rule_table->num_rules = num_rt_rule;
+	strlcpy(rt_rule_table->rt_tbl_name, rt_tbl_name, sizeof(rt_rule_table->rt_tbl_name));
+	rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = 0;
+
+	memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
+	rt_rule.at_rear = false;
+	rt_rule.status = -1;
+	rt_rule.rt_rule_hdl = -1;
+#ifdef FEATURE_IPA_V3
+	rt_rule.rule.hashable = true;
+#endif
+	rt_rule.rule.hdr_hdl = 0;
+	rt_rule.rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl;
+
+	position = 0;
+	for(i=0; i<iface_query->num_tx_props; i++)
+	{
+		if(tx_prop->tx[i].ip == iptype)
+		{
+			if(position >= num_rt_rule || position >= MAX_NUM_PROP)
+			{
+				IPACMERR("Number of routing rules already exceeds limit.\n");
+				res = IPACM_FAILURE;
+				goto end;
+			}
+
+			if(ipa_if_cate == WLAN_IF && IPACM_Iface::ipacmcfg->isMCC_Mode)
+			{
+				IPACMDBG_H("In WLAN MCC mode, use alt dst pipe: %d\n",
+						tx_prop->tx[i].alt_dst_pipe);
+				rt_rule.rule.dst = tx_prop->tx[i].alt_dst_pipe;
+			}
+			else
+			{
+				IPACMDBG_H("It is not WLAN MCC mode, use dst pipe: %d\n",
+						tx_prop->tx[i].dst_pipe);
+				rt_rule.rule.dst = tx_prop->tx[i].dst_pipe;
+			}
+
+			memcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));
+			if(peer_l2_hdr_type == IPA_HDR_L2_ETHERNET_II)
+				rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+			else
+				rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+			memcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));
+			memset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));
+
+			memcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));
+			position++;
+		}
+	}
+	if(false == m_routing.AddRoutingRule(rt_rule_table))
+	{
+		IPACMERR("Routing rule addition failed!\n");
+		res = IPACM_FAILURE;
+		goto end;
+	}
+	else
+	{
+		*rt_rule_count = position;
+		for(i=0; i<position; i++)
+			rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
+	}
+
+end:
+	free(rt_rule_table);
+	return res;
+}
+
+/* modify routing rule*/
+int IPACM_Lan::eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl,
+		ipa_hdr_l2_type peer_l2_hdr_type, ipa_ip_type iptype, uint32_t *rt_rule_hdl, int rt_rule_count)
+{
+	struct ipa_ioc_mdfy_rt_rule *rt_rule = NULL;
+	struct ipa_rt_rule_mdfy *rt_rule_entry;
+	int len, index, res = IPACM_SUCCESS;
+
+	if(tx_prop == NULL)
+	{
+		IPACMDBG_H("No tx properties \n");
+		return IPACM_FAILURE;
+	}
+
+	if(ipa_if_cate != WLAN_IF)
+	{
+		IPACMDBG_H("This is not WLAN IF, no need to modify rt rule.\n");
+		return IPACM_SUCCESS;
+	}
+
+	IPACMDBG_H("Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n",
+			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+	len = sizeof(struct ipa_ioc_mdfy_rt_rule) + rt_rule_count * sizeof(struct ipa_rt_rule_mdfy);
+	rt_rule = (struct ipa_ioc_mdfy_rt_rule *)malloc(len);
+	if(rt_rule == NULL)
+	{
+		IPACMERR("Unable to allocate memory for modify rt rule\n");
+		return IPACM_FAILURE;
+	}
+	memset(rt_rule, 0, len);
+
+	rt_rule->commit = 1;
+	rt_rule->num_rules = 0;
+	rt_rule->ip = iptype;
+
+	for (index = 0; index < tx_prop->num_tx_props; index++)
+	{
+		if (tx_prop->tx[index].ip == iptype)
+		{
+			if (rt_rule->num_rules >= rt_rule_count)
+			{
+				IPACMERR("Number of routing rules exceeds limit.\n");
+				res = IPACM_FAILURE;
+				goto end;
+			}
+
+			rt_rule_entry = &rt_rule->rules[rt_rule->num_rules];
+
+			if (IPACM_Iface::ipacmcfg->isMCC_Mode)
+			{
+				IPACMDBG_H("In WLAN MCC mode, use alt dst pipe: %d\n",
+						tx_prop->tx[index].alt_dst_pipe);
+				rt_rule_entry->rule.dst = tx_prop->tx[index].alt_dst_pipe;
+			}
+			else
+			{
+				IPACMDBG_H("In WLAN SCC mode, use dst pipe: %d\n",
+						tx_prop->tx[index].dst_pipe);
+				rt_rule_entry->rule.dst = tx_prop->tx[index].dst_pipe;
+			}
+
+			rt_rule_entry->rule.hdr_hdl = 0;
+			rt_rule_entry->rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl;
+#ifdef FEATURE_IPA_V3
+			rt_rule_entry->rule.hashable = true;
+#endif
+			memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[index].attrib,
+					sizeof(rt_rule_entry->rule.attrib));
+			if(peer_l2_hdr_type == IPA_HDR_L2_ETHERNET_II)
+				rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+			else
+				rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+			memcpy(rt_rule_entry->rule.attrib.dst_mac_addr, mac,
+					sizeof(rt_rule_entry->rule.attrib.dst_mac_addr));
+			memset(rt_rule_entry->rule.attrib.dst_mac_addr_mask, 0xFF,
+					sizeof(rt_rule_entry->rule.attrib.dst_mac_addr_mask));
+
+			rt_rule_entry->rt_rule_hdl = rt_rule_hdl[rt_rule->num_rules];
+			rt_rule->num_rules++;
+		}
+	}
+
+	if(m_routing.ModifyRoutingRule(rt_rule) == false)
+	{
+		IPACMERR("Failed to modify routing rules.\n");
+		res = IPACM_FAILURE;
+		goto end;
+	}
+	if(m_routing.Commit(iptype) == false)
+	{
+		IPACMERR("Failed to commit routing rules.\n");
+		res = IPACM_FAILURE;
+		goto end;
+	}
+	IPACMDBG("Modified routing rules successfully.\n");
+
+end:
+	free(rt_rule);
+	return res;
+}
+
+int IPACM_Lan::eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl)
+{
+	int len, res = IPACM_SUCCESS;
+	struct ipa_flt_rule_add flt_rule_entry;
+	struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL;
+
+#ifdef FEATURE_IPA_V3
+	if (rx_prop == NULL || tx_prop == NULL)
+	{
+		IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name);
+		return IPACM_FAILURE;
+	}
+
+	IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+	len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add);
+	pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len);
+	if (!pFilteringTable)
+	{
+		IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n");
+		return IPACM_FAILURE;
+	}
+	memset(pFilteringTable, 0, len);
+
+	/* add mac based rule*/
+	pFilteringTable->commit = 1;
+	pFilteringTable->ep = rx_prop->rx[0].src_pipe;
+	pFilteringTable->ip = iptype;
+	pFilteringTable->num_rules = 1;
+	pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype];
+
+	memset(&flt_rule_entry, 0, sizeof(flt_rule_entry));
+	flt_rule_entry.at_rear = 1;
+
+	flt_rule_entry.rule.retain_hdr = 0;
+	flt_rule_entry.rule.to_uc = 0;
+	flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING;
+	flt_rule_entry.rule.eq_attrib_type = 0;
+	flt_rule_entry.rule.rt_tbl_hdl = rt_tbl_hdl;
+
+	memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
+	if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II)
+	{
+		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
+	}
+	else
+	{
+		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
+	}
+
+	memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr));
+	memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask));
+
+	memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry));
+	if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable))
+	{
+		IPACMERR("Failed to add client filtering rules.\n");
+		res = IPACM_FAILURE;
+		goto end;
+	}
+	*flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl;
+
+end:
+	free(pFilteringTable);
+#endif
+	return res;
+}
+
+int IPACM_Lan::eth_bridge_del_flt_rule(uint32_t flt_rule_hdl, ipa_ip_type iptype)
+{
+	if(m_filtering.DeleteFilteringHdls(&flt_rule_hdl, iptype, 1) == false)
+	{
+		IPACMERR("Failed to delete the client specific flt rule.\n");
+		return IPACM_FAILURE;
+	}
+	return IPACM_SUCCESS;
+}
+
+int IPACM_Lan::eth_bridge_del_rt_rule(uint32_t rt_rule_hdl, ipa_ip_type iptype)
+{
+	if(m_routing.DeleteRoutingHdl(rt_rule_hdl, iptype) == false)
+	{
+		IPACMERR("Failed to delete routing rule.\n");
+		return IPACM_FAILURE;
+	}
+	return IPACM_SUCCESS;
+}
+
+/* delete header processing context */
+int IPACM_Lan::eth_bridge_del_hdr_proc_ctx(uint32_t hdr_proc_ctx_hdl)
+{
+	if(m_header.DeleteHeaderProcCtx(hdr_proc_ctx_hdl) == false)
+	{
+		IPACMERR("Failed to delete hdr proc ctx.\n");
+		return IPACM_FAILURE;
+	}
+	return IPACM_SUCCESS;
+}
diff --git a/ipacm/src/IPACM_LanToLan.cpp b/ipacm/src/IPACM_LanToLan.cpp
index 0abfc42..be33acd 100644
--- a/ipacm/src/IPACM_LanToLan.cpp
+++ b/ipacm/src/IPACM_LanToLan.cpp
@@ -39,1567 +39,1215 @@
 */
 
 #include <stdlib.h>
-#include <assert.h>
 #include "IPACM_LanToLan.h"
 #include "IPACM_Wlan.h"
 
-#define ipv6_multicast_addr 0xff000000
-#define ipv6_multicast_mask 0xff000000
+#define __stringify(x...) #x
 
-#define max_cache_connection 20
+const char *ipa_l2_hdr_type[] = {
+	__stringify(NONE),
+	__stringify(ETH_II),
+	__stringify(802_3),
+	__stringify(L2_MAX)
+};
 
-IPACM_LanToLan* IPACM_LanToLan::p_instance = NULL;
+IPACM_LanToLan_Iface::IPACM_LanToLan_Iface(IPACM_Lan *p_iface)
+{
+	int i;
+
+	m_p_iface = p_iface;
+	memset(m_is_ip_addr_assigned, 0, sizeof(m_is_ip_addr_assigned));
+	m_support_inter_iface_offload = true;
+	m_support_intra_iface_offload = false;
+	for(i = 0; i < IPA_HDR_L2_MAX; i++)
+	{
+		ref_cnt_peer_l2_hdr_type[i] = 0;
+		hdr_proc_ctx_for_inter_interface[i] = 0;
+	}
+	hdr_proc_ctx_for_intra_interface = 0;
+
+	if(p_iface->ipa_if_cate == WLAN_IF)
+	{
+		IPACMDBG_H("Interface %s is WLAN interface.\n", p_iface->dev_name);
+		m_support_intra_iface_offload = true;
+		if( ((IPACM_Wlan*)p_iface)->is_guest_ap() )
+		{
+			IPACMDBG_H("Interface %s is guest AP.\n", p_iface->dev_name);
+			m_support_inter_iface_offload = false;
+		}
+	}
+	return;
+}
+
+IPACM_LanToLan_Iface::~IPACM_LanToLan_Iface()
+{
+}
 
 IPACM_LanToLan::IPACM_LanToLan()
 {
-	num_offload_pair_v4_ = 0;
-	num_offload_pair_v6_ = 0;
-	client_info_v4_.reserve(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_LAN_CLIENT);
-	client_info_v6_.reserve(3*(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT + IPA_LAN_TO_LAN_MAX_LAN_CLIENT));
-	p_instance = this;
+	IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_IFACE_UP, this);
+	IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_IFACE_DOWN, this);
+	IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_ADD, this);
+	IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_CLIENT_DEL, this);
+	IPACM_EvtDispatcher::registr(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, this);
 
-	IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_ACTIVE, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_INACTIVE, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_DISCONNECT, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_POWER_SAVE, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_CLIENT_POWER_RECOVER, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_TO_LAN_NEW_CONNECTION, this);
-	IPACM_EvtDispatcher::registr(IPA_LAN_TO_LAN_DEL_CONNECTION, this);
 	return;
 }
 
 IPACM_LanToLan::~IPACM_LanToLan()
 {
-	client_table_v4::iterator it_v4;
-	for(it_v4 = client_info_v4_.begin(); it_v4 != client_info_v4_.end(); it_v4++)
-	{
-		turnoff_offload_links(IPA_IP_v4, &(it_v4->second));
-		clear_peer_list(&(it_v4->second));
-	}
-	client_info_v4_.clear();
-	IPACMDBG("Clear IPv4 hash table in Lan2Lan distructor.\n");
-
-	client_table_v6::iterator it_v6;
-	for(it_v6 = client_info_v6_.begin(); it_v6 != client_info_v6_.end(); it_v6++)
-	{
-		turnoff_offload_links(IPA_IP_v6, &(it_v6->second));
-		clear_peer_list(&(it_v6->second));
-	}
-	client_info_v6_.clear();
-	IPACMDBG("Clear IPv6 hash table in Lan2Lan distructor.\n");
-
+	IPACMDBG_DMESG("WARNING: UNEXPECTEDLY KILL LAN2LAN CONTROLLER!\n");
 	return;
 }
 
 void IPACM_LanToLan::event_callback(ipa_cm_event_id event, void* param)
 {
+	ipacm_event_eth_bridge *data = (ipacm_event_eth_bridge*)param;
+	IPACMDBG_H("Get %s event.\n", IPACM_Iface::ipacmcfg->getEventName(event));
+
 	switch(event)
 	{
-		case IPA_LAN_CLIENT_ACTIVE:
+		case IPA_ETH_BRIDGE_IFACE_UP:
 		{
-			IPACMDBG_H("Get IPA_LAN_CLIENT_ACTIVE event.\n");
-			ipacm_event_lan_client* data = (ipacm_event_lan_client*)param;
-			handle_client_active(data);
+			handle_iface_up(data);
 			break;
 		}
 
-		case IPA_LAN_CLIENT_INACTIVE:
+		case IPA_ETH_BRIDGE_IFACE_DOWN:
 		{
-			IPACMDBG_H("Get IPA_LAN_CLIENT_INACTIVE event.\n");
-			ipacm_event_lan_client* data = (ipacm_event_lan_client*)param;
-			handle_client_inactive(data);
+			handle_iface_down(data);
 			break;
 		}
 
-		case IPA_LAN_CLIENT_DISCONNECT:
+		case IPA_ETH_BRIDGE_CLIENT_ADD:
 		{
-			IPACMDBG_H("Get IPA_LAN_CLIENT_DISCONNECT event.\n");
-			ipacm_event_lan_client* data = (ipacm_event_lan_client*)param;
-			handle_client_disconnect(data);
+			handle_client_add(data);
 			break;
 		}
 
-		case IPA_LAN_TO_LAN_NEW_CONNECTION:
+		case IPA_ETH_BRIDGE_CLIENT_DEL:
 		{
-			IPACMDBG_H("Get IPA_LAN_TO_LAN_NEW_CONNECTION event.\n");
-			ipacm_event_connection* data = (ipacm_event_connection*)param;
-			handle_new_lan2lan_connection(data);
+			handle_client_del(data);
 			break;
 		}
 
-		case IPA_LAN_TO_LAN_DEL_CONNECTION:
+		case IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH:
 		{
-			IPACMDBG_H("Get IPA_LAN_TO_LAN_DEL_CONNECTION event.\n");
-			ipacm_event_connection* data = (ipacm_event_connection*)param;
-			handle_del_lan2lan_connection(data);
-			break;
-		}
-		case IPA_LAN_CLIENT_POWER_SAVE:
-		{
-			IPACMDBG_H("Get IPA_LAN_CLIENT_POWER_SAVE event.\n");
-			ipacm_event_lan_client* data = (ipacm_event_lan_client*)param;
-			handle_client_power_save(data);
-			break;
-		}
-		case IPA_LAN_CLIENT_POWER_RECOVER:
-		{
-			IPACMDBG_H("Get IPA_LAN_CLIENT_POWER_RECOVER event.\n");
-			ipacm_event_lan_client* data = (ipacm_event_lan_client*)param;
-			handle_client_power_recover(data);
+			handle_wlan_scc_mcc_switch(data);
 			break;
 		}
 		default:
 			break;
 	}
+
+	print_data_structure_info();
 	return;
 }
 
-void IPACM_LanToLan::handle_client_active(ipacm_event_lan_client* data)
+void IPACM_LanToLan::handle_iface_up(ipacm_event_eth_bridge *data)
 {
-	if(data == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return;
-	}
-	if(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)
-	{
-		IPACMERR("Event data is not populated properly.\n");
-		return;
-	}
-	if(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected.\n");
-		return;
-	}
+	list<IPACM_LanToLan_Iface>::iterator it;
 
-	IPACMDBG_H("New client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \n",
-		data->p_iface->dev_name, data->iptype,
-		data->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],
-		data->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
-
-	bool client_not_found;
-	client_info* client_ptr;
-
-	if(data->iptype == IPA_IP_v4)
+	IPACMDBG_H("Interface name: %s IP type: %d\n", data->p_iface->dev_name, data->iptype);
+	for(it = m_iface.begin(); it != m_iface.end(); it++)
 	{
-		client_not_found = (client_info_v4_.count(data->ipv4_addr) == 0);
-		IPACMDBG_H("Is the client not found? %d\n", client_not_found);
-		client_info& client = client_info_v4_[data->ipv4_addr];
-		client_ptr = &client;
-	}
-	else
-	{
-		uint64_t v6_addr;
-		memcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));
-
-		client_not_found = (client_info_v6_.count(v6_addr) == 0);
-		IPACMDBG_H("Is the client not found? %d\n", client_not_found);
-		client_info& client = client_info_v6_[v6_addr];
-		client_ptr = &client;
-	}
-
-	if(client_not_found == true)
-	{
-		if(data->iptype == IPA_IP_v4)
+		if(it->get_iface_pointer() == data->p_iface)
 		{
-			client_ptr->ip.ipv4_addr = data->ipv4_addr;
-		}
-		else
-		{
-			memcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));
-		}
-		memcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));
-		client_ptr->is_active =  true;
-		client_ptr->is_powersave = false;
-		client_ptr->p_iface = data->p_iface;
-
-		generate_new_connection(data->iptype, client_ptr);
-		check_cache_connection(data->iptype, client_ptr);
-	}
-	else	//the client is found
-	{
-		if(client_ptr->is_active == true)	//the client is active
-		{
-			IPACMDBG_H("The client is active.\n");
-			if(memcmp(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr)) == 0)
+			IPACMDBG_H("Found the interface.\n");
+			if(it->get_m_is_ip_addr_assigned(data->iptype) == false)
 			{
-				IPACMDBG_H("Mac addr is the same, do nothing.\n");
-			}
-			else
-			{
-				IPACMERR("The new client has same IP but differenc mac.\n");
-				turnoff_offload_links(data->iptype, client_ptr);
-				clear_peer_list(client_ptr);
+				IPACMDBG_H("IP type %d was not active before, activating it now.\n", data->iptype);
+				it->set_m_is_ip_addr_assigned(data->iptype, true);
 
-				if(data->iptype == IPA_IP_v4)
-				{
-					client_ptr->ip.ipv4_addr = data->ipv4_addr;
-				}
-				else
-				{
-					memcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));
-				}
-				memcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));
-				client_ptr->is_active =  true;
-				client_ptr->is_powersave = false;
-				client_ptr->p_iface = data->p_iface;
+				/* install inter-interface rules */
+				if(it->get_m_support_inter_iface_offload())
+					it->add_all_inter_interface_client_flt_rule(data->iptype);
 
-				generate_new_connection(data->iptype, client_ptr);
-				check_cache_connection(data->iptype, client_ptr);
-			}
-		}
-		else 	//the client is inactive
-		{
-			IPACMDBG_H("The client is inactive.\n");
-			if(data->iptype == IPA_IP_v4)
-			{
-				client_ptr->ip.ipv4_addr = data->ipv4_addr;
-			}
-			else
-			{
-				memcpy(client_ptr->ip.ipv6_addr, data->ipv6_addr, sizeof(client_ptr->ip.ipv6_addr));
-			}
-			memcpy(client_ptr->mac_addr, data->mac_addr, sizeof(client_ptr->mac_addr));
-			client_ptr->is_active =  true;
-			client_ptr->is_powersave = false;
-			client_ptr->p_iface = data->p_iface;
-
-			check_potential_link(data->iptype, client_ptr);
-			generate_new_connection(data->iptype, client_ptr);
-			check_cache_connection(data->iptype, client_ptr);
-		}
-	}
-	IPACMDBG_H("There are %d clients in v4 table and %d clients in v6 table.\n", client_info_v4_.size(), client_info_v6_.size());
-	return;
-}
-
-void IPACM_LanToLan::check_potential_link(ipa_ip_type iptype, client_info* client)
-{
-	if(client == NULL)
-	{
-		IPACMERR("Client is NULL.\n");
-		return;
-	}
-
-	IPACMDBG_H("Check client's peer list.\n");
-	IPACMDBG_H("Client: IP type: %d, IPv4 addr: 0x%08x, IPv6 addr: 0x%08x%08x%08x%08x\n", iptype, client->ip.ipv4_addr,
-				client->ip.ipv6_addr[0], client->ip.ipv6_addr[1], client->ip.ipv6_addr[2], client->ip.ipv6_addr[3]);
-
-	peer_info_list::iterator peer_it;
-	int res, num = 0;
-
-	for(peer_it = client->peer.begin(); peer_it != client->peer.end(); peer_it++)
-	{
-		if(peer_it->peer_pointer->is_active == true && peer_it->num_connection > 0)
-		{
-			res = IPACM_SUCCESS;
-			res = add_offload_link(iptype, client, peer_it->peer_pointer);
-			res = add_offload_link(iptype, peer_it->peer_pointer, client);
-			if(res == IPACM_SUCCESS)
-			{
-				if(iptype == IPA_IP_v4)
-				{
-					num_offload_pair_v4_ ++;
-					IPACMDBG_H("Now the number of v4 offload links is %d.\n", num_offload_pair_v4_);
-				}
-				else
-				{
-					num_offload_pair_v6_ ++;
-					IPACMDBG_H("Now the number of v6 offload links is %d.\n", num_offload_pair_v6_);
-				}
-				num++;
-			}
-		}
-	}
-	IPACMDBG_H("Added %d offload links in total.\n", num);
-	return;
-}
-
-int IPACM_LanToLan::add_offload_link(ipa_ip_type iptype, client_info* client, client_info* peer)
-{
-	if( (iptype == IPA_IP_v4 && num_offload_pair_v4_ >= MAX_OFFLOAD_PAIR)
-		|| (iptype == IPA_IP_v6 && num_offload_pair_v6_ >= MAX_OFFLOAD_PAIR) )
-	{
-		IPACMDBG_H("The number of offload pairs already reaches maximum.\n");
-		return IPACM_FAILURE;
-	}
-	if(client == NULL || peer == NULL)
-	{
-		IPACMERR("Either client or peer is NULL.\n");
-		return IPACM_FAILURE;
-	}
-
-	uint32_t hdr_hdl, flt_hdl;
-	lan_to_lan_rt_rule_hdl rt_rule_hdl;
-
-	offload_link_info link_info;
-
-
-	if(iptype == IPA_IP_v4)
-	{
-		IPACMDBG_H("Add offload link for IPv4, client IP: 0x%08x, peer IP: 0x%08x \n", client->ip.ipv4_addr, peer->ip.ipv4_addr);
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		IPACMDBG_H("Add offload link for IPv6, client IP: 0x%08x%08x%08x%08x, peer IP: 0x%08x%08x%08x%08x \n",
-				client->ip.ipv6_addr[0], client->ip.ipv6_addr[1], client->ip.ipv6_addr[2], client->ip.ipv6_addr[3],
-				peer->ip.ipv6_addr[0], peer->ip.ipv6_addr[1], peer->ip.ipv6_addr[2], peer->ip.ipv6_addr[3]);
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		return IPACM_FAILURE;
-	}
-
-	//add lan2lan header
-	if(peer->p_iface->add_lan2lan_hdr(iptype, client->mac_addr, peer->mac_addr, &hdr_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to create lan2lan header.\n");
-		return IPACM_FAILURE;
-	}
-	IPACMDBG_H("Created lan2lan hdr with hdl %d.\n", hdr_hdl);
-
-	//add lan2lan routing/filtering rules
-	if(peer->p_iface->add_lan2lan_rt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,
-					client->ip.ipv6_addr, peer->ip.ipv6_addr, hdr_hdl, &rt_rule_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to create lan2lan rt rule.\n");
-		goto rt_fail;
-	}
-	IPACMDBG_H("Created %d lan2lan rt rules.\n", rt_rule_hdl.num_rule);
-	IPACMDBG_H("Created lan2lan rt rules with hdl: %d.\n", rt_rule_hdl.rule_hdl[0]);
-
-	if(client->p_iface->add_lan2lan_flt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,
-					client->ip.ipv6_addr, peer->ip.ipv6_addr, &flt_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to create lan2lan flt rule.\n");
-		goto flt_fail;
-	}
-	IPACMDBG_H("Created lan2lan flt rule with hdl %d.\n", flt_hdl);
-
-	link_info.peer_pointer = peer;
-	link_info.flt_rule_hdl = flt_hdl;
-	link_info.hdr_hdl = hdr_hdl;
-	memcpy(&link_info.rt_rule_hdl, &rt_rule_hdl, sizeof(lan_to_lan_rt_rule_hdl));
-
-	client->link.push_back(link_info);
-
-	return IPACM_SUCCESS;
-
-flt_fail:
-	peer->p_iface->del_lan2lan_rt_rule(iptype, rt_rule_hdl);
-
-rt_fail:
-	peer->p_iface->del_lan2lan_hdr(iptype, hdr_hdl);
-
-	return IPACM_FAILURE;
-}
-
-void IPACM_LanToLan::handle_client_inactive(ipacm_event_lan_client* data)
-{
-	if(data == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return;
-	}
-	if(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)
-	{
-		IPACMERR("Event data is not populated properly.\n");
-		return;
-	}
-	if(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d.\n", data->iptype);
-		return;
-	}
-
-	IPACMDBG_H("Del client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \n",
-		data->p_iface->dev_name, data->iptype,
-		data->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],
-		data->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
-
-	client_info* client_ptr;
-	uint64_t v6_addr;
-
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->ipv4_addr) == 0)//if not found the client, return
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v4_[data->ipv4_addr];
-		client_ptr = &client;
-	}
-	else
-	{
-		memcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));
-		if(client_info_v6_.count(v6_addr) == 0)	//if not found the client, insert it in table
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v6_[v6_addr];
-		client_ptr = &client;
-	}
-
-	turnoff_offload_links(data->iptype, client_ptr);
-	client_ptr->is_active = false;
-	if(client_ptr->peer.size() == 0)
-	{
-		IPACMDBG_H("Peer list is empty, remove client entry.\n");
-		if(data->iptype == IPA_IP_v4)
-		{
-			client_info_v4_.erase(data->ipv4_addr);
-		}
-		else
-		{
-			client_info_v6_.erase(v6_addr);
-		}
-	}
-	return;
-}
-
-int IPACM_LanToLan::turnoff_offload_links(ipa_ip_type iptype, client_info* client)
-{
-	if(client == NULL)
-	{
-		IPACMERR("Client is NULL.\n");
-		return IPACM_FAILURE;
-	}
-
-	bool err_flag;
-	offload_link_info_list::iterator client_it;
-	offload_link_info_list::iterator peer_it;
-	client_info* peer;
-
-	for(client_it = client->link.begin(); client_it != client->link.end(); client_it++)
-	{
-		peer = client_it->peer_pointer;
-		if(del_offload_link(iptype, client->p_iface, peer->p_iface, &(*client_it)) == IPACM_FAILURE)
-		{
-			IPACMERR("Failed to delete client's offload link.\n");
-			return IPACM_FAILURE;
-		}
-
-		err_flag = true;
-		for(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)
-		{
-			if(peer_it->peer_pointer == client)
-			{
-				if(del_offload_link(iptype, peer->p_iface, client->p_iface, &(*peer_it)) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to delete peer's offload link.\n");
-					return IPACM_FAILURE;
-				}
-				peer->link.erase(peer_it);
-				err_flag = false;
-				break;
-			}
-		}
-		if(err_flag)
-		{
-			IPACMERR("Unable to find corresponding offload link in peer's entry.\n");
-			return IPACM_FAILURE;
-		}
-		if(iptype == IPA_IP_v4)
-		{
-			num_offload_pair_v4_ --;
-			IPACMDBG_H("Now the number of v4 offload pair is %d\n", num_offload_pair_v4_);
-		}
-		else
-		{
-			num_offload_pair_v6_ --;
-			IPACMDBG_H("Now the number of v6 offload pair is %d\n", num_offload_pair_v6_);
-		}
-	}
-
-	client->link.clear();
-	return IPACM_SUCCESS;
-}
-
-int IPACM_LanToLan::del_offload_link(ipa_ip_type iptype, IPACM_Lan* client, IPACM_Lan* peer, offload_link_info* link)
-{
-	if(client == NULL || peer == NULL || link == NULL)
-	{
-		IPACMERR("Either iface or link is NULL.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Delete an offload link for IP type: %d\n", iptype);
-
-	int res = IPACM_SUCCESS;
-
-	if(client->del_lan2lan_flt_rule(iptype, link->flt_rule_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to delete flt rule.\n");
-		res = IPACM_FAILURE;
-	}
-
-	if(peer->del_lan2lan_rt_rule(iptype, link->rt_rule_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to delete rt rules.\n");
-		res = IPACM_FAILURE;
-	}
-
-	if(peer->del_lan2lan_hdr(iptype, link->hdr_hdl) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to delete header.\n");
-		res = IPACM_FAILURE;
-	}
-
-	return res;
-}
-
-void IPACM_LanToLan::handle_client_disconnect(ipacm_event_lan_client* data)
-{
-	if(data == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return;
-	}
-	if(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)
-	{
-		IPACMERR("Event data is not populated properly.\n");
-		return;
-	}
-	if(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d.\n", data->iptype);
-		return;
-	}
-
-	IPACMDBG_H("Del client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \n",
-		data->p_iface->dev_name, data->iptype,
-		data->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],
-		data->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
-
-	client_info* client_ptr;
-	uint64_t v6_addr;
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->ipv4_addr) == 0)	//if not found the client, return
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v4_[data->ipv4_addr];
-		client_ptr = &client;
-	}
-	else
-	{
-		memcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));
-		if(client_info_v6_.count(v6_addr) == 0)	//if not found the client, insert it in table
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v6_[v6_addr];
-		client_ptr = &client;
-	}
-
-	turnoff_offload_links(data->iptype, client_ptr);
-	clear_peer_list(client_ptr);
-	if(data->iptype == IPA_IP_v4)
-	{
-		client_info_v4_.erase(data->ipv4_addr);
-	}
-	else
-	{
-		client_info_v6_.erase(v6_addr);
-	}
-	return;
-}
-
-int IPACM_LanToLan::clear_peer_list(client_info* client)
-{
-	if(client == NULL)
-	{
-		IPACMERR("Client is NULL.\n");
-		return IPACM_FAILURE;
-	}
-
-	bool err_flag;
-	peer_info_list::iterator client_it;
-	peer_info_list::iterator peer_it;
-	client_info* peer;
-
-	for(client_it = client->peer.begin(); client_it != client->peer.end(); client_it++)
-	{
-		err_flag = true;
-		peer = client_it->peer_pointer;
-		for(peer_it = peer->peer.begin(); peer_it != peer->peer.end(); peer_it++)
-		{
-			if(peer_it->peer_pointer == client)
-			{
-				peer->peer.erase(peer_it);
-				err_flag = false;
-				break;
-			}
-		}
-		if(err_flag == true)
-		{
-			IPACMERR("Failed to find peer info.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	client->peer.clear();
-	return IPACM_SUCCESS;
-}
-
-void IPACM_LanToLan::handle_client_power_save(ipacm_event_lan_client* data)
-{
-	if(data == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return;
-	}
-	if(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)
-	{
-		IPACMERR("Event data is not populated properly.\n");
-		return;
-	}
-	if(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d.\n", data->iptype);
-		return;
-	}
-
-	IPACMDBG_H("Client power save info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \n",
-		data->p_iface->dev_name, data->iptype,
-		data->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],
-		data->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
-
-	client_info* client_ptr;
-	uint64_t v6_addr;
-
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->ipv4_addr) == 0)//if not found the client, return
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v4_[data->ipv4_addr];
-		client_ptr = &client;
-	}
-	else
-	{
-		memcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));
-		if(client_info_v6_.count(v6_addr) == 0)	//if not found the client, insert it in table
-		{
-			IPACMERR("The client is not found the client, return.\n");
-			return;
-		}
-		IPACMDBG_H("The client is found.\n");
-		client_info& client = client_info_v6_[v6_addr];
-		client_ptr = &client;
-	}
-
-	if(remove_flt_rules(data->iptype, client_ptr) == IPACM_FAILURE)
-	{
-		IPACMERR("Failed to remove flt rules when power save.\n");
-		return;
-	}
-	client_ptr->is_active = false;
-	client_ptr->is_powersave = true;
-	return;
-}
-
-void IPACM_LanToLan::handle_new_lan2lan_connection(ipacm_event_connection* data)
-{
-	IPACMDBG_H("New lan2lan connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\n", data->iptype, data->src_ipv4_addr, data->dst_ipv4_addr);
-	IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x", data->src_ipv6_addr[0], data->src_ipv6_addr[1], data->src_ipv6_addr[2],
-				data->src_ipv6_addr[3], data->dst_ipv6_addr[0], data->dst_ipv6_addr[1], data->dst_ipv6_addr[2], data->dst_ipv6_addr[3]);
-
-	client_info* src_client_ptr;
-	client_info* dst_client_ptr;
-
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->src_ipv4_addr) == 0 || client_info_v4_.count(data->dst_ipv4_addr) == 0)
-		{
-			IPACMERR("Either source or destination is not in table.\n");
-			return;
-		}
-		client_info& src_client = client_info_v4_[data->src_ipv4_addr];
-		src_client_ptr = &src_client;
-		client_info& dst_client = client_info_v4_[data->dst_ipv4_addr];
-		dst_client_ptr = &dst_client;
-	}
-	else //ipv6 case
-	{
-		uint64_t src_ipv6_addr;
-		uint64_t dst_ipv6_addr;
-		memcpy(&src_ipv6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));
-		memcpy(&dst_ipv6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));
-
-		if(client_info_v6_.count(src_ipv6_addr) == 0 || client_info_v6_.count(dst_ipv6_addr) == 0)
-		{
-			IPACMERR("Either source or destination is not in table.\n");
-			return;
-		}
-		client_info& src_client = client_info_v6_[src_ipv6_addr];
-		src_client_ptr = &src_client;
-		client_info& dst_client = client_info_v6_[dst_ipv6_addr];
-		dst_client_ptr = &dst_client;
-	}
-
-	IPACMDBG_H("Both src and dst are already in table.\n");
-	bool is_first_connection;
-	is_first_connection = add_connection(src_client_ptr, dst_client_ptr);
-
-	if(is_first_connection && src_client_ptr->is_active && dst_client_ptr->is_active)
-	{
-		IPACMDBG_H("This is first connection, add offload links.\n");
-
-		if(add_offload_link(data->iptype, src_client_ptr, dst_client_ptr) == IPACM_FAILURE)
-		{
-			IPACMERR("Failed to add offload link for src->dst direction.\n");
-			return;
-		}
-		if(add_offload_link(data->iptype, dst_client_ptr, src_client_ptr) == IPACM_FAILURE)
-		{
-			IPACMERR("Failed to add offload link for dst->src direction.\n");
-			return;
-		}
-
-		if(data->iptype == IPA_IP_v4)
-		{
-			num_offload_pair_v4_ ++;
-			IPACMDBG_H("Added offload links, now num_offload_pair_v4_: %d\n", num_offload_pair_v4_);
-		}
-		else
-		{
-			num_offload_pair_v6_ ++;
-			IPACMDBG_H("Added offload links, now num_offload_pair_v6_: %d\n", num_offload_pair_v6_);
-		}
-	}
-	return;
-}
-
-//If need to insert an entry in peer list, return true, otherwise return false
-bool IPACM_LanToLan::add_connection(client_info* src_client, client_info* dst_client)
-{
-	if(src_client == NULL || dst_client == NULL)
-	{
-		IPACMERR("Either source or dest client is NULL.\n");
-		return false;
-	}
-
-	peer_info_list::iterator it;
-	peer_info new_peer;
-	bool ret = false;
-
-	for(it = src_client->peer.begin(); it != src_client->peer.end(); it++)
-	{
-		if(it->peer_pointer == dst_client)
-		{
-			it->num_connection++;
-			IPACMDBG_H("Find dst client entry in peer list, connection count: %d\n", it->num_connection);
-			break;
-		}
-	}
-	if(it == src_client->peer.end())
-	{
-		IPACMDBG_H("Not finding dst client entry, insert a new one in peer list.\n");
-		new_peer.peer_pointer = dst_client;
-		new_peer.num_connection = 1;
-		src_client->peer.push_back(new_peer);
-		ret = true;
-	}
-
-	for(it = dst_client->peer.begin(); it != dst_client->peer.end(); it++)
-	{
-		if(it->peer_pointer == src_client)
-		{
-			it->num_connection++;
-			IPACMDBG_H("Find dst client entry in peer list, connection count: %d\n", it->num_connection);
-			break;
-		}
-	}
-	if(it == dst_client->peer.end())
-	{
-		IPACMDBG_H("Not finding src client entry, insert a new one in peer list.\n");
-		new_peer.peer_pointer = src_client;
-		new_peer.num_connection = 1;
-		dst_client->peer.push_back(new_peer);
-		ret = true;
-	}
-	return ret;
-}
-
-void IPACM_LanToLan::handle_del_lan2lan_connection(ipacm_event_connection* data)
-{
-	IPACMDBG_H("Del lan2lan connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\n", data->iptype, data->src_ipv4_addr, data->dst_ipv4_addr);
-	IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x", data->src_ipv6_addr[0], data->src_ipv6_addr[1], data->src_ipv6_addr[2],
-				data->src_ipv6_addr[3], data->dst_ipv6_addr[0], data->dst_ipv6_addr[1], data->dst_ipv6_addr[2], data->dst_ipv6_addr[3]);
-
-	bool res;
-	uint64_t src_ipv6_addr, dst_ipv6_addr;
-	client_info* src_client_ptr;
-	client_info* dst_client_ptr;
-
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->src_ipv4_addr) == 0
-			|| client_info_v4_.count(data->dst_ipv4_addr) == 0)	//if not found the client
-		{
-			IPACMDBG_H("Not found either source or dest client, return.\n");
-			return;
-		}
-		client_info& src_client = client_info_v4_[data->src_ipv4_addr];
-		client_info& dst_client = client_info_v4_[data->dst_ipv4_addr];
-		src_client_ptr = &src_client;
-		dst_client_ptr = &dst_client;
-	}
-	else
-	{
-		memcpy(&src_ipv6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));
-		memcpy(&dst_ipv6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));
-		if(client_info_v6_.count(src_ipv6_addr) == 0
-			|| client_info_v6_.count(dst_ipv6_addr) == 0)//if not found the client
-		{
-			IPACMDBG_H("Not found either source or dest client, return.\n");
-			return;
-		}
-		client_info& src_client = client_info_v6_[src_ipv6_addr];
-		client_info& dst_client = client_info_v6_[dst_ipv6_addr];
-		src_client_ptr = &src_client;
-		dst_client_ptr = &dst_client;
-	}
-
-	res = remove_connection(src_client_ptr, dst_client_ptr);
-
-	if(res && src_client_ptr->is_active && dst_client_ptr->is_active)
-	{
-		IPACMDBG_H("Erase link info for both src and dst entries.\n");
-		erase_offload_link(data->iptype, src_client_ptr, dst_client_ptr);
-	}
-	else
-	{
-		if(res && src_client_ptr->is_powersave && (dst_client_ptr->is_active || dst_client_ptr->is_powersave))
-		{
-			IPACMDBG_H("Erase link info for both src and dst entries due to src powersave.\n");
-			erase_offload_link(data->iptype, src_client_ptr, dst_client_ptr);
-		}
-		if(res && dst_client_ptr->is_powersave && (src_client_ptr->is_active || src_client_ptr->is_powersave))
-		{
-			IPACMDBG_H("Erase link info for both src and dst entries due to dst powersave.\n");
-			erase_offload_link(data->iptype, dst_client_ptr, src_client_ptr);
-		}
-	}
-
-	//if the src client is not active and not powersave mode, if peer list is empty, remove client entry
-	if(res && src_client_ptr->is_active == false && src_client_ptr->is_powersave == false && src_client_ptr->peer.size() == 0)
-	{
-		IPACMDBG_H("Peer list of src is empty, remove src entry.\n");
-		if(data->iptype == IPA_IP_v4)
-		{
-			client_info_v4_.erase(data->src_ipv4_addr);
-		}
-		else
-		{
-			client_info_v6_.erase(src_ipv6_addr);
-		}
-	}
-
-	//if the dst client is not active and not powersave mode, if peer list is empty, remove client entry
-	if(res && dst_client_ptr->is_active == false && dst_client_ptr->is_powersave == false && dst_client_ptr->peer.size() == 0)
-	{
-		IPACMDBG_H("Peer list of dst is empty, remove dst entry.\n");
-		if(data->iptype == IPA_IP_v4)
-		{
-			client_info_v4_.erase(data->dst_ipv4_addr);
-		}
-		else
-		{
-			client_info_v6_.erase(dst_ipv6_addr);
-		}
-	}
-	return;
-}
-
-//If need to remove an entry in peer list, return true, otherwise return false
-bool IPACM_LanToLan::remove_connection(client_info* src_client, client_info* dst_client)
-{
-	if(src_client == NULL || dst_client == NULL)
-	{
-		IPACMERR("Either source or dest client is NULL.\n");
-		return false;
-	}
-
-	peer_info_list::iterator it;
-	bool ret = false;
-
-	for(it = src_client->peer.begin(); it != src_client->peer.end(); it++)
-	{
-		if(it->peer_pointer == dst_client)
-		{
-			it->num_connection--;
-			IPACMDBG_H("Find dst client entry in src peer list, connection count: %d\n", it->num_connection);
-			if(it->num_connection == 0)
-			{
-				IPACMDBG_H("Need to remove dst entry in src peer list.\n");
-				ret = true;
+				/* install intra-BSS rules */
+				if(it->get_m_support_intra_iface_offload())
+					it->add_all_intra_interface_client_flt_rule(data->iptype);
 			}
 			break;
 		}
 	}
-	if(ret == true)
-	{
-		src_client->peer.erase(it);
-	}
 
-	ret = false;
-	for(it = dst_client->peer.begin(); it != dst_client->peer.end(); it++)
+	if(it == m_iface.end())	//If the interface has not been created before
 	{
-		if(it->peer_pointer == src_client)
+		if(m_iface.size() == MAX_NUM_IFACE)
 		{
-			it->num_connection--;
-			IPACMDBG_H("Find src client entry in dst peer list, connection count: %d\n", it->num_connection);
-			if(it->num_connection == 0)
-			{
-				IPACMDBG_H("Need to remove src entry in dst peer list.\n");
-				ret = true;
-			}
-			break;
+			IPACMERR("The number of interfaces has reached maximum %d.\n", MAX_NUM_IFACE);
+			return;
 		}
+
+		if(!data->p_iface->tx_prop || !data->p_iface->rx_prop)
+		{
+			IPACMERR("The interface %s does not have tx_prop or rx_prop.\n", data->p_iface->dev_name);
+			return;
+		}
+
+		if(data->p_iface->tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_NONE || data->p_iface->tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_MAX)
+		{
+			IPACMERR("Invalid l2 header type %s!\n", ipa_l2_hdr_type[data->p_iface->tx_prop->tx[0].hdr_l2_type]);
+			return;
+		}
+
+		IPACMDBG_H("Does not find the interface, insert a new one.\n");
+		IPACM_LanToLan_Iface new_iface(data->p_iface);
+		new_iface.set_m_is_ip_addr_assigned(data->iptype, true);
+
+		m_iface.push_front(new_iface);
+		IPACMDBG_H("Now the total number of interfaces is %d.\n", m_iface.size());
+
+		IPACM_LanToLan_Iface &front_iface = m_iface.front();
+
+		/* install inter-interface rules */
+		if(front_iface.get_m_support_inter_iface_offload())
+		{
+			for(it = ++m_iface.begin(); it != m_iface.end(); it++)
+			{
+				/* populate hdr_proc_ctx and routing table handle */
+				handle_new_iface_up(&front_iface, &(*it));
+
+				/* add client specific routing rule on existing interface */
+				it->add_client_rt_rule_for_new_iface();
+			}
+
+			/* add client specific filtering rule on new interface */
+			front_iface.add_all_inter_interface_client_flt_rule(data->iptype);
+		}
+
+		/* populate the intra-interface information */
+		if(front_iface.get_m_support_intra_iface_offload())
+		{
+			front_iface.handle_intra_interface_info();
+		}
+
+		/* handle cached client add event */
+		handle_cached_client_add_event(front_iface.get_iface_pointer());
 	}
-	if(ret == true)
-	{
-		dst_client->peer.erase(it);
-	}
-	return ret;
+	return;
 }
 
-void IPACM_LanToLan::erase_offload_link(ipa_ip_type iptype, client_info* src_client, client_info* dst_client)
+void IPACM_LanToLan::handle_iface_down(ipacm_event_eth_bridge *data)
 {
-	if(src_client == NULL || dst_client == NULL)
-	{
-		IPACMERR("Either source or dest client is NULL.\n");
-		return;
-	}
+	list<IPACM_LanToLan_Iface>::iterator it_target_iface;
 
-	offload_link_info_list::iterator it;
-	int res_src = IPACM_FAILURE, res_dst = IPACM_FAILURE;
+	IPACMDBG_H("Interface name: %s\n", data->p_iface->dev_name);
 
-	for(it = src_client->link.begin(); it != src_client->link.end(); it++)
+	for(it_target_iface = m_iface.begin(); it_target_iface != m_iface.end(); it_target_iface++)
 	{
-		if(it->peer_pointer == dst_client)
+		if(it_target_iface->get_iface_pointer() == data->p_iface)
 		{
-			res_src = IPACM_SUCCESS;
-			IPACMDBG_H("Find dst client entry in src link list\n");
-			res_src = del_offload_link(iptype, src_client->p_iface, dst_client->p_iface, &(*it));
-			src_client->link.erase(it);
+			IPACMDBG_H("Found the interface.\n");
 			break;
 		}
 	}
 
-	for(it = dst_client->link.begin(); it != dst_client->link.end(); it++)
+	if(it_target_iface == m_iface.end())
 	{
-		if(it->peer_pointer == src_client)
+		IPACMDBG_H("The interface has not been found.\n");
+		/* clear cached client add event for the unfound interface*/
+		clear_cached_client_add_event(data->p_iface);
+		return;
+	}
+
+	it_target_iface->handle_down_event();
+	m_iface.erase(it_target_iface);
+
+	return;
+}
+
+void IPACM_LanToLan::handle_new_iface_up(IPACM_LanToLan_Iface *new_iface, IPACM_LanToLan_Iface *exist_iface)
+{
+	char rt_tbl_name_for_flt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
+	char rt_tbl_name_for_rt[IPA_IP_MAX][IPA_RESOURCE_NAME_MAX];
+
+	IPACMDBG_H("Populate peer info between: new_iface %s, existing iface %s\n", new_iface->get_iface_pointer()->dev_name,
+		exist_iface->get_iface_pointer()->dev_name);
+
+	/* populate the routing table information */
+	snprintf(rt_tbl_name_for_flt[IPA_IP_v4], IPA_RESOURCE_NAME_MAX, "eth_v4_%s_to_%s",
+		ipa_l2_hdr_type[exist_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type],
+		ipa_l2_hdr_type[new_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type]);
+	IPACMDBG_H("IPv4 routing table for flt name: %s\n", rt_tbl_name_for_flt[IPA_IP_v4]);
+
+	snprintf(rt_tbl_name_for_flt[IPA_IP_v6], IPA_RESOURCE_NAME_MAX, "eth_v6_%s_to_%s",
+		ipa_l2_hdr_type[exist_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type],
+		ipa_l2_hdr_type[new_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type]);
+	IPACMDBG_H("IPv6 routing table for flt name: %s\n", rt_tbl_name_for_flt[IPA_IP_v6]);
+
+	snprintf(rt_tbl_name_for_rt[IPA_IP_v4], IPA_RESOURCE_NAME_MAX, "eth_v4_%s_to_%s",
+		ipa_l2_hdr_type[new_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type],
+		ipa_l2_hdr_type[exist_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type]);
+	IPACMDBG_H("IPv4 routing table for rt name: %s\n", rt_tbl_name_for_rt[IPA_IP_v4]);
+
+	snprintf(rt_tbl_name_for_rt[IPA_IP_v6], IPA_RESOURCE_NAME_MAX, "eth_v6_%s_to_%s",
+		ipa_l2_hdr_type[new_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type],
+		ipa_l2_hdr_type[exist_iface->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type]);
+	IPACMDBG_H("IPv6 routing table for rt name: %s\n", rt_tbl_name_for_rt[IPA_IP_v6]);
+
+	/* add new peer info in both new iface and existing iface */
+	exist_iface->handle_new_iface_up(rt_tbl_name_for_flt, rt_tbl_name_for_rt, new_iface);
+
+	new_iface->handle_new_iface_up(rt_tbl_name_for_rt, rt_tbl_name_for_flt, exist_iface);
+
+	return;
+}
+
+void IPACM_LanToLan::handle_client_add(ipacm_event_eth_bridge *data)
+{
+	list<IPACM_LanToLan_Iface>::iterator it_iface;
+
+	IPACMDBG_H("Incoming client MAC: 0x%02x%02x%02x%02x%02x%02x, interface: %s\n", data->mac_addr[0], data->mac_addr[1],
+		data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5], data->p_iface->dev_name);
+
+	for(it_iface = m_iface.begin(); it_iface != m_iface.end(); it_iface++)
+	{
+		if(it_iface->get_iface_pointer() == data->p_iface)	//find the interface
 		{
-			res_dst = IPACM_SUCCESS;
-			IPACMDBG_H("Find src client entry in dst link list\n");
-			res_dst = del_offload_link(iptype, dst_client->p_iface, src_client->p_iface, &(*it));
-			dst_client->link.erase(it);
+			IPACMDBG_H("Found the interface.\n");
+			it_iface->handle_client_add(data->mac_addr);
 			break;
 		}
 	}
 
-	if(res_src == IPACM_SUCCESS && res_dst == IPACM_SUCCESS)
+	/* if the iface was not found, cache the client add event */
+	if(it_iface == m_iface.end())
 	{
-		if(iptype == IPA_IP_v4)
+		IPACMDBG_H("The interface is not found.\n");
+		if(m_cached_client_add_event.size() < MAX_NUM_CACHED_CLIENT_ADD_EVENT)
 		{
-			num_offload_pair_v4_ --;
-			IPACMDBG_H("Decrease num of v4 offload pairs to %d\n", num_offload_pair_v4_);
+			IPACMDBG_H("Cached the client information.\n");
+			m_cached_client_add_event.push_front(*data);
 		}
 		else
 		{
-			num_offload_pair_v6_ --;
-			IPACMDBG_H("Decrease num of v6 offload pairs to %d\n", num_offload_pair_v6_);
+			IPACMDBG_H("Cached client add event has reached maximum number.\n");
 		}
 	}
 	return;
 }
 
-void IPACM_LanToLan::generate_new_connection(ipa_ip_type iptype, client_info* client)
+void IPACM_LanToLan::handle_client_del(ipacm_event_eth_bridge *data)
 {
-#ifndef CT_OPT
-	if(client == NULL)
+	list<IPACM_LanToLan_Iface>::iterator it_iface;
+
+	IPACMDBG_H("Incoming client MAC: 0x%02x%02x%02x%02x%02x%02x, interface: %s\n", data->mac_addr[0], data->mac_addr[1],
+		data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5], data->p_iface->dev_name);
+
+	for(it_iface = m_iface.begin(); it_iface != m_iface.end(); it_iface++)
 	{
-		IPACMERR("Client is NULL.\n");
-		return;
-	}
-
-	IPACMDBG_H("Generate new connection events for IP type %d\n", iptype);
-
-	int num = 0;
-	ipacm_cmd_q_data evt;
-	ipacm_event_connection* new_conn;
-	ipacm_iface_type client_type, peer_type;
-	client_type = IPACM_Iface::ipacmcfg->iface_table[client->p_iface->ipa_if_num].if_cat;
-
-	IPACMDBG_H("Client's iface type is %d.\n", client_type);
-
-	if(iptype == IPA_IP_v4)
-	{
-		client_table_v4::iterator it;
-		for(it = client_info_v4_.begin(); it != client_info_v4_.end(); it++)
+		if(it_iface->get_iface_pointer() == data->p_iface)	//found the interface
 		{
-			peer_type = IPACM_Iface::ipacmcfg->iface_table[it->second.p_iface->ipa_if_num].if_cat;
-			if(peer_type != client_type && it->second.is_active == true)
-			{
-				IPACMDBG_H("Find a qualified peer to generate new_conn event.\n");
-				IPACMDBG_H("Peer's iface type is %d.\n", peer_type);
-				new_conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-				if(new_conn == NULL)
-				{
-					IPACMERR("Failed to allocate memory for new_connection event.\n");
-					return;
-				}
-				memset(new_conn, 0, sizeof(ipacm_event_connection));
-				new_conn->iptype = IPA_IP_v4;
-				new_conn->src_ipv4_addr = client->ip.ipv4_addr;
-				new_conn->dst_ipv4_addr = it->second.ip.ipv4_addr;
-
-				memset(&evt, 0, sizeof(evt));
-				evt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;
-				evt.evt_data = (void*)new_conn;
-				IPACM_EvtDispatcher::PostEvt(&evt);
-				num++;
-			}
+			IPACMDBG_H("Found the interface.\n");
+			it_iface->handle_client_del(data->mac_addr);
+			break;
 		}
 	}
-	else if(iptype == IPA_IP_v6)
-	{
-		client_table_v6::iterator it;
-		for(it = client_info_v6_.begin(); it != client_info_v6_.end(); it++)
-		{
-			peer_type = IPACM_Iface::ipacmcfg->iface_table[it->second.p_iface->ipa_if_num].if_cat;
-			if(peer_type != client_type && it->second.is_active == true)
-			{
-				IPACMDBG_H("Find a qualified peer to generate new_conn event.\n");
-				IPACMDBG_H("Peer's iface type is %d.\n", peer_type);
-				new_conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-				if(new_conn == NULL)
-				{
-					IPACMERR("Failed to allocate memory for new_connection event.\n");
-					return;
-				}
-				memset(new_conn, 0, sizeof(ipacm_event_connection));
-				new_conn->iptype = IPA_IP_v6;
-				memcpy(new_conn->src_ipv6_addr, client->ip.ipv6_addr, sizeof(new_conn->src_ipv6_addr));
-				memcpy(new_conn->dst_ipv6_addr, it->second.ip.ipv6_addr, sizeof(new_conn->dst_ipv6_addr));
 
-				memset(&evt, 0, sizeof(evt));
-				evt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;
-				evt.evt_data = (void*)new_conn;
-				IPACM_EvtDispatcher::PostEvt(&evt);
-				num++;
-			}
-		}
-	}
-	else
+	if(it_iface == m_iface.end())
 	{
-		IPACMERR("IP type is not expected.\n");
+		IPACMDBG_H("The interface is not found.\n");
 	}
-	IPACMDBG_H("Generate %d new connection events in total.\n", num);
-#endif
+
 	return;
 }
 
-void IPACM_LanToLan::handle_client_power_recover(ipacm_event_lan_client* data)
+void IPACM_LanToLan::handle_wlan_scc_mcc_switch(ipacm_event_eth_bridge *data)
 {
-	if(data == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return;
-	}
-	if(data->mac_addr == NULL || data->ipv6_addr == NULL || data->p_iface == NULL)
-	{
-		IPACMERR("Event data is not populated properly.\n");
-		return;
-	}
-	if(data->iptype != IPA_IP_v4 && data->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d\n", data->iptype);
-		return;
-	}
+	list<IPACM_LanToLan_Iface>::iterator it_iface;
 
-	IPACMDBG_H("New client info: iface %s, iptype: %d, mac: 0x%02x%02x%02x%02x%02x%02x, v4_addr: 0x%08x, v6_addr: 0x%08x%08x%08x%08x \n",
-		data->p_iface->dev_name, data->iptype,
-		data->mac_addr[0], data->mac_addr[1], data->mac_addr[2], data->mac_addr[3], data->mac_addr[4], data->mac_addr[5],
-		data->ipv4_addr, data->ipv6_addr[0], data->ipv6_addr[1], data->ipv6_addr[2], data->ipv6_addr[3]);
-
-	client_info* client_ptr;
-	if(data->iptype == IPA_IP_v4)
+	IPACMDBG_H("Incoming interface: %s\n", data->p_iface->dev_name);
+	for(it_iface = m_iface.begin(); it_iface != m_iface.end(); it_iface++)
 	{
-		if(client_info_v4_.count(data->ipv4_addr) == 0)
+		if(it_iface->get_iface_pointer() == data->p_iface)
 		{
-			IPACMERR("Client is not found.\n");
-			return;
+			it_iface->handle_wlan_scc_mcc_switch();
+			break;
 		}
-		client_info& client = client_info_v4_[data->ipv4_addr];
-		client_ptr = &client;
 	}
-	else
-	{
-		uint64_t v6_addr;
-		memcpy(&v6_addr, &(data->ipv6_addr[2]), sizeof(uint64_t));
-		if(client_info_v6_.count(v6_addr) == 0)
-		{
-			IPACMERR("Client is not found.\n");
-			return;
-		}
-		client_info& client = client_info_v6_[v6_addr];
-		client_ptr = &client;
-	}
-
-	if(client_ptr->is_active == true || client_ptr->is_powersave != true)	//the client is in wrong state
-	{
-		IPACMERR("The client is in wrong state: active %d, powersave %d.\n", client_ptr->is_active, client_ptr->is_powersave);
-		return;
-	}
-	else
-	{
-		if(add_flt_rules(data->iptype, client_ptr) == IPACM_FAILURE)
-		{
-			IPACMERR("Failed to add back flt rules when power recovery.\n");
-			return;
-		}
-		client_ptr->is_active =  true;
-		client_ptr->is_powersave = false;
-
-		check_potential_link(data->iptype, client_ptr);
-		generate_new_connection(data->iptype, client_ptr);
-	}
-	IPACMDBG_H("There are %d clients in v4 table and %d clients in v6 table.\n", client_info_v4_.size(), client_info_v6_.size());
 	return;
 }
 
-//This function is called when power save: remove filtering rules only
-int IPACM_LanToLan::remove_flt_rules(ipa_ip_type iptype, client_info* client)
+void IPACM_LanToLan::handle_cached_client_add_event(IPACM_Lan *p_iface)
 {
-	if(client == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return IPACM_FAILURE;
-	}
+	list<ipacm_event_eth_bridge>::iterator it;
 
-	bool err_flag;
-	offload_link_info_list::iterator client_it;
-	offload_link_info_list::iterator peer_it;
-	client_info* peer;
-
-	for(client_it = client->link.begin(); client_it != client->link.end(); client_it++)
+	it = m_cached_client_add_event.begin();
+	while(it != m_cached_client_add_event.end())
 	{
-		if(client->p_iface->del_lan2lan_flt_rule(iptype, client_it->flt_rule_hdl) == IPACM_FAILURE)
+		if(it->p_iface == p_iface)
 		{
-			IPACMERR("Failed to delete client's filtering rule.\n");
-		}
-
-		err_flag = true;
-		peer = client_it->peer_pointer;
-		for(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)
-		{
-			if(peer_it->peer_pointer == client)
-			{
-				if(peer->p_iface->del_lan2lan_flt_rule(iptype, peer_it->flt_rule_hdl) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to delete peer's offload link.\n");
-				}
-				err_flag = false;
-				break;
-			}
-		}
-		if(err_flag)
-		{
-			IPACMERR("Unable to find corresponding offload link in peer's entry.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	return IPACM_SUCCESS;
-}
-
-int IPACM_LanToLan::add_flt_rules(ipa_ip_type iptype, client_info* client)
-{
-	if(client == NULL)
-	{
-		IPACMERR("No client info is found.\n");
-		return IPACM_FAILURE;
-	}
-
-	bool err_flag;
-	offload_link_info_list::iterator client_it;
-	offload_link_info_list::iterator peer_it;
-	client_info* peer;
-
-	for(client_it = client->link.begin(); client_it != client->link.end(); client_it++)
-	{
-		peer = client_it->peer_pointer;
-		if(client->p_iface->add_lan2lan_flt_rule(iptype, client->ip.ipv4_addr, peer->ip.ipv4_addr,
-			client->ip.ipv6_addr, peer->ip.ipv6_addr, &(client_it->flt_rule_hdl)) == IPACM_FAILURE)
-		{
-			IPACMERR("Failed to add client's filtering rule.\n");
-			return IPACM_FAILURE;
-		}
-
-		err_flag = true;
-		for(peer_it = peer->link.begin(); peer_it != peer->link.end(); peer_it++)
-		{
-			if(peer_it->peer_pointer == client)
-			{
-				if(peer->p_iface->add_lan2lan_flt_rule(iptype, peer->ip.ipv4_addr, client->ip.ipv4_addr,
-					peer->ip.ipv6_addr, client->ip.ipv6_addr, &(peer_it->flt_rule_hdl)) == IPACM_FAILURE)
-				{
-					IPACMERR("Failed to delete peer's offload link.\n");
-					return IPACM_FAILURE;
-				}
-				err_flag = false;
-				break;
-			}
-		}
-		if(err_flag)
-		{
-			IPACMERR("Unable to find corresponding offload link in peer's entry.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	return IPACM_SUCCESS;
-}
-
-void IPACM_LanToLan::handle_new_connection(ipacm_event_connection* new_conn)
-{
-#ifdef CT_OPT
-	if(new_conn == NULL)
-	{
-		IPACMERR("No connection info is found.\n");
-		return;
-	}
-	if(new_conn->iptype != IPA_IP_v4 && new_conn->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d.\n", new_conn->iptype);
-		return;
-	}
-
-	IPACMDBG_H("New connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\n", new_conn->iptype, new_conn->src_ipv4_addr, new_conn->dst_ipv4_addr);
-	IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x", new_conn->src_ipv6_addr[0], new_conn->src_ipv6_addr[1], new_conn->src_ipv6_addr[2],
-				new_conn->src_ipv6_addr[3], new_conn->dst_ipv6_addr[0], new_conn->dst_ipv6_addr[1], new_conn->dst_ipv6_addr[2], new_conn->dst_ipv6_addr[3]);
-
-	if(is_lan2lan_connection(new_conn) == false)
-	{
-		IPACMDBG_H("The connection is not lan2lan connection.\n");
-		cache_new_connection(new_conn);
-		return;
-	}
-
-	ipacm_cmd_q_data evt;
-	ipacm_event_connection* conn;
-
-	conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-	if(conn == NULL)
-	{
-		IPACMERR("Failed to allocate memory for new_connection event.\n");
-		return;
-	}
-	memcpy(conn, new_conn, sizeof(ipacm_event_connection));
-
-	memset(&evt, 0, sizeof(evt));
-	evt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;
-	evt.evt_data = (void*)conn;
-	IPACM_EvtDispatcher::PostEvt(&evt);
-#endif
-	return;
-}
-
-void IPACM_LanToLan::handle_del_connection(ipacm_event_connection* new_conn)
-{
-#ifdef CT_OPT
-	if(new_conn == NULL)
-	{
-		IPACMERR("No connection info is found.\n");
-		return;
-	}
-	if(new_conn->iptype != IPA_IP_v4 && new_conn->iptype != IPA_IP_v6)
-	{
-		IPACMERR("IP type is not expected: %d.\n", new_conn->iptype);
-		return;
-	}
-
-	IPACMDBG_H("Del connection info: IP type: %d, src_v4_addr: 0x%08x, dst_v4_addr: 0x%08x\n", new_conn->iptype, new_conn->src_ipv4_addr, new_conn->dst_ipv4_addr);
-	IPACMDBG_H("src_v6_addr: 0x%08x%08x%08x%08x, dst_v6_addr: 0x%08x%08x%08x%08x", new_conn->src_ipv6_addr[0], new_conn->src_ipv6_addr[1], new_conn->src_ipv6_addr[2],
-				new_conn->src_ipv6_addr[3], new_conn->dst_ipv6_addr[0], new_conn->dst_ipv6_addr[1], new_conn->dst_ipv6_addr[2], new_conn->dst_ipv6_addr[3]);
-
-	if(is_lan2lan_connection(new_conn) == false)
-	{
-		IPACMDBG_H("The connection is not lan2lan connection.\n");
-		remove_cache_connection(new_conn);
-		return;
-	}
-
-	ipacm_cmd_q_data evt;
-	ipacm_event_connection* conn;
-
-	conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-	if(conn == NULL)
-	{
-		IPACMERR("Failed to allocate memory for del_connection event.\n");
-		return;
-	}
-	memcpy(conn, new_conn, sizeof(ipacm_event_connection));
-
-	memset(&evt, 0, sizeof(evt));
-	evt.event = IPA_LAN_TO_LAN_DEL_CONNECTION;
-	evt.evt_data = (void*)conn;
-	IPACM_EvtDispatcher::PostEvt(&evt);
-#endif
-	return;
-}
-
-bool IPACM_LanToLan::is_lan2lan_connection(ipacm_event_connection* data)
-{
-	if(data->iptype == IPA_IP_v4)
-	{
-		if(client_info_v4_.count(data->src_ipv4_addr) == 0 || client_info_v4_.count(data->dst_ipv4_addr) == 0)
-		{
-			IPACMDBG("Either source or destination is not in client table\n");
-			return false;
-		}
-
-		ipacm_iface_type src_type, dst_type;
-		src_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v4_[data->src_ipv4_addr].p_iface->ipa_if_num].if_cat;
-		dst_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v4_[data->dst_ipv4_addr].p_iface->ipa_if_num].if_cat;
-
-		return (src_type != dst_type);
-	}
-	else
-	{
-		uint64_t src_v6_addr, dst_v6_addr;
-		memcpy(&src_v6_addr, &(data->src_ipv6_addr[2]), sizeof(uint64_t));
-		memcpy(&dst_v6_addr, &(data->dst_ipv6_addr[2]), sizeof(uint64_t));
-
-		if(client_info_v6_.count(src_v6_addr) == 0 || client_info_v6_.count(dst_v6_addr) == 0)
-		{
-			IPACMDBG("Either source or destination is not in client table\n");
-			return false;
-		}
-
-		ipacm_iface_type src_type, dst_type;
-		src_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v6_[src_v6_addr].p_iface->ipa_if_num].if_cat;
-		dst_type = IPACM_Iface::ipacmcfg->iface_table[client_info_v6_[dst_v6_addr].p_iface->ipa_if_num].if_cat;
-
-		return (src_type != dst_type);
-	}
-}
-
-IPACM_LanToLan* IPACM_LanToLan::getLan2LanInstance()
-{
-	return p_instance;
-}
-
-bool IPACM_LanToLan::is_potential_lan2lan_connection(ipacm_event_connection* new_conn)
-{
-	int i, num_private_subnet;
-	bool src_is_valid = false;
-	bool dst_is_valid = false;
-
-	if(new_conn->iptype == IPA_IP_v4)
-	{
-		num_private_subnet = IPACM_Iface::ipacmcfg->ipa_num_private_subnet;
-		for(i=0; i<num_private_subnet; i++)
-		{
-			if( (new_conn->src_ipv4_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask)
-				== (IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask) )
-			{
-				src_is_valid = true;
-			}
-			if( (new_conn->dst_ipv4_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask)
-				== (IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_addr & IPACM_Iface::ipacmcfg->private_subnet_table[i].subnet_mask) )
-			{
-				dst_is_valid = true;
-			}
-		}
-
-		if(src_is_valid && dst_is_valid)
-		{
-			IPACMDBG("Both src and dst are potentially in subnet.\n");
-			return true;
-		}
-	}
-	else
-	{
-		if( (new_conn->src_ipv6_addr[0] & ipv6_multicast_mask) != (ipv6_multicast_addr & ipv6_multicast_mask) )
-		{
-			src_is_valid = true;
-		}
-		if( (new_conn->dst_ipv6_addr[0] & ipv6_multicast_mask) != (ipv6_multicast_addr & ipv6_multicast_mask) )
-		{
-			dst_is_valid = true;
-		}
-
-		if(src_is_valid && dst_is_valid)
-		{
-			IPACMDBG("Both src and dst are potentially in subnet.\n");
-			return true;
-		}
-	}
-
-	IPACMDBG("This connection is not a lan2lan connection potentially.\n");
-	return false;
-}
-
-void IPACM_LanToLan::cache_new_connection(ipacm_event_connection* new_conn)
-{
-	if(is_potential_lan2lan_connection(new_conn) == true)
-	{
-		if(new_conn->iptype == IPA_IP_v4)
-		{
-			if(connection_v4_.size() == max_cache_connection)
-			{
-				IPACMDBG_H("Cached ipv4 connections already reach maximum, clear up the list.\n");
-				connection_v4_.clear();
-			}
-
-			connection_v4_.push_back(*new_conn);
-			IPACMDBG_H("Cache an ipv4 connection, now the number of ipv4 cache connection is %d.\n", connection_v4_.size());
+			IPACMDBG_H("Found client with MAC: 0x%02x%02x%02x%02x%02x%02x\n", it->mac_addr[0], it->mac_addr[1],
+				it->mac_addr[2], it->mac_addr[3], it->mac_addr[4], it->mac_addr[5]);
+			handle_client_add(&(*it));
+			it = m_cached_client_add_event.erase(it);
 		}
 		else
 		{
-			if(connection_v6_.size() == max_cache_connection)
-			{
-				IPACMDBG_H("Cached ipv6 connections already reach maximum, clear up the list.\n");
-				connection_v6_.clear();
-			}
-
-			connection_v6_.push_back(*new_conn);
-			IPACMDBG_H("Cache an ipv6 connection, now the number of ipv6 cache connection is %d.\n", connection_v6_.size());
+			it++;
 		}
 	}
 	return;
 }
 
-void IPACM_LanToLan::remove_cache_connection(ipacm_event_connection* del_conn)
+void IPACM_LanToLan::clear_cached_client_add_event(IPACM_Lan *p_iface)
 {
-	connection_list::iterator it;
-	if(is_potential_lan2lan_connection(del_conn) == true)
+	list<ipacm_event_eth_bridge>::iterator it;
+
+	it = m_cached_client_add_event.begin();
+	while(it != m_cached_client_add_event.end())
 	{
-		if(del_conn->iptype == IPA_IP_v4)
+		if(it->p_iface == p_iface)
 		{
-			for(it = connection_v4_.begin(); it != connection_v4_.end(); it++)
-			{
-				if(it->src_ipv4_addr == del_conn->src_ipv4_addr && it->dst_ipv4_addr == del_conn->dst_ipv4_addr)
-				{
-					IPACMDBG("Find the cached ipv4 connection, remove it from list.\n");
-					connection_v4_.erase(it);
-					IPACMDBG_H("Now the number of ipv4 cache connection is %d.\n", connection_v4_.size());
-					return;
-				}
-			}
-			IPACMDBG_H("Do not find the cached ipv4 connection, do nothing.\n");
+			IPACMDBG_H("Found client with MAC: 0x%02x%02x%02x%02x%02x%02x\n", it->mac_addr[0], it->mac_addr[1],
+				it->mac_addr[2], it->mac_addr[3], it->mac_addr[4], it->mac_addr[5]);
+			it = m_cached_client_add_event.erase(it);
 		}
 		else
 		{
-			for(it = connection_v6_.begin(); it != connection_v6_.end(); it++)
-			{
-				if(memcmp(it->src_ipv6_addr, del_conn->src_ipv6_addr, 4*sizeof(uint32_t)) == 0
-					&& memcmp(it->dst_ipv6_addr, del_conn->dst_ipv6_addr, 4*sizeof(uint32_t)) == 0 )
-				{
-					IPACMDBG("Find the cached ipv6 connection, remove it from list.\n");
-					connection_v6_.erase(it);
-					IPACMDBG_H("Now the number of ipv6 cache connection is %d.\n", connection_v6_.size());
-					return;
-				}
-			}
-			IPACMDBG_H("Do not find the cached ipv6 connection, do nothing.\n");
+			it++;
 		}
 	}
 	return;
 }
 
-void IPACM_LanToLan::check_cache_connection(ipa_ip_type iptype, client_info* client)
+void IPACM_LanToLan::print_data_structure_info()
 {
-#ifdef CT_OPT
-	connection_list::iterator it;
-	if(iptype == IPA_IP_v4)
+	list<IPACM_LanToLan_Iface>::iterator it;
+	list<ipacm_event_eth_bridge>::iterator it_event;
+	int i;
+
+	IPACMDBG_H("There are %d interfaces in total.\n", m_iface.size());
+
+	for(it = m_iface.begin(); it != m_iface.end(); it++)
 	{
-		it = connection_v4_.begin();
-		while(it != connection_v4_.end())
+		it->print_data_structure_info();
+	}
+
+	IPACMDBG_H("There are %d cached client add events in total.\n", m_cached_client_add_event.size());
+
+	i = 1;
+	for(it_event = m_cached_client_add_event.begin(); it_event != m_cached_client_add_event.end(); it_event++)
+	{
+		IPACMDBG_H("Client %d MAC: 0x%02x%02x%02x%02x%02x%02x, interface: %s\n", i, it_event->mac_addr[0], it_event->mac_addr[1], it_event->mac_addr[2],
+			it_event->mac_addr[3], it_event->mac_addr[4], it_event->mac_addr[5], it_event->p_iface->dev_name);
+		i++;
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_client_rt_rule_for_new_iface()
+{
+	list<client_info>::iterator it;
+	ipa_hdr_l2_type peer_l2_type;
+	peer_iface_info &peer = m_peer_iface_info.front();
+
+	peer_l2_type = peer.peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type;
+	if(ref_cnt_peer_l2_hdr_type[peer_l2_type] == 1)
+	{
+		for(it = m_client_info.begin(); it != m_client_info.end(); it++)
 		{
-			if( (it->src_ipv4_addr == client->ip.ipv4_addr && client_info_v4_.count(it->dst_ipv4_addr) > 0)
-				|| (it->dst_ipv4_addr == client->ip.ipv4_addr && client_info_v4_.count(it->src_ipv4_addr) > 0) )
-			{
-				IPACMDBG("Found a cache connection for src client 0x%08x and dst client 0x%08x.\n", it->src_ipv4_addr, it->dst_ipv4_addr);
-				ipacm_cmd_q_data evt;
-				ipacm_event_connection* conn;
+			add_client_rt_rule(&peer, &(*it));
+		}
+	}
 
-				conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-				if(conn == NULL)
-				{
-					IPACMERR("Failed to allocate memory for new_connection event.\n");
-					return;
-				}
-				memcpy(conn, &(*it), sizeof(ipacm_event_connection));
+	return;
+}
 
-				memset(&evt, 0, sizeof(evt));
-				evt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;
-				evt.evt_data = (void*)conn;
-				IPACM_EvtDispatcher::PostEvt(&evt);
+void IPACM_LanToLan_Iface::add_client_rt_rule(peer_iface_info *peer_info, client_info *client)
+{
+	int i, num_rt_rule;
+	uint32_t rt_rule_hdl[MAX_NUM_PROP];
+	ipa_hdr_l2_type peer_l2_hdr_type;
 
-				it = connection_v4_.erase(it);
-				IPACMDBG_H("Now the number of cache connections is %d.\n", connection_v4_.size());
-			}
-			else
-			{
-				it++;
-			}
+	peer_l2_hdr_type = peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type;
+
+	/* if the peer info is not for intra interface communication */
+	if(peer_info->peer != this)
+	{
+		IPACMDBG_H("This is for inter interface communication.\n");
+
+		m_p_iface->eth_bridge_add_rt_rule(client->mac_addr, peer_info->rt_tbl_name_for_rt[IPA_IP_v4], hdr_proc_ctx_for_inter_interface[peer_l2_hdr_type],
+			peer_l2_hdr_type, IPA_IP_v4, rt_rule_hdl, &num_rt_rule);
+
+		client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v4] = num_rt_rule;
+		IPACMDBG_H("Number of IPv4 routing rule is %d.\n", num_rt_rule);
+		for(i=0; i<num_rt_rule; i++)
+		{
+			IPACMDBG_H("Routing rule %d handle %d\n", i, rt_rule_hdl[i]);
+			client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v4][i] = rt_rule_hdl[i];
+		}
+
+		m_p_iface->eth_bridge_add_rt_rule(client->mac_addr, peer_info->rt_tbl_name_for_rt[IPA_IP_v6], hdr_proc_ctx_for_inter_interface[peer_l2_hdr_type],
+			peer_l2_hdr_type, IPA_IP_v6, rt_rule_hdl, &num_rt_rule);
+
+		client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v6] = num_rt_rule;
+		IPACMDBG_H("Number of IPv6 routing rule is %d.\n", num_rt_rule);
+		for(i=0; i<num_rt_rule; i++)
+		{
+			IPACMDBG_H("Routing rule %d handle %d\n", i, rt_rule_hdl[i]);
+			client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v6][i] = rt_rule_hdl[i];
 		}
 	}
 	else
 	{
-		uint64_t src_v6_addr, dst_v6_addr;
-		it = connection_v6_.begin();
-		while(it != connection_v6_.end())
+		IPACMDBG_H("This is for intra interface communication.\n");
+		m_p_iface->eth_bridge_add_rt_rule(client->mac_addr, peer_info->rt_tbl_name_for_rt[IPA_IP_v4], hdr_proc_ctx_for_intra_interface,
+			peer_l2_hdr_type, IPA_IP_v4, rt_rule_hdl, &num_rt_rule);
+
+		client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4] = num_rt_rule;
+		IPACMDBG_H("Number of IPv4 routing rule is %d.\n", num_rt_rule);
+		for(i=0; i<num_rt_rule; i++)
 		{
-			memcpy(&src_v6_addr, &(it->src_ipv6_addr[2]), sizeof(uint64_t));
-			memcpy(&dst_v6_addr, &(it->dst_ipv6_addr[2]), sizeof(uint64_t));
-			if( (memcmp(it->src_ipv6_addr, client->ip.ipv6_addr, 4*sizeof(uint32_t)) == 0 && client_info_v6_.count(dst_v6_addr) > 0)
-				|| (memcmp(it->dst_ipv6_addr, client->ip.ipv6_addr, 4*sizeof(uint32_t)) == 0 && client_info_v6_.count(src_v6_addr) > 0) )
+			IPACMDBG_H("Routing rule %d handle %d\n", i, rt_rule_hdl[i]);
+			client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4][i] = rt_rule_hdl[i];
+		}
+
+		m_p_iface->eth_bridge_add_rt_rule(client->mac_addr, peer_info->rt_tbl_name_for_rt[IPA_IP_v6], hdr_proc_ctx_for_intra_interface,
+			peer_l2_hdr_type, IPA_IP_v6, rt_rule_hdl, &num_rt_rule);
+
+		client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6] = num_rt_rule;
+		IPACMDBG_H("Number of IPv6 routing rule is %d.\n", num_rt_rule);
+		for(i=0; i<num_rt_rule; i++)
+		{
+			IPACMDBG_H("Routing rule %d handle %d\n", i, rt_rule_hdl[i]);
+			client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6][i] = rt_rule_hdl[i];
+		}
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_all_inter_interface_client_flt_rule(ipa_ip_type iptype)
+{
+	list<peer_iface_info>::iterator it_iface;
+	list<client_info>::iterator it_client;
+
+	for(it_iface = m_peer_iface_info.begin(); it_iface != m_peer_iface_info.end(); it_iface++)
+	{
+		IPACMDBG_H("Add flt rules for clients of interface %s.\n", it_iface->peer->get_iface_pointer()->dev_name);
+		for(it_client = it_iface->peer->m_client_info.begin(); it_client != it_iface->peer->m_client_info.end(); it_client++)
+		{
+			add_client_flt_rule(&(*it_iface), &(*it_client), iptype);
+		}
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_all_intra_interface_client_flt_rule(ipa_ip_type iptype)
+{
+	list<client_info>::iterator it_client;
+
+	IPACMDBG_H("Add flt rules for own clients.\n");
+	for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+	{
+		add_client_flt_rule(&m_intra_interface_info, &(*it_client), iptype);
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client)
+{
+	list<peer_iface_info>::iterator it;
+
+	for(it = m_peer_iface_info.begin(); it != m_peer_iface_info.end(); it++)
+	{
+		if(it->peer == peer_iface)
+		{
+			IPACMDBG_H("Found the peer iface info.\n");
+			if(m_is_ip_addr_assigned[IPA_IP_v4])
 			{
-				IPACMDBG("Found a cache connection with src client 0x%08x%08x%08x%08x and dst client 0x%08x%08x%08x%08x.\n", it->src_ipv6_addr[0],
-							it->src_ipv6_addr[1], it->src_ipv6_addr[2], it->src_ipv6_addr[3], it->dst_ipv6_addr[0], it->dst_ipv6_addr[1],
-							it->dst_ipv6_addr[2], it->dst_ipv6_addr[3]);
-				ipacm_cmd_q_data evt;
-				ipacm_event_connection* conn;
-
-				conn = (ipacm_event_connection*)malloc(sizeof(ipacm_event_connection));
-				if(conn == NULL)
-				{
-					IPACMERR("Failed to allocate memory for new_connection event.\n");
-					return;
-				}
-				memcpy(conn, &(*it), sizeof(ipacm_event_connection));
-
-				memset(&evt, 0, sizeof(evt));
-				evt.event = IPA_LAN_TO_LAN_NEW_CONNECTION;
-				evt.evt_data = (void*)conn;
-				IPACM_EvtDispatcher::PostEvt(&evt);
-
-				it = connection_v6_.erase(it);
-				IPACMDBG_H("Now the number of cache connections is %d.\n", connection_v6_.size());
+				add_client_flt_rule(&(*it), client, IPA_IP_v4);
 			}
-			else
+			if(m_is_ip_addr_assigned[IPA_IP_v6])
 			{
-				it++;
+				add_client_flt_rule(&(*it), client, IPA_IP_v6);
+			}
+
+			break;
+		}
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_client_flt_rule(peer_iface_info *peer, client_info *client, ipa_ip_type iptype)
+{
+	list<flt_rule_info>::iterator it_flt;
+	uint32_t flt_rule_hdl;
+	flt_rule_info new_flt_info;
+	ipa_ioc_get_rt_tbl rt_tbl;
+
+	rt_tbl.ip = iptype;
+	memcpy(rt_tbl.name, peer->rt_tbl_name_for_flt[iptype], sizeof(rt_tbl.name));
+	IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name);
+
+	if(IPACM_Iface::m_routing.GetRoutingTable(&rt_tbl) == false)
+	{
+		IPACMERR("Failed to get routing table.\n");
+		return;
+	}
+
+	m_p_iface->eth_bridge_add_flt_rule(client->mac_addr, rt_tbl.hdl,
+		iptype, &flt_rule_hdl);
+	IPACMDBG_H("Installed flt rule for IP type %d: handle %d\n", iptype, flt_rule_hdl);
+	IPACM_Iface::m_routing.PutRoutingTable(rt_tbl.hdl);
+
+	for(it_flt = peer->flt_rule.begin(); it_flt != peer->flt_rule.end(); it_flt++)
+	{
+		if(it_flt->p_client == client)	//the client is already in the flt info list
+		{
+			IPACMDBG_H("The client is found in flt info list.\n");
+			it_flt->flt_rule_hdl[iptype] = flt_rule_hdl;
+			break;
+		}
+	}
+
+	if(it_flt == peer->flt_rule.end())	//the client is not in the flt info list
+	{
+		IPACMDBG_H("The client is not found in flt info list, insert a new one.\n");
+		memset(&new_flt_info, 0, sizeof(new_flt_info));
+		new_flt_info.p_client = client;
+		new_flt_info.flt_rule_hdl[iptype] = flt_rule_hdl;
+
+		peer->flt_rule.push_front(new_flt_info);
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::del_one_client_flt_rule(IPACM_LanToLan_Iface *peer_iface, client_info *client)
+{
+	list<peer_iface_info>::iterator it;
+
+	for(it = m_peer_iface_info.begin(); it != m_peer_iface_info.end(); it++)
+	{
+		if(it->peer == peer_iface)
+		{
+			IPACMDBG_H("Found the peer iface info.\n");
+			del_client_flt_rule(&(*it), client);
+			break;
+		}
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::del_client_flt_rule(peer_iface_info *peer, client_info *client)
+{
+	list<flt_rule_info>::iterator it_flt;
+
+	for(it_flt = peer->flt_rule.begin(); it_flt != peer->flt_rule.end(); it_flt++)
+	{
+		if(it_flt->p_client == client)	//found the client in flt info list
+		{
+			IPACMDBG_H("Found the client in flt info list.\n");
+			if(m_is_ip_addr_assigned[IPA_IP_v4])
+			{
+				m_p_iface->eth_bridge_del_flt_rule(it_flt->flt_rule_hdl[IPA_IP_v4], IPA_IP_v4);
+				IPACMDBG_H("IPv4 flt rule %d is deleted.\n", it_flt->flt_rule_hdl[IPA_IP_v4]);
+			}
+			if(m_is_ip_addr_assigned[IPA_IP_v6])
+			{
+				m_p_iface->eth_bridge_del_flt_rule(it_flt->flt_rule_hdl[IPA_IP_v6], IPA_IP_v6);
+				IPACMDBG_H("IPv6 flt rule %d is deleted.\n", it_flt->flt_rule_hdl[IPA_IP_v6]);
+			}
+
+			peer->flt_rule.erase(it_flt);
+			break;
+		}
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::del_client_rt_rule(peer_iface_info *peer, client_info *client)
+{
+	ipa_hdr_l2_type peer_l2_hdr_type;
+	int i, num_rules;
+
+	peer_l2_hdr_type = peer->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type;
+	/* if the peer info is not for intra interface communication */
+	if(peer->peer != this)
+	{
+		IPACMDBG_H("Delete routing rules for inter interface communication.\n");
+
+		num_rules = client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v4];
+		for(i = 0; i < num_rules; i++)
+		{
+			m_p_iface->eth_bridge_del_rt_rule(client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v4][i], IPA_IP_v4);
+			IPACMDBG_H("IPv4 rt rule %d is deleted.\n", client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v4][i]);
+		}
+		client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v4] = 0;
+
+		num_rules = client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v6];
+		for(i = 0; i < num_rules; i++)
+		{
+			m_p_iface->eth_bridge_del_rt_rule(client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v6][i], IPA_IP_v6);
+			IPACMDBG_H("IPv6 rt rule %d is deleted.\n", client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v6][i]);
+		}
+		client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v6] = 0;
+	}
+	else
+	{
+		IPACMDBG_H("Delete routing rules for intra interface communication.\n");
+		num_rules = client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4];
+		for(i = 0; i < num_rules; i++)
+		{
+			m_p_iface->eth_bridge_del_rt_rule(client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4][i], IPA_IP_v4);
+			IPACMDBG_H("IPv4 rt rule %d is deleted.\n", client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4][i]);
+		}
+		client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4] = 0;
+
+		num_rules = client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6];
+		for(i = 0; i < num_rules; i++)
+		{
+			m_p_iface->eth_bridge_del_rt_rule(client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6][i], IPA_IP_v6);
+			IPACMDBG_H("IPv6 rt rule %d is deleted.\n", client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6][i]);
+		}
+		client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6] = 0;
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_down_event()
+{
+	list<IPACM_LanToLan_Iface>::iterator it_other_iface;
+	list<peer_iface_info>::iterator it_own_peer_info, it_other_iface_peer_info;
+	IPACM_LanToLan_Iface *other_iface;
+
+	/* clear inter-interface rules */
+	if(m_support_inter_iface_offload)
+	{
+		for(it_own_peer_info = m_peer_iface_info.begin(); it_own_peer_info != m_peer_iface_info.end();
+			it_own_peer_info++)
+		{
+			/* decrement reference count of peer l2 header type on both interfaces*/
+			decrement_ref_cnt_peer_l2_hdr_type(it_own_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type);
+			it_own_peer_info->peer->decrement_ref_cnt_peer_l2_hdr_type(m_p_iface->tx_prop->tx[0].hdr_l2_type);
+
+			/* first clear all flt rule on target interface */
+			IPACMDBG_H("Clear all flt rule on target interface.\n");
+			clear_all_flt_rule_for_one_peer_iface(&(*it_own_peer_info));
+
+			other_iface = it_own_peer_info->peer;
+			/* then clear all flt/rt rule and hdr proc ctx for target interface on peer interfaces */
+			IPACMDBG_H("Clear all flt/rt rules and hdr proc ctx for target interface on peer interfaces %s.\n",
+				it_own_peer_info->peer->get_iface_pointer()->dev_name);
+			for(it_other_iface_peer_info = other_iface->m_peer_iface_info.begin();
+				it_other_iface_peer_info != other_iface->m_peer_iface_info.end();
+				it_other_iface_peer_info++)
+			{
+				if(it_other_iface_peer_info->peer == this)	//found myself in other iface's peer info list
+				{
+					IPACMDBG_H("Found the right peer info on other iface.\n");
+					other_iface->clear_all_flt_rule_for_one_peer_iface(&(*it_other_iface_peer_info));
+					other_iface->clear_all_rt_rule_for_one_peer_iface(&(*it_other_iface_peer_info));
+					/* remove the peer info from the list */
+					other_iface->m_peer_iface_info.erase(it_other_iface_peer_info);
+					other_iface->del_hdr_proc_ctx(m_p_iface->tx_prop->tx[0].hdr_l2_type);
+					break;
+				}
+			}
+
+			/* then clear rt rule and hdr proc ctx and release rt table on target interface */
+			IPACMDBG_H("Clear rt rules and hdr proc ctx and release rt table on target interface.\n");
+			clear_all_rt_rule_for_one_peer_iface(&(*it_own_peer_info));
+			del_hdr_proc_ctx(it_own_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type);
+		}
+		m_peer_iface_info.clear();
+	}
+
+	/* clear intra interface rules */
+	if(m_support_intra_iface_offload)
+	{
+		IPACMDBG_H("Clear intra interface flt/rt rules and hdr proc ctx, release rt tables.\n");
+		clear_all_flt_rule_for_one_peer_iface(&m_intra_interface_info);
+		clear_all_rt_rule_for_one_peer_iface(&m_intra_interface_info);
+		m_p_iface->eth_bridge_del_hdr_proc_ctx(hdr_proc_ctx_for_intra_interface);
+		IPACMDBG_H("Hdr proc ctx with hdl %d is deleted.\n", hdr_proc_ctx_for_intra_interface);
+	}
+
+	/* then clear the client info list */
+	m_client_info.clear();
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::clear_all_flt_rule_for_one_peer_iface(peer_iface_info *peer)
+{
+	list<flt_rule_info>::iterator it;
+
+	for(it = peer->flt_rule.begin(); it != peer->flt_rule.end(); it++)
+	{
+		if(m_is_ip_addr_assigned[IPA_IP_v4])
+		{
+			m_p_iface->eth_bridge_del_flt_rule(it->flt_rule_hdl[IPA_IP_v4], IPA_IP_v4);
+			IPACMDBG_H("IPv4 flt rule %d is deleted.\n", it->flt_rule_hdl[IPA_IP_v4]);
+		}
+		if(m_is_ip_addr_assigned[IPA_IP_v6])
+		{
+			m_p_iface->eth_bridge_del_flt_rule(it->flt_rule_hdl[IPA_IP_v6], IPA_IP_v6);
+			IPACMDBG_H("IPv6 flt rule %d is deleted.\n", it->flt_rule_hdl[IPA_IP_v6]);
+		}
+	}
+	peer->flt_rule.clear();
+	return;
+}
+
+void IPACM_LanToLan_Iface::clear_all_rt_rule_for_one_peer_iface(peer_iface_info *peer)
+{
+	list<client_info>::iterator it;
+	ipa_hdr_l2_type peer_l2_type;
+
+	peer_l2_type = peer->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type;
+	if(ref_cnt_peer_l2_hdr_type[peer_l2_type] == 0)
+	{
+		for(it = m_client_info.begin(); it != m_client_info.end(); it++)
+		{
+			del_client_rt_rule(peer, &(*it));
+		}
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_wlan_scc_mcc_switch()
+{
+	list<peer_iface_info>::iterator it_peer_info;
+	list<client_info>::iterator it_client;
+	ipa_hdr_l2_type peer_l2_hdr_type;
+	bool flag[IPA_HDR_L2_MAX];
+	int i;
+
+	/* modify inter-interface routing rules */
+	if(m_support_inter_iface_offload)
+	{
+		IPACMDBG_H("Modify rt rules for peer interfaces.\n");
+		memset(flag, 0, sizeof(flag));
+		for(it_peer_info = m_peer_iface_info.begin(); it_peer_info != m_peer_iface_info.end(); it_peer_info++)
+		{
+			peer_l2_hdr_type = it_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type;
+			if(flag[peer_l2_hdr_type] == false)
+			{
+				flag[peer_l2_hdr_type] = true;
+				for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+				{
+					m_p_iface->eth_bridge_modify_rt_rule(it_client->mac_addr, hdr_proc_ctx_for_inter_interface[peer_l2_hdr_type],
+						peer_l2_hdr_type, IPA_IP_v4, it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v4],
+						it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v4]);
+					IPACMDBG_H("The following IPv4 routing rules are modified:\n");
+					for(i = 0; i < it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v4]; i++)
+					{
+						IPACMDBG_H("%d\n", it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v4][i]);
+					}
+
+					m_p_iface->eth_bridge_modify_rt_rule(it_client->mac_addr, hdr_proc_ctx_for_inter_interface[peer_l2_hdr_type],
+						peer_l2_hdr_type, IPA_IP_v6, it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v6],
+						it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v6]);
+					IPACMDBG_H("The following IPv6 routing rules are modified:\n");
+					for(i = 0; i < it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].num_hdl[IPA_IP_v6]; i++)
+					{
+						IPACMDBG_H("%d\n", it_client->inter_iface_rt_rule_hdl[peer_l2_hdr_type].rule_hdl[IPA_IP_v6][i]);
+					}
+				}
 			}
 		}
 	}
-#endif
+
+	/* modify routing rules for intra-interface communication */
+	IPACMDBG_H("Modify rt rules for intra-interface communication.\n");
+	if(m_support_intra_iface_offload)
+	{
+		for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+		{
+			m_p_iface->eth_bridge_modify_rt_rule(it_client->mac_addr, hdr_proc_ctx_for_intra_interface,
+				m_p_iface->tx_prop->tx[0].hdr_l2_type, IPA_IP_v4, it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4],
+				it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4]);
+			IPACMDBG_H("The following IPv4 routing rules are modified:\n");
+			for(i = 0; i < it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4]; i++)
+			{
+				IPACMDBG_H("%d\n", it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4][i]);
+			}
+
+			m_p_iface->eth_bridge_modify_rt_rule(it_client->mac_addr, hdr_proc_ctx_for_intra_interface,
+				m_p_iface->tx_prop->tx[0].hdr_l2_type, IPA_IP_v6, it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6],
+				it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6]);
+			IPACMDBG_H("The following IPv6 routing rules are modified:\n");
+			for(i = 0; i < it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6]; i++)
+			{
+				IPACMDBG_H("%d\n", it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6][i]);
+			}
+		}
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_intra_interface_info()
+{
+	uint32_t hdr_proc_ctx_hdl;
+
+	m_intra_interface_info.peer = this;
+
+	snprintf(m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v4], IPA_RESOURCE_NAME_MAX,
+		"eth_v4_intra_interface");
+	IPACMDBG_H("IPv4 routing table for flt name: %s\n", m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v4]);
+	snprintf(m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v6], IPA_RESOURCE_NAME_MAX,
+		"eth_v6_intra_interface");
+	IPACMDBG_H("IPv6 routing table for flt name: %s\n", m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v6]);
+
+	memcpy(m_intra_interface_info.rt_tbl_name_for_rt[IPA_IP_v4], m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v4],
+		IPA_RESOURCE_NAME_MAX);
+	IPACMDBG_H("IPv4 routing table for rt name: %s\n", m_intra_interface_info.rt_tbl_name_for_rt[IPA_IP_v4]);
+	memcpy(m_intra_interface_info.rt_tbl_name_for_rt[IPA_IP_v6], m_intra_interface_info.rt_tbl_name_for_flt[IPA_IP_v6],
+		IPA_RESOURCE_NAME_MAX);
+	IPACMDBG_H("IPv6 routing table for rt name: %s\n", m_intra_interface_info.rt_tbl_name_for_rt[IPA_IP_v6]);
+
+	m_p_iface->eth_bridge_add_hdr_proc_ctx(m_p_iface->tx_prop->tx[0].hdr_l2_type,
+		&hdr_proc_ctx_hdl);
+	hdr_proc_ctx_for_intra_interface = hdr_proc_ctx_hdl;
+	IPACMDBG_H("Hdr proc ctx for intra-interface communication: hdl %d\n", hdr_proc_ctx_hdl);
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_new_iface_up(char rt_tbl_name_for_flt[][IPA_RESOURCE_NAME_MAX], char rt_tbl_name_for_rt[][IPA_RESOURCE_NAME_MAX],
+		IPACM_LanToLan_Iface *peer_iface)
+{
+	peer_iface_info new_peer;
+	ipa_hdr_l2_type peer_l2_hdr_type;
+
+	new_peer.peer = peer_iface;
+	memcpy(new_peer.rt_tbl_name_for_rt[IPA_IP_v4], rt_tbl_name_for_rt[IPA_IP_v4], IPA_RESOURCE_NAME_MAX);
+	memcpy(new_peer.rt_tbl_name_for_rt[IPA_IP_v6], rt_tbl_name_for_rt[IPA_IP_v6], IPA_RESOURCE_NAME_MAX);
+	memcpy(new_peer.rt_tbl_name_for_flt[IPA_IP_v4], rt_tbl_name_for_flt[IPA_IP_v4], IPA_RESOURCE_NAME_MAX);
+	memcpy(new_peer.rt_tbl_name_for_flt[IPA_IP_v6], rt_tbl_name_for_flt[IPA_IP_v6], IPA_RESOURCE_NAME_MAX);
+
+	peer_l2_hdr_type = peer_iface->m_p_iface->tx_prop->tx[0].hdr_l2_type;
+	increment_ref_cnt_peer_l2_hdr_type(peer_l2_hdr_type);
+	add_hdr_proc_ctx(peer_l2_hdr_type);
+
+	/* push the new peer_iface_info into the list */
+	m_peer_iface_info.push_front(new_peer);
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_client_add(uint8_t *mac)
+{
+	list<client_info>::iterator it_client;
+	list<peer_iface_info>::iterator it_peer_info;
+	client_info new_client;
+	bool flag[IPA_HDR_L2_MAX];
+
+	for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+	{
+		if(memcmp(it_client->mac_addr, mac, sizeof(it_client->mac_addr)) == 0)
+		{
+			IPACMDBG_H("This client has been added before.\n");
+			return;
+		}
+	}
+
+	if(m_client_info.size() == MAX_NUM_CLIENT)
+	{
+		IPACMDBG_H("The number of clients has reached maximum %d.\n", MAX_NUM_CLIENT);
+		return;
+	}
+
+	memcpy(new_client.mac_addr, mac, sizeof(new_client.mac_addr));
+	m_client_info.push_front(new_client);
+
+	client_info &front_client = m_client_info.front();
+
+	/* install inter-interface rules */
+	if(m_support_inter_iface_offload)
+	{
+		memset(flag, 0, sizeof(flag));
+		for(it_peer_info = m_peer_iface_info.begin(); it_peer_info != m_peer_iface_info.end(); it_peer_info++)
+		{
+			/* make sure add routing rule only once for each peer l2 header type */
+			if(flag[it_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type] == false)
+			{
+				/* add client routing rule for each peer interface */
+				add_client_rt_rule(&(*it_peer_info), &front_client);
+				flag[it_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type] = true;
+			}
+
+			/* add client filtering rule on peer interfaces */
+			it_peer_info->peer->add_one_client_flt_rule(this, &front_client);
+		}
+	}
+
+	/* install intra-interface rules */
+	if(m_support_intra_iface_offload)
+	{
+		/* add routing rule first */
+		add_client_rt_rule(&m_intra_interface_info, &front_client);
+
+		/* add filtering rule */
+		if(m_is_ip_addr_assigned[IPA_IP_v4])
+		{
+			add_client_flt_rule(&m_intra_interface_info, &front_client, IPA_IP_v4);
+		}
+		if(m_is_ip_addr_assigned[IPA_IP_v6])
+		{
+			add_client_flt_rule(&m_intra_interface_info, &front_client, IPA_IP_v6);
+		}
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::handle_client_del(uint8_t *mac)
+{
+	list<client_info>::iterator it_client;
+	list<peer_iface_info>::iterator it_peer_info;
+	bool flag[IPA_HDR_L2_MAX];
+
+	for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+	{
+		if(memcmp(it_client->mac_addr, mac, sizeof(it_client->mac_addr)) == 0)	//found the client
+		{
+			IPACMDBG_H("Found the client.\n");
+			break;
+		}
+	}
+
+	if(it_client != m_client_info.end())	//if we found the client
+	{
+		/* uninstall inter-interface rules */
+		if(m_support_inter_iface_offload)
+		{
+			memset(flag, 0, sizeof(flag));
+			for(it_peer_info = m_peer_iface_info.begin(); it_peer_info != m_peer_iface_info.end();
+				it_peer_info++)
+			{
+				IPACMDBG_H("Delete client filtering rule on peer interface.\n");
+				it_peer_info->peer->del_one_client_flt_rule(this, &(*it_client));
+
+				/* make sure to delete routing rule only once for each peer l2 header type */
+				if(flag[it_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type] == false)
+				{
+					IPACMDBG_H("Delete client routing rule for peer interface.\n");
+					del_client_rt_rule(&(*it_peer_info), &(*it_client));
+					flag[it_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type] = true;
+				}
+			}
+		}
+
+		/* uninstall intra-interface rules */
+		if(m_support_intra_iface_offload)
+		{
+			/* delete filtering rule first */
+			IPACMDBG_H("Delete client filtering rule for intra-interface communication.\n");
+			del_client_flt_rule(&m_intra_interface_info, &(*it_client));
+
+			/* delete routing rule */
+			IPACMDBG_H("Delete client routing rule for intra-interface communication.\n");
+			del_client_rt_rule(&m_intra_interface_info, &(*it_client));
+		}
+
+		/* erase the client from client info list */
+		m_client_info.erase(it_client);
+	}
+	else
+	{
+		IPACMDBG_H("The client is not found.\n");
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::add_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type)
+{
+	uint32_t hdr_proc_ctx_hdl;
+
+	if(ref_cnt_peer_l2_hdr_type[peer_l2_type] == 1)
+	{
+		m_p_iface->eth_bridge_add_hdr_proc_ctx(peer_l2_type, &hdr_proc_ctx_hdl);
+		hdr_proc_ctx_for_inter_interface[peer_l2_type] = hdr_proc_ctx_hdl;
+		IPACMDBG_H("Installed inter-interface hdr proc ctx on iface %s: handle %d\n", m_p_iface->dev_name, hdr_proc_ctx_hdl);
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::del_hdr_proc_ctx(ipa_hdr_l2_type peer_l2_type)
+{
+	if(ref_cnt_peer_l2_hdr_type[peer_l2_type] == 0)
+	{
+		m_p_iface->eth_bridge_del_hdr_proc_ctx(hdr_proc_ctx_for_inter_interface[peer_l2_type]);
+		IPACMDBG_H("Hdr proc ctx with hdl %d is deleted.\n", hdr_proc_ctx_for_inter_interface[peer_l2_type]);
+	}
+	return;
+}
+
+void IPACM_LanToLan_Iface::print_data_structure_info()
+{
+	list<peer_iface_info>::iterator it_peer;
+	list<client_info>::iterator it_client;
+	int i, j, k;
+
+	IPACMDBG_H("\n");
+	IPACMDBG_H("Interface %s:\n", m_p_iface->dev_name);
+	IPACMDBG_H("Is IPv4 addr assigned? %d\n", m_is_ip_addr_assigned[IPA_IP_v4]);
+	IPACMDBG_H("Is IPv6 addr assigned? %d\n", m_is_ip_addr_assigned[IPA_IP_v6]);
+	IPACMDBG_H("Support inter interface offload? %d\n", m_support_inter_iface_offload);
+	IPACMDBG_H("Support intra interface offload? %d\n", m_support_intra_iface_offload);
+
+	if(m_support_inter_iface_offload)
+	{
+		for(i = 0; i < IPA_HDR_L2_MAX; i++)
+		{
+			IPACMDBG_H("Ref_cnt of peer l2 type %s is %d.\n", ipa_l2_hdr_type[i], ref_cnt_peer_l2_hdr_type[i]);
+			if(ref_cnt_peer_l2_hdr_type[i] > 0)
+			{
+				IPACMDBG_H("Hdr proc ctx for peer l2 type %s: %d\n", ipa_l2_hdr_type[i], hdr_proc_ctx_for_inter_interface[i]);
+			}
+		}
+	}
+
+	if(m_support_intra_iface_offload)
+	{
+		IPACMDBG_H("Hdr proc ctx for intra-interface: %d\n", hdr_proc_ctx_for_intra_interface);
+	}
+
+	i = 1;
+	IPACMDBG_H("There are %d clients in total.\n", m_client_info.size());
+	for(it_client = m_client_info.begin(); it_client != m_client_info.end(); it_client++)
+	{
+		IPACMDBG_H("Client %d MAC: 0x%02x%02x%02x%02x%02x%02x Pointer: 0x%08x\n", i, it_client->mac_addr[0], it_client->mac_addr[1],
+			it_client->mac_addr[2], it_client->mac_addr[3], it_client->mac_addr[4], it_client->mac_addr[5], &(*it_client));
+
+		if(m_support_inter_iface_offload)
+		{
+			for(j = 0; j < IPA_HDR_L2_MAX; j++)
+			{
+				if(ref_cnt_peer_l2_hdr_type[j] > 0)
+				{
+					IPACMDBG_H("Printing routing rule info for inter-interface communication for peer l2 type %s.\n",
+						ipa_l2_hdr_type[j]);
+					IPACMDBG_H("Number of IPv4 routing rules is %d, handles:\n", it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v4]);
+					for(k = 0; k < it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v4]; k++)
+					{
+						IPACMDBG_H("%d\n", it_client->inter_iface_rt_rule_hdl[j].rule_hdl[IPA_IP_v4][k]);
+					}
+
+					IPACMDBG_H("Number of IPv6 routing rules is %d, handles:\n", it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v6]);
+					for(k = 0; k < it_client->inter_iface_rt_rule_hdl[j].num_hdl[IPA_IP_v6]; k++)
+					{
+						IPACMDBG_H("%d\n", it_client->inter_iface_rt_rule_hdl[j].rule_hdl[IPA_IP_v6][k]);
+					}
+				}
+			}
+		}
+
+		if(m_support_intra_iface_offload)
+		{
+			IPACMDBG_H("Printing routing rule info for intra-interface communication.\n");
+			IPACMDBG_H("Number of IPv4 routing rules is %d, handles:\n", it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4]);
+			for(j = 0; j < it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v4]; j++)
+			{
+				IPACMDBG_H("%d\n", it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v4][j]);
+			}
+
+			IPACMDBG_H("Number of IPv6 routing rules is %d, handles:\n", it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6]);
+			for(j = 0; j < it_client->intra_iface_rt_rule_hdl.num_hdl[IPA_IP_v6]; j++)
+			{
+				IPACMDBG_H("%d\n", it_client->intra_iface_rt_rule_hdl.rule_hdl[IPA_IP_v6][j]);
+			}
+		}
+		i++;
+	}
+
+	IPACMDBG_H("There are %d peer interfaces in total.\n", m_peer_iface_info.size());
+	for(it_peer = m_peer_iface_info.begin(); it_peer != m_peer_iface_info.end(); it_peer++)
+	{
+		print_peer_info(&(*it_peer));
+	}
+
+	if(m_support_intra_iface_offload)
+	{
+		IPACMDBG_H("This interface supports intra-interface communication, printing info:\n");
+		print_peer_info(&m_intra_interface_info);
+	}
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::print_peer_info(peer_iface_info *peer_info)
+{
+	list<flt_rule_info>::iterator it_flt;
+	list<rt_rule_info>::iterator it_rt;
+
+	IPACMDBG_H("Printing peer info for iface %s:\n", peer_info->peer->m_p_iface->dev_name);
+
+	IPACMDBG_H("There are %d flt info in total.\n", peer_info->flt_rule.size());
+	for(it_flt = peer_info->flt_rule.begin(); it_flt != peer_info->flt_rule.end(); it_flt++)
+	{
+		IPACMDBG_H("Flt rule handle for client 0x%08x:\n", it_flt->p_client);
+		if(m_is_ip_addr_assigned[IPA_IP_v4])
+		{
+			IPACMDBG_H("IPv4 %d\n", it_flt->flt_rule_hdl[IPA_IP_v4]);
+		}
+		if(m_is_ip_addr_assigned[IPA_IP_v6])
+		{
+			IPACMDBG_H("IPv6 %d\n", it_flt->flt_rule_hdl[IPA_IP_v6]);
+		}
+	}
+
+	return;
+}
+
+IPACM_Lan* IPACM_LanToLan_Iface::get_iface_pointer()
+{
+	return m_p_iface;
+}
+
+bool IPACM_LanToLan_Iface::get_m_is_ip_addr_assigned(ipa_ip_type iptype)
+{
+	IPACMDBG_H("Has IP address been assigned to interface %s for IP type %d? %d\n",
+		m_p_iface->dev_name, iptype, m_is_ip_addr_assigned[iptype]);
+	return m_is_ip_addr_assigned[iptype];
+}
+
+void IPACM_LanToLan_Iface::set_m_is_ip_addr_assigned(ipa_ip_type iptype, bool value)
+{
+	IPACMDBG_H("Is IP address of IP type %d assigned to interface %s? %d\n", iptype,
+		m_p_iface->dev_name, value);
+	m_is_ip_addr_assigned[iptype] = value;
+}
+
+bool IPACM_LanToLan_Iface::get_m_support_inter_iface_offload()
+{
+	IPACMDBG_H("Support inter interface offload on %s? %d\n", m_p_iface->dev_name,
+		m_support_inter_iface_offload);
+	return m_support_inter_iface_offload;
+}
+
+bool IPACM_LanToLan_Iface::get_m_support_intra_iface_offload()
+{
+	IPACMDBG_H("Support intra interface offload on %s? %d\n", m_p_iface->dev_name,
+		m_support_intra_iface_offload);
+	return m_support_intra_iface_offload;
+}
+
+void IPACM_LanToLan_Iface::increment_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type)
+{
+	ref_cnt_peer_l2_hdr_type[peer_l2_type]++;
+	IPACMDBG_H("Now the ref_cnt of peer l2 hdr type %s is %d.\n", ipa_l2_hdr_type[peer_l2_type],
+		ref_cnt_peer_l2_hdr_type[peer_l2_type]);
+
+	return;
+}
+
+void IPACM_LanToLan_Iface::decrement_ref_cnt_peer_l2_hdr_type(ipa_hdr_l2_type peer_l2_type)
+{
+	ref_cnt_peer_l2_hdr_type[peer_l2_type]--;
+	IPACMDBG_H("Now the ref_cnt of peer l2 hdr type %s is %d.\n", ipa_l2_hdr_type[peer_l2_type],
+		ref_cnt_peer_l2_hdr_type[peer_l2_type]);
+
 	return;
 }
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index a725649..fe13e67 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -684,6 +684,7 @@
 
 void IPACM_Sig_Handler(int sig)
 {
+	int cnt;
 	ipacm_cmd_q_data evt_data;
 
 	printf("Received Signal: %d\n", sig);
@@ -729,11 +730,11 @@
 	IPACMDBG_H("In main()\n");
 	IPACM_Neighbor *neigh = new IPACM_Neighbor();
 	IPACM_IfaceManager *ifacemgr = new IPACM_IfaceManager();
-#ifndef FEATURE_ETH_BRIDGE_LE
-#ifndef FEATURE_IPA_ANDROID
+
+#ifdef FEATURE_ETH_BRIDGE_LE
 	IPACM_LanToLan* lan2lan = new IPACM_LanToLan();
-#endif /* defined(FEATURE_IPA_ANDROID)*/
 #endif
+
 	IPACM_ConntrackClient *cc = IPACM_ConntrackClient::GetInstance();
 	CtList = new IPACM_ConntrackListener();
 
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index 464e40d..375a718 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -54,8 +54,6 @@
 /* static member to store the number of total wifi clients within all APs*/
 int IPACM_Wlan::total_num_wifi_clients = 0;
 
-uint32_t* IPACM_Wlan::dummy_flt_rule_hdl_v4 = NULL;
-uint32_t* IPACM_Wlan::dummy_flt_rule_hdl_v6 = NULL;
 int IPACM_Wlan::num_wlan_ap_iface = 0;
 
 IPACM_Wlan::IPACM_Wlan(int iface_index) : IPACM_Lan(iface_index)
@@ -107,61 +105,13 @@
 	IPACM_Wlan::num_wlan_ap_iface++;
 	IPACMDBG_H("Now the number of wlan AP iface is %d\n", IPACM_Wlan::num_wlan_ap_iface);
 
-	is_guest_ap = false;
+	m_is_guest_ap = false;
 	if (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == INTERNET)
 	{
-		is_guest_ap = true;
+		m_is_guest_ap = true;
 	}
 	IPACMDBG_H("%s: guest ap enable: %d \n",
-		IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, is_guest_ap);
-
-	eth_bridge_wlan_client_rt_from_lan_info_v4 = NULL;
-	eth_bridge_wlan_client_rt_from_lan_info_v6 = NULL;
-	eth_bridge_wlan_client_rt_from_wlan_info_v4 = NULL;
-	eth_bridge_wlan_client_rt_from_wlan_info_v6 = NULL;
-	if(tx_prop != NULL)
-	{
-#ifdef FEATURE_ETH_BRIDGE_LE
-		client_rt_info_size_v4 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v4 * sizeof(uint32_t);
-		eth_bridge_wlan_client_rt_from_lan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v4);
-		eth_bridge_wlan_client_rt_from_wlan_info_v4 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v4);
-
-		client_rt_info_size_v6 = sizeof(eth_bridge_client_rt_info) + each_client_rt_rule_count_v6 * sizeof(uint32_t);
-		eth_bridge_wlan_client_rt_from_lan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
-		eth_bridge_wlan_client_rt_from_wlan_info_v6 = (eth_bridge_client_rt_info*)calloc(IPA_LAN_TO_LAN_MAX_WLAN_CLIENT, client_rt_info_size_v6);
-#endif
-	}
-	wlan_client_rt_from_lan_info_count_v4 = 0;
-	wlan_client_rt_from_lan_info_count_v6 = 0;
-	wlan_client_rt_from_wlan_info_count_v4 = 0;
-	wlan_client_rt_from_wlan_info_count_v6 = 0;
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(iface_query != NULL)
-	{
-		if(ipa_if_cate == WLAN_IF && tx_prop != NULL)
-		{
-			if(IPACM_Lan::wlan_hdr_type != IPA_HDR_L2_NONE && tx_prop->tx[0].hdr_l2_type != IPACM_Lan::wlan_hdr_type)
-			{
-				IPACMERR("The WLAN header format is not consistent! Now header format is %d.\n", tx_prop->tx[0].hdr_l2_type);
-			}
-			else
-			{
-				if(wlan_ap_index == 0)
-				{
-					if(eth_bridge_get_hdr_template_hdl(&IPACM_Lan::wlan_hdr_template_hdl) == IPACM_FAILURE)
-					{
-						IPACMERR("Failed to setup wlan hdr template.\n");
-					}
-					else
-					{
-						IPACM_Lan::wlan_hdr_type = tx_prop->tx[0].hdr_l2_type;
-						add_hdr_proc_ctx();
-					}
-				}
-			}
-		}
-	}
-#endif
+		IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, m_is_guest_ap);
 
 #ifdef FEATURE_IPA_ANDROID
 	/* set the IPA-client pipe enum */
@@ -574,31 +524,15 @@
 			ipa_interface_index = iface_ipa_index_query(data->if_index);
 			if (ipa_interface_index == ipa_if_num)
 			{
-#ifdef FEATURE_ETH_BRIDGE_LE
 				int i;
 				for(i=0; i<data->num_of_attribs; i++)
 				{
 					if(data->attribs[i].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)
 					{
-						if (is_guest_ap == false)
-						{
-							if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-							{
-								eth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_WLAN, IPA_IP_v4);
-								eth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_WLAN, IPA_IP_v6);
-							}
-							if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-							{
-								eth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_LAN, IPA_IP_v4);
-								eth_bridge_add_wlan_client_rt_rule(data->attribs[i].u.mac_addr, SRC_LAN, IPA_IP_v6);
-							}
-							eth_bridge_post_lan_client_event(data->attribs[i].u.mac_addr, IPA_ETH_BRIDGE_CLIENT_ADD_EVENT);
-							eth_bridge_add_client(data->attribs[i].u.mac_addr);
-						}
+						eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_ADD, IPA_IP_MAX, data->attribs[i].u.mac_addr);
 						break;
 					}
 				}
-#endif
 				IPACMDBG_H("Received IPA_WLAN_CLIENT_ADD_EVENT\n");
 				handle_wlan_client_init_ex(data);
 			}
@@ -612,24 +546,7 @@
 			if (ipa_interface_index == ipa_if_num)
 			{
 				IPACMDBG_H("Received IPA_WLAN_CLIENT_DEL_EVENT\n");
-#ifdef FEATURE_ETH_BRIDGE_LE
-				if (is_guest_ap == false)
-				{
-					if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_wlan_client_rt_rule(data->mac_addr, SRC_WLAN);
-					}
-					if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-					{
-						eth_bridge_del_wlan_client_rt_rule(data->mac_addr, SRC_LAN);
-					}
-					eth_bridge_post_lan_client_event(data->mac_addr, IPA_ETH_BRIDGE_CLIENT_DEL_EVENT);
-					eth_bridge_del_client(data->mac_addr);
-				}
-#endif
-				/* support lan2lan ipa-HW feature*/
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v4);
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v6);
+				eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_DEL, IPA_IP_MAX, data->mac_addr);
 				handle_wlan_client_down_evt(data->mac_addr);
 			}
 		}
@@ -642,9 +559,6 @@
 			if (ipa_interface_index == ipa_if_num)
 			{
 				IPACMDBG_H("Received IPA_WLAN_CLIENT_POWER_SAVE_EVENT\n");
-				/* support lan2lan ipa-HW feature*/
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_SAVE, IPA_IP_v4);
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_SAVE, IPA_IP_v6);
 				handle_wlan_client_pwrsave(data->mac_addr);
 			}
 		}
@@ -657,9 +571,6 @@
 			if (ipa_interface_index == ipa_if_num)
 			{
 				IPACMDBG_H("Received IPA_WLAN_CLIENT_RECOVER_EVENT\n");
-				/* support lan2lan ipa-HW feature*/
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_RECOVER, IPA_IP_v4);
-				handle_lan2lan_msg_post(data->mac_addr, IPA_LAN_CLIENT_POWER_RECOVER, IPA_IP_v6);
 
 				wlan_index = get_wlan_client_index(data->mac_addr);
 				if ((wlan_index != IPACM_INVALID_INDEX) &&
@@ -702,8 +613,6 @@
 				{
 					return;
 				}
-				/* support lan2lan ipa-hw feature */
-				handle_lan2lan_client_active(data, IPA_LAN_CLIENT_ACTIVE);
 
 				handle_wlan_client_route_rule(data->mac_addr, data->iptype);
 				if (data->iptype == IPA_IP_v4)
@@ -728,142 +637,18 @@
 		IPACM_Iface::handle_software_routing_disable();
 		break;
 
-	case IPA_ETH_BRIDGE_CLIENT_ADD_EVENT:
-		{
-			IPACMDBG_H("Received IPA_ETH_BRIDGE_CLIENT_ADD_EVENT event.\n");
-			ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
-			if(is_guest_ap == true)
-			{
-				IPACMDBG_H("%s iface is wlan guest ap, return.\n", dev_name);
-				return;
-			}
-
-			if(mac != NULL)
-			{
-				if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
-				{
-					eth_bridge_add_client_flt_rule(mac->mac_addr, IPA_IP_v4, mac->ipa_if_cate);
-				}
-				if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
-				{
-					eth_bridge_add_client_flt_rule(mac->mac_addr, IPA_IP_v6, mac->ipa_if_cate);
-				}
-			}
-			else
-			{
-				IPACMERR("Event MAC is empty.\n");
-			}
-		}
-		break;
-
-	case IPA_ETH_BRIDGE_CLIENT_DEL_EVENT:
-		{
-			IPACMDBG_H("Received IPA_ETH_BRIDGE_CLIENT_DEL_EVENT event.\n");
-			ipacm_event_data_mac* mac = (ipacm_event_data_mac*)param;
-			if(is_guest_ap == true)
-			{
-				IPACMDBG_H("%s iface is wlan guest ap, return.\n", dev_name);
-				return;
-			}
-			if(mac != NULL)
-			{
-				if(eth_bridge_del_client_flt_rule(mac->mac_addr) == IPACM_FAILURE)
-				{
-					IPACMDBG_H("Failed to delete client MAC based flt rule.\n");
-				}
-			}
-			else
-			{
-				IPACMERR("Event MAC is empty.\n");
-			}
-		}
-		break;
-
-	case IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT:
-	{
-		IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_SET_EVENT event.\n");
-		int i;
-		ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
-		if(cat == NULL)
-		{
-			IPACMERR("Event data is empty.\n");
-			return;
-		}
-		if(cat->if_cat != LAN_IF && cat->if_cat != ODU_IF)
-		{
-			IPACMDBG_H("The event was not sent by LAN interface, ignore.\n");
-			return;
-		}
-		if(is_guest_ap == true)
-		{
-			IPACMDBG_H("%s iface is wlan guest ap, return.\n", dev_name);
-			return;
-		}
-		if (IPACM_Lan::is_usb_up == true && IPACM_Lan::is_cpe_up == true)
-		{
-			IPACMDBG_H("USB and CPE both are up, lan-wlan routing rules are already installed. \n");
-			return;
-		}
-		for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-		{
-			if(IPACM_Lan::eth_bridge_client[i].ipa_if_num == ipa_if_num)
-			{
-				eth_bridge_add_wlan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN, IPA_IP_v4);
-				eth_bridge_add_wlan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN, IPA_IP_v6);
-			}
-		}
-	}
-	break;
-
-	case IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT:
-	{
-		IPACMDBG_H("Received IPA_ETH_BRIDGE_HDR_PROC_CTX_UNSET_EVENT event.\n");
-		int i;
-		ipacm_event_data_if_cat* cat = (ipacm_event_data_if_cat*)param;
-		if(cat == NULL)
-		{
-			IPACMERR("Event data is empty.\n");
-			return;
-		}
-		if(cat->if_cat != LAN_IF && cat->if_cat != ODU_IF)
-		{
-			IPACMDBG_H("The event was not sent by LAN interface, ignore.\n");
-			return;
-		}
-		if(is_guest_ap == true)
-		{
-			IPACMDBG_H("%s iface is wlan guest ap, return.\n", dev_name);
-			return;
-		}
-		if (IPACM_Lan::is_usb_up == true || IPACM_Lan::is_cpe_up == true)
-		{
-			IPACMDBG_H("USB or CPE is still up, so keep lan-wlan routing rule. \n");
-			return;
-		}
-		for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-		{
-			if(IPACM_Lan::eth_bridge_client[i].ipa_if_num == ipa_if_num)
-			{
-				eth_bridge_del_wlan_client_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN);
-			}
-		}
-	}
-	break;
-
 	case IPA_WLAN_SWITCH_TO_SCC:
 		IPACMDBG_H("Received IPA_WLAN_SWITCH_TO_SCC\n");
 		if(ip_type == IPA_IP_MAX)
 		{
 			handle_SCC_MCC_switch(IPA_IP_v4);
 			handle_SCC_MCC_switch(IPA_IP_v6);
-			eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v4);
-			eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v6);
 		}
 		else
 		{
 			handle_SCC_MCC_switch(ip_type);
-			eth_bridge_handle_wlan_SCC_MCC_switch(ip_type);
 		}
+		eth_bridge_post_event(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, IPA_IP_MAX, NULL);
 		break;
 
 	case IPA_WLAN_SWITCH_TO_MCC:
@@ -872,14 +657,12 @@
 		{
 			handle_SCC_MCC_switch(IPA_IP_v4);
 			handle_SCC_MCC_switch(IPA_IP_v6);
-			eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v4);
-			eth_bridge_handle_wlan_SCC_MCC_switch(IPA_IP_v6);
 		}
 		else
 		{
 			handle_SCC_MCC_switch(ip_type);
-			eth_bridge_handle_wlan_SCC_MCC_switch(ip_type);
 		}
+		eth_bridge_post_event(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, IPA_IP_MAX, NULL);
 		break;
 
 	case IPA_CRADLE_WAN_MODE_SWITCH:
@@ -907,7 +690,7 @@
 		IPACMDBG_H("Received IPA_CFG_CHANGE_EVENT event for %s with new wlan-mode: %s old wlan-mode: %s\n",
 				IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name,
 				(IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == 0) ? "full" : "internet",
-				(is_guest_ap == true) ? "internet" : "full");
+				(m_is_guest_ap == true) ? "internet" : "full");
 		/* Add Natting iface to IPACM_Config if there is  Rx/Tx property */
 		if (rx_prop != NULL || tx_prop != NULL)
 		{
@@ -915,15 +698,15 @@
 			IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name);
 		}
 
-		if (is_guest_ap == true && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == FULL))
+		if (m_is_guest_ap == true && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == FULL))
 		{
-			is_guest_ap = false;
+			m_is_guest_ap = false;
 			IPACMDBG_H("wlan mode is switched to full access mode. \n");
 			eth_bridge_handle_wlan_mode_switch();
 		}
-		else if (is_guest_ap == false && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == INTERNET))
+		else if (m_is_guest_ap == false && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == INTERNET))
 		{
-			is_guest_ap = true;
+			m_is_guest_ap = true;
 			IPACMDBG_H("wlan mode is switched to internet only access mode. \n");
 			eth_bridge_handle_wlan_mode_switch();
 		}
@@ -958,72 +741,6 @@
 	return;
 }
 
-int IPACM_Wlan::add_dummy_lan2lan_flt_rule(ipa_ip_type iptype)
-{
-	if(rx_prop == NULL)
-	{
-		IPACMDBG_H("There is no rx_prop for iface %s, not able to add dummy lan2lan filtering rule.\n", dev_name);
-		return IPACM_FAILURE;
-	}
-
-	int offset;
-	if(iptype == IPA_IP_v4)
-	{
-		if(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)
-		{
-			IPACMERR("Dummy ipv4 flt rule has not been installed.\n");
-			return IPACM_FAILURE;
-		}
-
-#ifndef CT_OPT
-		offset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)
-						+ IPV4_DEFAULT_FILTERTING_RULES;
-#else
-		offset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet)
-						+ NUM_TCP_CTL_FLT_RULE + IPV4_DEFAULT_FILTERTING_RULES;
-#endif
-
-#ifdef FEATURE_IPA_ANDROID
-		offset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
-#endif
-		for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
-		{
-			lan2lan_flt_rule_hdl_v4[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+i];
-			lan2lan_flt_rule_hdl_v4[i].valid = false;
-			IPACMDBG_H("Lan2lan v4 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v4[i].rule_hdl);
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{
-		if(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)
-		{
-			IPACMERR("Dummy ipv6 flt rule has not been installed.\n");
-			return IPACM_FAILURE;
-		}
-
-#ifndef CT_OPT
-		offset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + MAX_OFFLOAD_PAIR);
-#else
-		offset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR)
-						+ NUM_TCP_CTL_FLT_RULE;
-#endif
-
-		for (int i = 0; i < MAX_OFFLOAD_PAIR; i++)
-		{
-			lan2lan_flt_rule_hdl_v6[i].rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+i];
-			lan2lan_flt_rule_hdl_v6[i].valid = false;
-			IPACMDBG_H("Lan2lan v6 flt rule %d hdl:0x%x\n", i, lan2lan_flt_rule_hdl_v6[i].rule_hdl);
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-		return IPACM_FAILURE;
-	}
-
-	return IPACM_SUCCESS;
-}
-
 /* handle wifi client initial,copy all partial headers (tx property) */
 int IPACM_Wlan::handle_wlan_client_init_ex(ipacm_event_data_wlan_ex *data)
 {
@@ -1811,14 +1528,6 @@
 		IPACMERR("Invalid iptype: 0x%x\n", ip_type);
 		goto fail;
 	}
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(wlan_ap_index == 0)
-	{
-		IPACM_Lan::wlan_hdr_type = IPA_HDR_L2_NONE;
-		IPACM_Lan::wlan_hdr_template_hdl = 0;
-		del_hdr_proc_ctx();
-	}
-#endif
 
 	/* delete wan filter rule */
 	if (IPACM_Wan::isWanUP(ipa_if_num) && rx_prop != NULL)
@@ -1846,12 +1555,6 @@
 		}
 		IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, NUM_IPV4_ICMP_FLT_RULE);
 
-#ifdef FEATURE_ETH_BRIDGE_LE
-		if(is_guest_ap == false)	//delete eth bridge flt rules only when it is not guest ap
-		{
-			eth_bridge_remove_all_client_flt_rule(IPA_IP_v4);
-		}
-#endif
 		if (m_filtering.DeleteFilteringHdls(dft_v4fl_rule_hdl, IPA_IP_v4, IPV4_DEFAULT_FILTERTING_RULES) == false)
 		{
 			IPACMERR("Error Deleting Filtering Rule, aborting...\n");
@@ -1896,13 +1599,6 @@
 		}
 		IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, NUM_IPV6_ICMP_FLT_RULE);
 
-#ifdef FEATURE_ETH_BRIDGE_LE
-		if(is_guest_ap == false)	//delete eth bridge flt rules only when it is not guest ap
-		{
-			eth_bridge_remove_all_client_flt_rule(IPA_IP_v6);
-		}
-#endif
-
 		if (m_filtering.DeleteFilteringHdls(dft_v6fl_rule_hdl, IPA_IP_v6, IPV6_DEFAULT_FILTERTING_RULES) == false)
 		{
 			IPACMERR("Error Adding RuleTable(1) to Filtering, aborting...\n");
@@ -1958,17 +1654,10 @@
 	/* clean wifi client rule*/
 	IPACMDBG_H("left %d wifi clients need to be deleted \n ", num_wifi_client);
 
+	eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_DOWN, IPA_IP_MAX, NULL);
+
 	for (i = 0; i < num_wifi_client; i++)
 	{
-#ifdef FEATURE_ETH_BRIDGE_LE
-		if (is_guest_ap == false)
-		{
-			eth_bridge_del_wlan_client_rt_rule(get_client_memptr(wlan_client, i)->mac, SRC_WLAN);
-			eth_bridge_del_wlan_client_rt_rule(get_client_memptr(wlan_client, i)->mac, SRC_LAN);
-			eth_bridge_del_client(get_client_memptr(wlan_client, i)->mac);
-			eth_bridge_post_lan_client_event(get_client_memptr(wlan_client, i)->mac, IPA_ETH_BRIDGE_CLIENT_DEL_EVENT);
-		}
-#endif
 		/* First reset nat rules and then route rules */
 		if(get_client_memptr(wlan_client, i)->ipv4_set == true)
 		{
@@ -1992,9 +1681,6 @@
 
 		IPACMDBG_H("Delete %d client header\n", num_wifi_client);
 
-		handle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v4);
-		handle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, IPA_IP_v6);
-
 		if(get_client_memptr(wlan_client, i)->ipv4_header_set == true)
 		{
 			if (m_header.DeleteHeaderHdl(get_client_memptr(wlan_client, i)->hdr_hdl_v4)
@@ -2064,40 +1750,7 @@
 	{
 		free(iface_query);
 	}
-#ifdef FEATURE_ETH_BRIDGE_LE
-	if(eth_bridge_lan_client_rt_from_lan_info_v4 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_lan_info_v4);
-	}
-	if(eth_bridge_lan_client_rt_from_lan_info_v6 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_lan_info_v6);
-	}
-	if(eth_bridge_lan_client_rt_from_wlan_info_v4 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_wlan_info_v4);
-	}
-	if(eth_bridge_lan_client_rt_from_wlan_info_v6 != NULL)
-	{
-		free(eth_bridge_lan_client_rt_from_wlan_info_v6);
-	}
-	if(eth_bridge_wlan_client_rt_from_lan_info_v4 != NULL)
-	{
-		free(eth_bridge_wlan_client_rt_from_lan_info_v4);
-	}
-	if(eth_bridge_wlan_client_rt_from_lan_info_v6 != NULL)
-	{
-		free(eth_bridge_wlan_client_rt_from_lan_info_v6);
-	}
-	if(eth_bridge_wlan_client_rt_from_wlan_info_v4 != NULL)
-	{
-		free(eth_bridge_wlan_client_rt_from_wlan_info_v4);
-	}
-	if(eth_bridge_wlan_client_rt_from_wlan_info_v6 != NULL)
-	{
-		free(eth_bridge_wlan_client_rt_from_wlan_info_v6);
-	}
-#endif
+
 	is_active = false;
 	post_del_self_evt();
 
@@ -2121,13 +1774,7 @@
 			IPACMERR("Failed to delete old iptype(%d) rules.\n", iptype);
 			return res;
 		}
-		/* Pass info to LAN2LAN module */
-		res = handle_lan2lan_msg_post(get_client_memptr(wlan_client, i)->mac, IPA_LAN_CLIENT_DISCONNECT, iptype);
-		if (res != IPACM_SUCCESS)
-		{
-			IPACMERR("Failed to posting delete old iptype(%d) address.\n", iptype);
-			return res;
-		}
+
 		/* Reset ip-address */
 		if(iptype == IPA_IP_v4)
 		{
@@ -2141,989 +1788,6 @@
 	return res;
 }
 
-/*handle lan2lan internal mesg posting*/
-int IPACM_Wlan::handle_lan2lan_msg_post(uint8_t *mac_addr, ipa_cm_event_id event,ipa_ip_type iptype)
-{
-	int client_index;
-	client_index = get_wlan_client_index(mac_addr);
-	if (client_index == IPACM_INVALID_INDEX)
-	{
-		IPACMDBG_H("wlan client not attached\n");
-		return IPACM_SUCCESS;
-	}
-
-	ipacm_event_lan_client* lan_client;
-	ipacm_cmd_q_data evt_data;
-	if((get_client_memptr(wlan_client, client_index)->ipv4_set == true)
-		&& (iptype == IPA_IP_v4)) /* handle ipv4 case*/
-	{
-		if(ip_type != IPA_IP_v4 && ip_type != IPA_IP_MAX)
-		{
-			IPACMERR("Client has IPv4 addr but iface does not have IPv4 up.\n");
-			return IPACM_FAILURE;
-		}
-
-		lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
-		if(lan_client == NULL)
-		{
-			IPACMERR("Unable to allocate memory.\n");
-			return IPACM_FAILURE;
-		}
-		memset(lan_client, 0, sizeof(ipacm_event_lan_client));
-
-		lan_client->iptype = IPA_IP_v4;
-		lan_client->ipv4_addr = get_client_memptr(wlan_client, client_index)->v4_addr;
-		lan_client->p_iface = this;
-
-		memset(&evt_data, 0, sizeof(evt_data));
-		evt_data.event = event;
-		evt_data.evt_data = (void*)lan_client;
-
-		IPACMDBG_H("Posting event: %d\n",event);
-		IPACM_EvtDispatcher::PostEvt(&evt_data);
-	}
-
-	if((get_client_memptr(wlan_client, client_index)->ipv6_set > 0)
-		&& (iptype == IPA_IP_v6)) /* handle v6 case: may be multiple v6 addr */
-	{
-		if(ip_type != IPA_IP_v6 && ip_type != IPA_IP_MAX)
-		{
-			IPACMERR("Client has IPv6 addr but iface does not have IPv6 up.\n");
-			return IPACM_FAILURE;
-		}
-		int i;
-
-		for(i=0; i<get_client_memptr(wlan_client, client_index)->ipv6_set; i++)
-		{
-			lan_client = (ipacm_event_lan_client*)malloc(sizeof(ipacm_event_lan_client));
-			if(lan_client == NULL)
-			{
-				IPACMERR("Unable to allocate memory.\n");
-				return IPACM_FAILURE;
-			}
-			memset(lan_client, 0, sizeof(ipacm_event_lan_client));
-
-			lan_client->iptype = IPA_IP_v6;
-			memcpy(lan_client->ipv6_addr, get_client_memptr(wlan_client, client_index)->v6_addr[i], 4*sizeof(uint32_t));
-			lan_client->p_iface = this;
-
-			memset(&evt_data, 0, sizeof(evt_data));
-			evt_data.event = event;
-			evt_data.evt_data = (void*)lan_client;
-
-			IPACMDBG_H("Posting event: %d\n",event);
-			IPACM_EvtDispatcher::PostEvt(&evt_data);
-		}
-	}
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Wlan::add_lan2lan_hdr(ipa_ip_type iptype, uint8_t* src_mac, uint8_t* dst_mac, uint32_t* hdr_hdl)
-{
-	if(tx_prop == NULL)
-	{
-		IPACMERR("There is no tx_prop, cannot add header.\n");
-		return IPACM_FAILURE;
-	}
-	if(src_mac == NULL || dst_mac == NULL)
-	{
-		IPACMERR("Either src_mac or dst_mac is null, cannot add header.\n");
-		return IPACM_FAILURE;
-	}
-	if(hdr_hdl == NULL)
-	{
-		IPACMERR("Header handle is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	int i, j, k, len;
-	int res = IPACM_SUCCESS;
-	char index[4];
-	struct ipa_ioc_copy_hdr sCopyHeader;
-	struct ipa_ioc_add_hdr *pHeader;
-
-	IPACMDBG_H("Get lan2lan header request, src_mac: 0x%02x%02x%02x%02x%02x%02x dst_mac: 0x%02x%02x%02x%02x%02x%02x\n",
-			src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], dst_mac[0], dst_mac[1],
-			dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]);
-
-	len = sizeof(struct ipa_ioc_add_hdr) + sizeof(struct ipa_hdr_add);
-	pHeader = (struct ipa_ioc_add_hdr *)malloc(len);
-	if (pHeader == NULL)
-	{
-		IPACMERR("Failed to allocate header\n");
-		return IPACM_FAILURE;
-	}
-	memset(pHeader, 0, len);
-
-	if(iptype == IPA_IP_v4)
-	{		/* copy partial header for v4*/
-		for(i=0; i<tx_prop->num_tx_props; i++)
-		{
-			if(tx_prop->tx[i].ip == IPA_IP_v4)
-			{
-				IPACMDBG_H("Got v4-header name from %d tx props\n", i);
-				memset(&sCopyHeader, 0, sizeof(sCopyHeader));
-				memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
-				IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
-				if(m_header.CopyHeader(&sCopyHeader) == false)
-				{
-					IPACMERR("Copy header failed\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
-				if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
-				{
-					IPACMERR("Header oversize\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
-				}
-
-				for(j=0; j<num_wifi_client; j++)	//Add src/dst mac to the header
-				{
-					if(memcmp(dst_mac, get_client_memptr(wlan_client, j)->mac, IPA_MAC_ADDR_SIZE) == 0)
-					{
-						break;
-					}
-				}
-				if(j == num_wifi_client)
-				{
-					IPACMERR("Not able to find the wifi client from mac addr.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACMDBG_H("Find wifi client at position %d\n", j);
-					for(k = 0; k < get_client_memptr(wlan_client, j)->p_hdr_info->num_of_attribs; k++)
-					{
-						if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)
-						{
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],
-									dst_mac, IPA_MAC_ADDR_SIZE);
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset + IPA_MAC_ADDR_SIZE],
-									src_mac, IPA_MAC_ADDR_SIZE);
-						}
-						else if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_STA_ID)
-						{
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],
-									&get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id,
-									sizeof(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id));
-						}
-						else
-						{
-							IPACMDBG_H("The attribute type is not expected!\n");
-						}
-					}
-				}
-
-				pHeader->commit = true;
-				pHeader->num_hdrs = 1;
-
-				memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
-				strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V4, sizeof(pHeader->hdr[0].name));
-				pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-				for(j=0; j<MAX_OFFLOAD_PAIR; j++)
-				{
-					if( lan2lan_hdr_hdl_v4[j].valid == false)
-					{
-						IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
-						break;
-					}
-				}
-				if(j == MAX_OFFLOAD_PAIR)
-				{
-					IPACMERR("Failed to find an available hdr index.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				lan2lan_hdr_hdl_v4[j].valid = true;
-				snprintf(index,sizeof(index), "%d", j);
-
-				if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
-				{
-					IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
-				pHeader->hdr[0].is_partial = 0;
-				pHeader->hdr[0].hdr_hdl = -1;
-				pHeader->hdr[0].status = -1;
-
-				if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
-				{
-					IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				IPACMDBG_H("Installed v4 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
-							pHeader->hdr[0].hdr_hdl);
-				*hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				lan2lan_hdr_hdl_v4[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				break;
-			}
-		}
-	}
-	else if(iptype == IPA_IP_v6)
-	{		/* copy partial header for v6*/
-		for(i=0; i<tx_prop->num_tx_props; i++)
-		{
-			if(tx_prop->tx[i].ip == IPA_IP_v6)
-			{
-				IPACMDBG_H("Got v6-header name from %d tx props\n", i);
-				memset(&sCopyHeader, 0, sizeof(sCopyHeader));
-				memcpy(sCopyHeader.name, tx_prop->tx[i].hdr_name, sizeof(sCopyHeader.name));
-
-				IPACMDBG_H("Header name: %s\n", sCopyHeader.name);
-				if(m_header.CopyHeader(&sCopyHeader) == false)
-				{
-					IPACMERR("Copy header failed\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-
-				IPACMDBG_H("Header length: %d, paritial: %d\n", sCopyHeader.hdr_len, sCopyHeader.is_partial);
-				if (sCopyHeader.hdr_len > IPA_HDR_MAX_SIZE)
-				{
-					IPACMERR("Header oversize\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					memcpy(pHeader->hdr[0].hdr, sCopyHeader.hdr, sCopyHeader.hdr_len);
-				}
-
-				for(j=0; j<num_wifi_client; j++)	//Add src/dst mac to the header
-				{
-					if(memcmp(dst_mac, get_client_memptr(wlan_client, j)->mac, IPA_MAC_ADDR_SIZE) == 0)
-					{
-						break;
-					}
-				}
-				if(j == num_wifi_client)
-				{
-					IPACMERR("Not able to find the wifi client from mac addr.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				else
-				{
-					IPACMDBG_H("Find wifi client at position %d\n", j);
-					for(k = 0; k < get_client_memptr(wlan_client, j)->p_hdr_info->num_of_attribs; k++)
-					{
-						if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_MAC_ADDR)
-						{
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],
-									dst_mac, IPA_MAC_ADDR_SIZE);
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset + IPA_MAC_ADDR_SIZE],
-									src_mac, IPA_MAC_ADDR_SIZE);
-						}
-						else if(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].attrib_type == WLAN_HDR_ATTRIB_STA_ID)
-						{
-							memcpy(&pHeader->hdr[0].hdr[get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].offset],
-									&get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id,
-									sizeof(get_client_memptr(wlan_client, j)->p_hdr_info->attribs[k].u.sta_id));
-						}
-						else
-						{
-							IPACMDBG_H("The attribute type is not expected!\n");
-						}
-					}
-				}
-
-				pHeader->commit = true;
-				pHeader->num_hdrs = 1;
-
-				memset(pHeader->hdr[0].name, 0, sizeof(pHeader->hdr[0].name));
-				strlcpy(pHeader->hdr[0].name, IPA_LAN_TO_LAN_WLAN_HDR_NAME_V6, sizeof(pHeader->hdr[0].name));
-				pHeader->hdr[0].name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-
-				for(j=0; j<MAX_OFFLOAD_PAIR; j++)
-				{
-					if( lan2lan_hdr_hdl_v6[j].valid == false)
-					{
-						IPACMDBG_H("Construct lan2lan hdr with index %d.\n", j);
-						break;
-					}
-				}
-				if(j == MAX_OFFLOAD_PAIR)
-				{
-					IPACMERR("Failed to find an available hdr index.\n");
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				lan2lan_hdr_hdl_v6[j].valid = true;
-				snprintf(index,sizeof(index), "%d", j);
-
-				if (strlcat(pHeader->hdr[0].name, index, sizeof(pHeader->hdr[0].name)) > IPA_RESOURCE_NAME_MAX)
-				{
-					IPACMERR(" header name construction failed exceed length (%d)\n", strlen(pHeader->hdr[0].name));
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				pHeader->hdr[0].hdr_len = sCopyHeader.hdr_len;
-				pHeader->hdr[0].is_partial = 0;
-				pHeader->hdr[0].hdr_hdl = -1;
-				pHeader->hdr[0].status = -1;
-
-				if (m_header.AddHeader(pHeader) == false || pHeader->hdr[0].status != 0)
-				{
-					IPACMERR("Ioctl IPA_IOC_ADD_HDR failed with status: %d\n", pHeader->hdr[0].status);
-					res = IPACM_FAILURE;
-					goto fail;
-				}
-				IPACMDBG_H("Installed v6 full header %s header handle 0x%08x\n", pHeader->hdr[0].name,
-							pHeader->hdr[0].hdr_hdl);
-				*hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				lan2lan_hdr_hdl_v6[j].hdr_hdl = pHeader->hdr[0].hdr_hdl;
-				break;
-			}
-		}
-	}
-	else
-	{
-		IPACMERR("IP type is not expected.\n");
-	}
-
-fail:
-	free(pHeader);
-	return res;
-}
-
-/* install TCP control filter rules */
-void IPACM_Wlan::install_tcp_ctl_flt_rule(ipa_ip_type iptype)
-{
-	if (rx_prop == NULL)
-	{
-		IPACMDBG_H("No rx properties registered for iface %s\n", dev_name);
-		return;
-	}
-
-	int i, len, res = IPACM_SUCCESS, offset;
-	struct ipa_flt_rule_mdfy flt_rule;
-	struct ipa_ioc_mdfy_flt_rule* pFilteringTable;
-
-	if (iptype == IPA_IP_v4)
-	{
-		if(IPACM_Wlan::dummy_flt_rule_hdl_v4 == NULL)
-		{
-			IPACMERR("Dummy ipv4 flt rule has not been installed.\n");
-			return;
-		}
-		offset = wlan_ap_index * (IPV4_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR + IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
-#ifdef FEATURE_IPA_ANDROID
-		offset = offset + wlan_ap_index * (IPA_MAX_PRIVATE_SUBNET_ENTRIES - IPACM_Iface::ipacmcfg->ipa_num_private_subnet);
-#endif
-	}
-	else
-	{
-		if(IPACM_Wlan::dummy_flt_rule_hdl_v6 == NULL)
-		{
-			IPACMERR("Dummy ipv6 flt rule has not been installed.\n");
-			return;
-		}
-		offset = wlan_ap_index * (IPV6_DEFAULT_FILTERTING_RULES + NUM_TCP_CTL_FLT_RULE + MAX_OFFLOAD_PAIR);
-	}
-
-	len = sizeof(struct ipa_ioc_mdfy_flt_rule) + NUM_TCP_CTL_FLT_RULE * sizeof(struct ipa_flt_rule_mdfy);
-	pFilteringTable = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
-	if (!pFilteringTable)
-	{
-		IPACMERR("Failed to allocate ipa_ioc_mdfy_flt_rule memory...\n");
-		return;
-	}
-	memset(pFilteringTable, 0, len);
-
-	pFilteringTable->commit = 1;
-	pFilteringTable->ip = iptype;
-	pFilteringTable->num_rules = NUM_TCP_CTL_FLT_RULE;
-
-	memset(&flt_rule, 0, sizeof(struct ipa_flt_rule_mdfy));
-	flt_rule.status = -1;
-
-	flt_rule.rule.retain_hdr = 1;
-	flt_rule.rule.to_uc = 0;
-	flt_rule.rule.action = IPA_PASS_TO_EXCEPTION;
-	flt_rule.rule.eq_attrib_type = 1;
-
-	flt_rule.rule.eq_attrib.rule_eq_bitmap = 0;
-
-	if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA)
-	{
-		flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<14);
-		flt_rule.rule.eq_attrib.metadata_meq32_present = 1;
-		flt_rule.rule.eq_attrib.metadata_meq32.offset = 0;
-		flt_rule.rule.eq_attrib.metadata_meq32.value = rx_prop->rx[0].attrib.meta_data;
-		flt_rule.rule.eq_attrib.metadata_meq32.mask = rx_prop->rx[0].attrib.meta_data_mask;
-	}
-
-	flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<1);
-	flt_rule.rule.eq_attrib.protocol_eq_present = 1;
-	flt_rule.rule.eq_attrib.protocol_eq = IPACM_FIREWALL_IPPROTO_TCP;
-
-	/* add TCP FIN rule*/
-	flt_rule.rule.eq_attrib.rule_eq_bitmap |= (1<<8);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);
-	flt_rule.rule.eq_attrib.num_ihl_offset_meq_32 = 1;
-	if(iptype == IPA_IP_v4)
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset];
-	}
-	else
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset];
-	}
-	memcpy(&(pFilteringTable->rules[0]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-
-	/* add TCP SYN rule*/
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_SYN_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_SYN_SHIFT);
-	if(iptype == IPA_IP_v4)
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+1];
-	}
-	else
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+1];
-	}
-	memcpy(&(pFilteringTable->rules[1]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-
-	/* add TCP RST rule*/
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);
-	flt_rule.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);
-	if(iptype == IPA_IP_v4)
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v4[offset+2];
-	}
-	else
-	{
-		flt_rule.rule_hdl = IPACM_Wlan::dummy_flt_rule_hdl_v6[offset+2];
-	}
-	memcpy(&(pFilteringTable->rules[2]), &flt_rule, sizeof(struct ipa_flt_rule_mdfy));
-
-	if (false == m_filtering.ModifyFilteringRule(pFilteringTable))
-	{
-		IPACMERR("Failed to modify tcp control filtering rules.\n");
-		goto fail;
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
-			{
-				tcp_ctl_flt_rule_hdl_v4[i] = pFilteringTable->rules[i].rule_hdl;
-			}
-		}
-		else
-		{
-			for(i=0; i<NUM_TCP_CTL_FLT_RULE; i++)
-			{
-				tcp_ctl_flt_rule_hdl_v6[i] = pFilteringTable->rules[i].rule_hdl;
-			}
-		}
-	}
-
-fail:
-	free(pFilteringTable);
-	return;
-}
-
-int IPACM_Wlan::eth_bridge_install_cache_client_flt_rule(ipa_ip_type iptype)
-{
-	int i;
-
-	if(is_guest_ap == true)
-	{
-		IPACMDBG_H("%s iface is wlan guest ap, return.\n", dev_name);
-		return IPACM_SUCCESS;
-	}
-
-	IPACMDBG_H("There are %d clients cached.\n", IPACM_Lan::eth_bridge_num_client);
-	for(i=0; i<IPACM_Lan::eth_bridge_num_client; i++)
-	{
-		eth_bridge_add_client_flt_rule(IPACM_Lan::eth_bridge_client[i].mac, iptype,
-			IPACM_Lan::eth_bridge_client[i].ipa_if_cate);
-	}
-	return IPACM_SUCCESS;
-}
-
-int IPACM_Wlan::eth_bridge_add_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
-	if(tx_prop == NULL)
-	{
-		IPACMDBG_H("Tx prop is empty, not adding routing rule.\n");
-		return IPACM_SUCCESS;
-	}
-	if(mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x src_iface: %d .\n",
-			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src);
-
-	if(iptype == IPA_IP_v4)
-	{
-		if( (src == SRC_WLAN && wlan_client_rt_from_wlan_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
-			|| (src == SRC_LAN && wlan_client_rt_from_lan_info_count_v4 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
-		{
-			IPACMDBG_H("WLAN client number has reached maximum.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		if( (src == SRC_WLAN && wlan_client_rt_from_wlan_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT)
-			|| (src == SRC_LAN && wlan_client_rt_from_lan_info_count_v6 == IPA_LAN_TO_LAN_MAX_WLAN_CLIENT))
-		{
-			IPACMDBG_H("WLAN client number has reached maximum.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	if( (src == SRC_WLAN && IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == false)
-		|| (src == SRC_LAN && IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == false) )
-	{
-		IPACMDBG_H("Hdr proc ctx has not been set for source %d, don't add WLAN client routing rule.\n", src);
-		return IPACM_FAILURE;
-	}
-
-	int i, len, res = IPACM_SUCCESS;
-	struct ipa_ioc_add_rt_rule* rt_rule_table = NULL;
-	struct ipa_rt_rule_add rt_rule;
-	int position, num_rt_rule;
-
-	if(src == SRC_WLAN)
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			for(i=0; i<wlan_client_rt_from_wlan_info_count_v4; i++)
-			{
-				if(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->mac));
-		}
-		else
-		{
-			for(i=0; i<wlan_client_rt_from_wlan_info_count_v6; i++)
-			{
-				if(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_WLAN, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->mac));
-		}
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			for(i=0; i<wlan_client_rt_from_lan_info_count_v4; i++)
-			{
-				if(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_LAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_LAN, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v4, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v4, src, iptype)->mac));
-		}
-		else
-		{
-			for(i=0; i<wlan_client_rt_from_lan_info_count_v6; i++)
-			{
-				if(memcmp(eth_bridge_get_client_rt_info_ptr(i, SRC_LAN, iptype)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, SRC_LAN, iptype)->mac)) == 0)
-				{
-					IPACMDBG_H("The client's routing rule was added before.\n");
-					return IPACM_SUCCESS;
-				}
-			}
-			memcpy(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v6, src, iptype)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v6, src, iptype)->mac));
-		}
-	}
-
-	if(iptype == IPA_IP_v4)
-	{
-		num_rt_rule = each_client_rt_rule_count_v4;
-	}
-	else
-	{
-		num_rt_rule = each_client_rt_rule_count_v6;
-	}
-
-	len = sizeof(ipa_ioc_add_rt_rule) + num_rt_rule * sizeof(ipa_rt_rule_add);
-	rt_rule_table = (ipa_ioc_add_rt_rule*)malloc(len);
-	if(rt_rule_table == NULL)
-	{
-		IPACMERR("Failed to allocate memory.\n");
-		return IPACM_FAILURE;
-	}
-	memset(rt_rule_table, 0, len);
-
-	rt_rule_table->commit = 1;
-	rt_rule_table->ip = iptype;
-	rt_rule_table->num_rules = num_rt_rule;
-	if(src == SRC_WLAN)
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-		else
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_wlan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v4.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-		else
-		{
-			strlcpy(rt_rule_table->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_eth_bridge_lan_wlan_v6.name, sizeof(rt_rule_table->rt_tbl_name));
-		}
-	}
-	rt_rule_table->rt_tbl_name[IPA_RESOURCE_NAME_MAX-1] = '\0';
-	memset(&rt_rule, 0, sizeof(ipa_rt_rule_add));
-	rt_rule.at_rear = false;
-	rt_rule.status = -1;
-	rt_rule.rt_rule_hdl = -1;
-#ifdef FEATURE_IPA_V3
-	rt_rule.rule.hashable = true;
-#endif
-	rt_rule.rule.hdr_hdl = 0;
-	if(src == SRC_WLAN)
-	{
-		rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
-	}
-	else
-	{
-		rt_rule.rule.hdr_proc_ctx_hdl = IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
-	}
-	position = 0;
-	for(i=0; i<iface_query->num_tx_props; i++)
-	{
-		if(tx_prop->tx[i].ip == iptype)
-		{
-			if(position >= num_rt_rule)
-			{
-				IPACMERR("Number of routing rules already exceeds limit.\n");
-				res = IPACM_FAILURE;
-				goto fail;
-			}
-			/* Handle MCC Mode case */
-			if (IPACM_Iface::ipacmcfg->isMCC_Mode == true)
-			{
-				IPACMDBG_H("In MCC mode, use alt dst pipe: %d\n",
-						tx_prop->tx[i].alt_dst_pipe);
-				rt_rule.rule.dst = tx_prop->tx[i].alt_dst_pipe;
-			}
-			else
-			{
-				rt_rule.rule.dst = tx_prop->tx[i].dst_pipe;
-			}
-
-			memcpy(&rt_rule.rule.attrib, &tx_prop->tx[i].attrib, sizeof(rt_rule.rule.attrib));
-			if(src == SRC_WLAN)	//src is WLAN means packet is from WLAN
-			{
-				if(IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			else	//packet is from LAN
-			{
-				if(IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			memcpy(rt_rule.rule.attrib.dst_mac_addr, mac, sizeof(rt_rule.rule.attrib.dst_mac_addr));
-			memset(rt_rule.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(rt_rule.rule.attrib.dst_mac_addr_mask));
-
-			memcpy(&(rt_rule_table->rules[position]), &rt_rule, sizeof(rt_rule_table->rules[position]));
-			position++;
-		}
-	}
-
-	if(false == m_routing.AddRoutingRule(rt_rule_table))
-	{
-		IPACMERR("Routing rule addition failed!\n");
-		res = IPACM_FAILURE;
-		goto fail;
-	}
-	else
-	{
-		if(src == SRC_WLAN)
-		{
-			for(i=0; i<num_rt_rule; i++)
-			{
-				if(iptype == IPA_IP_v4)
-				{
-					eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-				else
-				{
-					eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-			}
-			if(iptype == IPA_IP_v4)
-			{
-				wlan_client_rt_from_wlan_info_count_v4++;
-				IPACMDBG_H("Now the number of IPv4 rt rule on wlan-wlan rt table is %d.\n", wlan_client_rt_from_wlan_info_count_v4);
-			}
-			else
-			{
-				wlan_client_rt_from_wlan_info_count_v6++;
-				IPACMDBG_H("Now the number of IPv6 rt rule on wlan-wlan rt table is %d.\n", wlan_client_rt_from_wlan_info_count_v6);
-			}
-		}
-		else
-		{
-			for(i=0; i<num_rt_rule; i++)
-			{
-				if(iptype == IPA_IP_v4)
-				{
-					eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v4, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-				else
-				{
-					eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v6, src, iptype)->rt_rule_hdl[i] = rt_rule_table->rules[i].rt_rule_hdl;
-				}
-			}
-			if(iptype == IPA_IP_v4)
-			{
-				wlan_client_rt_from_lan_info_count_v4++;
-				IPACMDBG_H("Now the number of IPv4 rt rule on lan-wlan rt table is %d.\n", wlan_client_rt_from_lan_info_count_v4);
-			}
-			else
-			{
-				wlan_client_rt_from_lan_info_count_v6++;
-				IPACMDBG_H("Now the number of IPv6 rt rule on lan-wlan rt table is %d.\n", wlan_client_rt_from_lan_info_count_v6);
-			}
-		}
-	}
-
-fail:
-	if(rt_rule_table != NULL)
-	{
-		free(rt_rule_table);
-	}
-	return res;
-}
-
-int IPACM_Wlan::eth_bridge_del_wlan_client_rt_rule(uint8_t* mac, eth_bridge_src_iface src)
-{
-	if(tx_prop == NULL)
-	{
-		IPACMDBG_H("Tx prop is empty, not deleting routing rule.\n");
-		return IPACM_SUCCESS;
-	}
-	if(mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-
-	int i, position;
-
-	/* first delete the rt rules from IPv4 rt table*/
-	if(src == SRC_WLAN)
-	{
-		for(i=0; i<wlan_client_rt_from_wlan_info_count_v4; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == wlan_client_rt_from_wlan_info_count_v4)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		for(i=0; i<wlan_client_rt_from_lan_info_count_v4; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == wlan_client_rt_from_lan_info_count_v4)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	for(i=0; i<each_client_rt_rule_count_v4; i++)
-	{
-		if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v4)->rt_rule_hdl[i], IPA_IP_v4) == false)
-		{
-			IPACMERR("Failed to delete routing rule %d.\n", i);
-			return IPACM_FAILURE;
-		}
-	}
-
-	if(src == SRC_WLAN)
-	{
-		for(i=position+1; i<wlan_client_rt_from_wlan_info_count_v4; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
-		wlan_client_rt_from_wlan_info_count_v4--;
-		IPACMDBG_H("Now the number of IPv4 rt rule from wlan info is %d.\n", wlan_client_rt_from_wlan_info_count_v4);
-	}
-	else
-	{
-		for(i=position+1; i<wlan_client_rt_from_lan_info_count_v4; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v4), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v4), client_rt_info_size_v4);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v4-1, src, IPA_IP_v4), 0, client_rt_info_size_v4);
-		wlan_client_rt_from_lan_info_count_v4--;
-		IPACMDBG_H("Now the number of IPv4 rt rule from lan info is %d.\n", wlan_client_rt_from_lan_info_count_v4);
-	}
-
-	/*delete rt rules from IPv6 rt table */
-	if(src == SRC_WLAN)
-	{
-		for(i=0; i<wlan_client_rt_from_wlan_info_count_v6; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == wlan_client_rt_from_wlan_info_count_v6)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-	else
-	{
-		for(i=0; i<wlan_client_rt_from_lan_info_count_v6; i++)
-		{
-			if(memcmp(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac, mac, sizeof(eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6)->mac)) == 0)
-			{
-				position = i;
-				IPACMDBG_H("The client is found at position %d.\n", position);
-				break;
-			}
-		}
-		if(i == wlan_client_rt_from_lan_info_count_v6)
-		{
-			IPACMERR("The client is not found.\n");
-			return IPACM_FAILURE;
-		}
-	}
-
-	for(i=0; i<each_client_rt_rule_count_v6; i++)
-	{
-		if(m_routing.DeleteRoutingHdl(eth_bridge_get_client_rt_info_ptr(position, src, IPA_IP_v6)->rt_rule_hdl[i], IPA_IP_v6) == false)
-		{
-			IPACMERR("Failed to delete routing rule %d.\n", i);
-			return IPACM_FAILURE;
-		}
-	}
-
-	if(src == SRC_WLAN)
-	{
-		for(i=position+1; i<wlan_client_rt_from_wlan_info_count_v6; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_wlan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
-		wlan_client_rt_from_wlan_info_count_v6--;
-		IPACMDBG_H("Now the number of IPv6 rt rule from wlan info is %d.\n", wlan_client_rt_from_wlan_info_count_v6);
-	}
-	else
-	{
-		for(i=position+1; i<wlan_client_rt_from_lan_info_count_v6; i++)
-		{
-			memcpy(eth_bridge_get_client_rt_info_ptr(i-1, src, IPA_IP_v6), eth_bridge_get_client_rt_info_ptr(i, src, IPA_IP_v6), client_rt_info_size_v6);
-		}
-		memset(eth_bridge_get_client_rt_info_ptr(wlan_client_rt_from_lan_info_count_v6-1, src, IPA_IP_v6), 0, client_rt_info_size_v6);
-		wlan_client_rt_from_lan_info_count_v6--;
-		IPACMDBG_H("Now the number of IPv6 rt rule from lan info is %d.\n", wlan_client_rt_from_lan_info_count_v6);
-	}
-
-	return IPACM_SUCCESS;
-}
-
-eth_bridge_client_rt_info* IPACM_Wlan::eth_bridge_get_client_rt_info_ptr(uint8_t index, eth_bridge_src_iface src, ipa_ip_type iptype)
-{
-	char* result;
-	if(src == SRC_WLAN)
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			result = (char *)eth_bridge_wlan_client_rt_from_wlan_info_v4 + index * client_rt_info_size_v4;
-		}
-		else
-		{
-			result = (char *)eth_bridge_wlan_client_rt_from_wlan_info_v6 + index * client_rt_info_size_v6;
-		}
-	}
-	else
-	{
-		if(iptype == IPA_IP_v4)
-		{
-			result = (char *)eth_bridge_wlan_client_rt_from_lan_info_v4 + index * client_rt_info_size_v4;
-		}
-		else
-		{
-			result = (char *)eth_bridge_wlan_client_rt_from_lan_info_v6 + index * client_rt_info_size_v6;
-		}
-	}
-	return (eth_bridge_client_rt_info*)result;
-}
-
 void IPACM_Wlan::handle_SCC_MCC_switch(ipa_ip_type iptype)
 {
 	struct ipa_ioc_mdfy_rt_rule *rt_rule = NULL;
@@ -3331,333 +1995,36 @@
 	return;
 }
 
-void IPACM_Wlan::eth_bridge_handle_wlan_SCC_MCC_switch(ipa_ip_type iptype)
-{
-
-	for (int i= 0; i < IPACM_Lan::eth_bridge_num_client; i++)
-	{
-		if (IPACM_Lan::eth_bridge_client[i].ipa_if_num == ipa_if_num)
-		{
-			if (IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				if (eth_bridge_modify_wlan_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_WLAN, iptype) == IPACM_FAILURE)
-				{
-					IPACMDBG_H("SCC/MCC switch is failed for iptype: %d src_iface: %d \n", iptype, SRC_WLAN);
-					return;
-				}
-			}
-			if (IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				if (eth_bridge_modify_wlan_rt_rule(IPACM_Lan::eth_bridge_client[i].mac, SRC_LAN, iptype) == IPACM_FAILURE)
-				{
-					IPACMDBG_H("SCC/MCC switch is failed for iptype: %d src_iface: %d \n", iptype, SRC_LAN);
-					return;
-				}
-			}
-		}
-	}
-
-	IPACMDBG_H("SCC/MCC switch is successful for iptype: %d\n", iptype);
-}
-
-int IPACM_Wlan::eth_bridge_modify_wlan_rt_rule(uint8_t* mac, eth_bridge_src_iface src_iface, ipa_ip_type iptype)
-{
-	struct ipa_ioc_mdfy_rt_rule *rt_rule = NULL;
-	struct ipa_rt_rule_mdfy *rt_rule_entry;
-	uint32_t index = 0, num_rt_rule = 0, position;
-
-	if (tx_prop == NULL)
-	{
-		IPACMDBG_H("No tx properties \n");
-		return IPACM_FAILURE;
-	}
-
-	if (mac == NULL)
-	{
-		IPACMERR("Client MAC address is empty.\n");
-		return IPACM_FAILURE;
-	}
-
-	IPACMDBG_H("Receive WLAN client MAC 0x%02x%02x%02x%02x%02x%02x. src_iface: %d\n",
-			mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], src_iface);
-
-	if (iptype == IPA_IP_v4)
-	{
-		num_rt_rule = each_client_rt_rule_count_v4;
-	}
-	else
-	{
-		num_rt_rule = each_client_rt_rule_count_v6;
-	}
-
-	if (src_iface == SRC_WLAN)
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			for (index = 0; index < wlan_client_rt_from_wlan_info_count_v4; index++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac)) == 0)
-				{
-					position = index;
-					IPACMDBG_H("The client is found at position %d.\n", position);
-					break;
-				}
-			}
-			if (index == wlan_client_rt_from_wlan_info_count_v4)
-			{
-				IPACMERR("The client is not found.\n");
-				return IPACM_FAILURE;
-			}
-		}
-		else
-		{
-			for (index =0 ; index < wlan_client_rt_from_wlan_info_count_v6; index++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac)) == 0)
-				{
-					position = index;
-					IPACMDBG_H("The client is found at position %d.\n", position);
-					break;
-				}
-			}
-			if (index == wlan_client_rt_from_wlan_info_count_v6)
-			{
-				IPACMERR("The client is not found.\n");
-				return IPACM_FAILURE;
-			}
-		}
-	}
-	else
-	{
-		if (iptype == IPA_IP_v4)
-		{
-			for (index = 0; index < wlan_client_rt_from_lan_info_count_v4; index++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v4)->mac)) == 0)
-				{
-					position = index;
-					IPACMDBG_H("The client is found at position %d.\n", position);
-					break;
-				}
-			}
-			if (index == wlan_client_rt_from_lan_info_count_v4)
-			{
-				IPACMERR("The client is not found.\n");
-				return IPACM_FAILURE;
-			}
-		}
-		else
-		{
-			for (index = 0; index < wlan_client_rt_from_lan_info_count_v6; index++)
-			{
-				if (memcmp(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac, mac,
-					sizeof(eth_bridge_get_client_rt_info_ptr(index, src_iface, IPA_IP_v6)->mac)) == 0)
-				{
-					position = index;
-					IPACMDBG_H("The client is found at position %d.\n", position);
-					break;
-				}
-			}
-			if (index == wlan_client_rt_from_lan_info_count_v6)
-			{
-				IPACMERR("The client is not found.\n");
-				return IPACM_FAILURE;
-			}
-		}
-	}
-
-	rt_rule = (struct ipa_ioc_mdfy_rt_rule *)
-			calloc(1, sizeof(struct ipa_ioc_mdfy_rt_rule) +
-			(num_rt_rule) * sizeof(struct ipa_rt_rule_mdfy));
-
-	if (rt_rule == NULL)
-	{
-		IPACMERR("Unable to allocate memory for modify rt rule\n");
-		return IPACM_FAILURE;
-	}
-	IPACMDBG("Allocated memory for %d rules successfully\n", num_rt_rule);
-
-	rt_rule->commit = 1;
-	rt_rule->num_rules = 0;
-	rt_rule->ip = iptype;
-
-	for (index = 0; index < tx_prop->num_tx_props; index++)
-	{
-		if (tx_prop->tx[index].ip == iptype)
-		{
-			if (rt_rule->num_rules >= num_rt_rule)
-			{
-				IPACMERR("Number of routing rules exceeds limit.\n");
-				free(rt_rule);
-				return IPACM_FAILURE;
-			}
-
-			rt_rule_entry = &rt_rule->rules[rt_rule->num_rules];
-
-			if (IPACM_Iface::ipacmcfg->isMCC_Mode)
-			{
-				IPACMDBG_H("In MCC mode, use alt dst pipe: %d\n",
-						tx_prop->tx[index].alt_dst_pipe);
-				rt_rule_entry->rule.dst = tx_prop->tx[index].alt_dst_pipe;
-			}
-			else
-			{
-				rt_rule_entry->rule.dst = tx_prop->tx[index].dst_pipe;
-			}
-
-			rt_rule_entry->rule.hdr_hdl = 0;
-
-			if (src_iface == SRC_WLAN)
-			{
-				rt_rule_entry->rule.hdr_proc_ctx_hdl =
-						IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
-			}
-			else
-			{
-				rt_rule_entry->rule.hdr_proc_ctx_hdl =
-						IPACM_Lan::lan_to_wlan_hdr_proc_ctx.proc_ctx_hdl;
-			}
-
-			memcpy(&rt_rule_entry->rule.attrib,
-					&tx_prop->tx[index].attrib,
-					sizeof(rt_rule_entry->rule.attrib));
-
-			if (src_iface == SRC_WLAN)	//src is WLAN means packet is from WLAN
-			{
-				if (IPACM_Lan::wlan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			else	//packet is from LAN
-			{
-				if (IPACM_Lan::lan_hdr_type == IPA_HDR_L2_ETHERNET_II)
-				{
-					rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II;
-				}
-				else
-				{
-					rt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3;
-				}
-			}
-			memcpy(rt_rule_entry->rule.attrib.dst_mac_addr, mac,
-					sizeof(rt_rule_entry->rule.attrib.dst_mac_addr));
-			memset(rt_rule_entry->rule.attrib.dst_mac_addr_mask, 0xFF,
-					sizeof(rt_rule_entry->rule.attrib.dst_mac_addr_mask));
-
-			rt_rule_entry->rt_rule_hdl =
-					eth_bridge_get_client_rt_info_ptr(position, src_iface, iptype)->rt_rule_hdl[rt_rule->num_rules];
-			IPACMDBG_H("tx:%d, rt rule hdl=%x ip-type: %d\n", index,
-				eth_bridge_get_client_rt_info_ptr(position, src_iface, iptype)->rt_rule_hdl[rt_rule->num_rules], iptype);
-
-			rt_rule->num_rules++;
-		}
-	}
-
-	if (rt_rule->num_rules > 0)
-	{
-		if (false == m_routing.ModifyRoutingRule(rt_rule))
-		{
-			IPACMERR("Routing rule modify failed!\n");
-			free(rt_rule);
-			return IPACM_FAILURE;
-		}
-		if (false == m_routing.Commit(iptype))
-		{
-			IPACMERR("Routing rule modify commit failed!\n");
-			free(rt_rule);
-			return IPACM_FAILURE;
-		}
-		IPACMDBG("Routing rule modified successfully \n");
-	}
-
-	if (rt_rule)
-	{
-		free(rt_rule);
-	}
-	return IPACM_SUCCESS;
-}
-
 void IPACM_Wlan::eth_bridge_handle_wlan_mode_switch()
 {
 	int i;
-	uint8_t mac[IPA_MAC_ADDR_SIZE];
 
-	if(is_guest_ap == true)	//switch from FULL to INTERNET mode
+	/* ====== post events to mimic WLAN interface goes down/up when AP mode is changing ====== */
+
+	/* first post IFACE_DOWN event */
+	eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_DOWN, IPA_IP_MAX, NULL);
+
+	/* then post IFACE_UP event */
+	if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
 	{
-		/* first delete all eth bridge flt rules */
-		if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
-		{
-			eth_bridge_remove_all_client_flt_rule(IPA_IP_v4);
-		}
-		if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
-		{
-			eth_bridge_remove_all_client_flt_rule(IPA_IP_v6);
-		}
-
-		for(i=0; i<num_wifi_client; i++)
-		{
-			memcpy(mac, get_client_memptr(wlan_client, i)->mac, sizeof(mac));
-
-			/* remove client info from the client array */
-			eth_bridge_del_client(mac);
-
-			/* delete all eth bridge rt rules */
-			if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				eth_bridge_del_wlan_client_rt_rule(mac, SRC_LAN);
-			}
-			if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				eth_bridge_del_wlan_client_rt_rule(mac, SRC_WLAN);
-			}
-
-			/* post client delete event */
-			eth_bridge_post_lan_client_event(mac, IPA_ETH_BRIDGE_CLIENT_DEL_EVENT);
-		}
+		eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v4, NULL);
 	}
-	else	//switch from INTERNET to FULL mode
+	if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
 	{
-		for(i=0; i<num_wifi_client; i++)
-		{
-			memcpy(mac, get_client_memptr(wlan_client, i)->mac, sizeof(mac));
-
-			/* add client info from the client array */
-			eth_bridge_add_client(mac);
-
-			/* add client rt rules */
-			if(IPACM_Lan::lan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				eth_bridge_add_wlan_client_rt_rule(mac, SRC_LAN, IPA_IP_v4);
-				eth_bridge_add_wlan_client_rt_rule(mac, SRC_LAN, IPA_IP_v6);
-			}
-			if(IPACM_Lan::wlan_to_wlan_hdr_proc_ctx.valid == true)
-			{
-				eth_bridge_add_wlan_client_rt_rule(mac, SRC_WLAN, IPA_IP_v4);
-				eth_bridge_add_wlan_client_rt_rule(mac, SRC_WLAN, IPA_IP_v6);
-			}
-
-			/* post client add event */
-			eth_bridge_post_lan_client_event(mac, IPA_ETH_BRIDGE_CLIENT_ADD_EVENT);
-		}
-
-		/* add client flt rules */
-		IPACMDBG_H("ip_type: %d\n", ip_type);
-		if(ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX)
-		{
-			eth_bridge_install_cache_client_flt_rule(IPA_IP_v4);
-		}
-		if(ip_type == IPA_IP_v6 || ip_type == IPA_IP_MAX)
-		{
-			eth_bridge_install_cache_client_flt_rule(IPA_IP_v6);
-		}
+		eth_bridge_post_event(IPA_ETH_BRIDGE_IFACE_UP, IPA_IP_v6, NULL);
 	}
+
+	/* at last post CLIENT_ADD event */
+	for(i = 0; i < num_wifi_client; i++)
+	{
+		eth_bridge_post_event(IPA_ETH_BRIDGE_CLIENT_ADD, IPA_IP_MAX,
+			get_client_memptr(wlan_client, i)->mac);
+	}
+
 	return;
 }
+
+bool IPACM_Wlan::is_guest_ap()
+{
+	return m_is_guest_ap;
+}
