diff options
author | imarom <imarom@cisco.com> | 2016-12-25 12:54:09 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-12-25 13:50:56 +0200 |
commit | 34cb66c9f06c7a43e68a17b4a8802f8d34298a65 (patch) | |
tree | aa6b081213e5715cf09a18503cc7b0a20168c6fc /src/stateless | |
parent | 549f2750ab22db5695a8d29575c136ab06e37235 (diff) |
refactor layer config on prot attributes
added guard against unconfigured MAC when going up with empty config
file
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/stateless')
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index e9b3c6d4..7d331c6e 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -1012,12 +1012,10 @@ TrexStatelessPort::set_l2_mode(const uint8_t *dest_mac) { /* not valid under traffic */ verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l2_mode"); - /* no IPv4 src */ - getPortAttrObj()->set_src_ipv4(0); - - /* set destination as MAC */ - getPortAttrObj()->get_dest().set_dest(dest_mac); - + /* configure port attributes for L2 */ + getPortAttrObj()->set_l2_mode(dest_mac); + + /* update RX core */ TrexStatelessRxSetL2Mode *msg = new TrexStatelessRxSetL2Mode(m_port_id); send_message_to_rx( (TrexStatelessCpToRxMsgBase *)msg ); } @@ -1031,15 +1029,12 @@ TrexStatelessPort::set_l3_mode(uint32_t src_ipv4, uint32_t dest_ipv4) { /* not valid under traffic */ verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l3_mode"); - /* set src IPv4 */ - getPortAttrObj()->set_src_ipv4(src_ipv4); - - /* set dest IPv4 */ - getPortAttrObj()->get_dest().set_dest(dest_ipv4); - + /* configure port attributes with L3 */ + getPortAttrObj()->set_l3_mode(src_ipv4, dest_ipv4); + /* send RX core the relevant info */ CManyIPInfo ip_info; - ip_info.insert(COneIPv4Info(src_ipv4, 0, getPortAttrObj()->get_src_mac())); + ip_info.insert(COneIPv4Info(src_ipv4, 0, getPortAttrObj()->get_layer_cfg().get_ether().get_src())); TrexStatelessRxSetL3Mode *msg = new TrexStatelessRxSetL3Mode(m_port_id, ip_info, false); send_message_to_rx( (TrexStatelessCpToRxMsgBase *)msg ); @@ -1054,15 +1049,12 @@ TrexStatelessPort::set_l3_mode(uint32_t src_ipv4, uint32_t dest_ipv4, const uint verify_state(PORT_STATE_IDLE | PORT_STATE_STREAMS, "set_l3_mode"); - /* set src IPv4 */ - getPortAttrObj()->set_src_ipv4(src_ipv4); - - /* set dest IPv4 + resolved MAC */ - getPortAttrObj()->get_dest().set_dest(dest_ipv4, resolved_mac); + /* configure port attributes with L3 */ + getPortAttrObj()->set_l3_mode(src_ipv4, dest_ipv4, resolved_mac); /* send RX core the relevant info */ CManyIPInfo ip_info; - ip_info.insert(COneIPv4Info(src_ipv4, 0, getPortAttrObj()->get_src_mac())); + ip_info.insert(COneIPv4Info(src_ipv4, 0, getPortAttrObj()->get_layer_cfg().get_ether().get_src())); bool is_grat_arp_needed = !getPortAttrObj()->is_loopback(); |