Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
update filename
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangml committed Dec 21, 2020
1 parent 8510c81 commit 19a01b6
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 53 deletions.
22 changes: 11 additions & 11 deletions include/aca_oam_server.h → include/aca_zeta_oam_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef ACA_OAM_SERVER_H
#define ACA_OAM_SERVER_H
#ifndef ACA_ZETA_OAM_SERVER_H
#define ACA_ZETA_OAM_SERVER_H

#include <cstdint>
#include <string>
Expand All @@ -24,7 +24,7 @@
#include "goalstateprovisioner.grpc.pb.h"

using namespace std;
namespace aca_oam_server
namespace aca_zeta_oam_server
{
//OAM Message Type
#define OAM_MSG_FLOW_INJECTION (0)
Expand Down Expand Up @@ -55,7 +55,7 @@ struct flow_inject_msg {
uint16_t src_port; // Inner Packet SPort
uint16_t dst_port; // Inner Packet DPort
uint8_t proto; // Inner Packet Protocol
uint8_t vni[3]; // tunnel_id
uint8_t vni[3]; // tunnel_id, 3bytes
struct in_addr inst_dst_ip; // Destination Inst IP
struct in_addr node_dst_ip; // Destination Node IP
uint8_t inst_dst_mac[6]; // Destination Inst MAC
Expand All @@ -80,12 +80,12 @@ struct oam_message {
} data;
};

class ACA_Oam_Server {
class ACA_Zeta_Oam_Server {
public:
ACA_Oam_Server();
~ACA_Oam_Server();
ACA_Zeta_Oam_Server();
~ACA_Zeta_Oam_Server();

static ACA_Oam_Server &get_instance();
static ACA_Zeta_Oam_Server &get_instance();
void oams_recv(uint32_t udp_dport, void *message);

bool lookup_oam_port_in_cache(uint port_number);
Expand Down Expand Up @@ -115,7 +115,7 @@ class ACA_Oam_Server {

void _parse_oam_none(uint32_t /* in_port */, oam_message *oammsg);

void (aca_oam_server::ACA_Oam_Server ::*_parse_oam_msg_ops[OAM_MSG_MAX])(uint32_t udp_dpost,
void (aca_zeta_oam_server::ACA_Zeta_Oam_Server ::*_parse_oam_msg_ops[OAM_MSG_MAX])(uint32_t udp_dpost,
oam_message *oammsg);

string _get_mac_addr(uint8_t *mac);
Expand All @@ -128,5 +128,5 @@ class ACA_Oam_Server {
// mutex for reading and writing to _oam_ports_cache
mutex _oam_ports_cache_mutex;
};
} // namespace aca_oam_server
#endif // #ifndef ACA_OAM_SERVER_H
} // namespace aca_zeta_oam_server
#endif // #ifndef ACA_Zeta_OAM_SERVER_H
9 changes: 8 additions & 1 deletion include/aca_zeta_programming.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct zeta_config {

class ACA_Zeta_Programming {
public:

ACA_Zeta_Programming();
~ACA_Zeta_Programming();
static ACA_Zeta_Programming &get_instance();
Expand All @@ -57,6 +56,14 @@ class ACA_Zeta_Programming {

uint get_group_id(string zeta_gateway_id);

void set_zeta_gateway(uint tunnel_id, const string auxGateway_id);

int remove_zeta_gateway(uint tunnel_id);

string get_zeta_gateway_id(uint tunnel_id);

bool is_exist_zeta_gateway(const string auxGateway_id);

private:
int _create_oam_ofp(uint port_number);
int _delete_oam_ofp(uint port_number);
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(SOURCES
./ovs/aca_ovs_control.cpp
./dhcp/aca_dhcp_state_handler.cpp
./dhcp/aca_dhcp_server.cpp
./zeta/aca_oam_server.cpp
./zeta/aca_zeta_oam_server.cpp
./zeta/aca_zeta_programming.cpp
)
FIND_LIBRARY(RDKAFKA rdkafka /usr/lib/x86_64-linux-gnu NO_DEFAULT_PATH)
Expand Down
6 changes: 3 additions & 3 deletions src/ovs/aca_ovs_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <netinet/ip.h>
#include <arpa/inet.h>
#include "aca_dhcp_server.h"
#include "aca_oam_server.h"
#include "aca_zeta_oam_server.h"

using namespace std;
using namespace ovs_control;
Expand Down Expand Up @@ -288,9 +288,9 @@ void ACA_OVS_Control::parse_packet(uint32_t in_port, void *packet)
}

/* oam message procedure */
if (aca_oam_server::ACA_Oam_Server::get_instance().lookup_oam_port_in_cache((uint)udp_dport)) {
if (aca_zeta_oam_server::ACA_Zeta_Oam_Server::get_instance().lookup_oam_port_in_cache((uint)udp_dport)) {
ACA_LOG_INFO("%s", " Message Type: OAM\n");
aca_oam_server::ACA_Oam_Server::get_instance().oams_recv(
aca_zeta_oam_server::ACA_Zeta_Oam_Server::get_instance().oams_recv(
(uint32_t)udp_dport, const_cast<unsigned char *>(payload));
}
}
Expand Down
54 changes: 27 additions & 27 deletions src/zeta/aca_oam_server.cpp → src/zeta/aca_zeta_oam_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "aca_oam_server.h"
#include "aca_zeta_oam_server.h"
#include "aca_log.h"
#include "goalstateprovisioner.grpc.pb.h"
#include <errno.h>
Expand All @@ -27,24 +27,24 @@
using namespace std;
using namespace aca_ovs_control;

namespace aca_oam_server
namespace aca_zeta_oam_server
{
ACA_Oam_Server::ACA_Oam_Server()
ACA_Zeta_Oam_Server::ACA_Zeta_Oam_Server()
{
_init_oam_msg_ops();
}

ACA_Oam_Server::~ACA_Oam_Server()
ACA_Zeta_Oam_Server::~ACA_Zeta_Oam_Server()
{
}

ACA_Oam_Server &ACA_Oam_Server::get_instance()
ACA_Zeta_Oam_Server &ACA_Zeta_Oam_Server::get_instance()
{
static ACA_Oam_Server instance;
static ACA_Zeta_Oam_Server instance;
return instance;
}

bool ACA_Oam_Server::_validate_oam_message(oam_message *oammsg)
bool ACA_Zeta_Oam_Server::_validate_oam_message(oam_message *oammsg)
{
int retcode = 0;

Expand All @@ -65,7 +65,7 @@ bool ACA_Oam_Server::_validate_oam_message(oam_message *oammsg)
return true;
}

void ACA_Oam_Server::oams_recv(uint udp_dport, void *message)
void ACA_Zeta_Oam_Server::oams_recv(uint udp_dport, void *message)
{
oam_message *oammsg = nullptr;

Expand All @@ -88,16 +88,16 @@ void ACA_Oam_Server::oams_recv(uint udp_dport, void *message)
return;
}

void ACA_Oam_Server::_init_oam_msg_ops()
void ACA_Zeta_Oam_Server::_init_oam_msg_ops()
{
_parse_oam_msg_ops[OAM_MSG_FLOW_INJECTION] =
&aca_oam_server::ACA_Oam_Server::_parse_oam_flow_injection;
&aca_zeta_oam_server::ACA_Zeta_Oam_Server::_parse_oam_flow_injection;
_parse_oam_msg_ops[OAM_MSG_FLOW_DELETION] =
&aca_oam_server::ACA_Oam_Server::_parse_oam_flow_deletion;
_parse_oam_msg_ops[OAM_MSG_NONE] = &aca_oam_server::ACA_Oam_Server::_parse_oam_none;
&aca_zeta_oam_server::ACA_Zeta_Oam_Server::_parse_oam_flow_deletion;
_parse_oam_msg_ops[OAM_MSG_NONE] = &aca_zeta_oam_server::ACA_Zeta_Oam_Server::_parse_oam_none;
}

uint8_t ACA_Oam_Server::_get_message_type(oam_message *oammsg)
uint8_t ACA_Zeta_Oam_Server::_get_message_type(oam_message *oammsg)
{
if (!oammsg) {
ACA_LOG_ERROR("%s", "OAM message is null!\n");
Expand All @@ -111,7 +111,7 @@ uint8_t ACA_Oam_Server::_get_message_type(oam_message *oammsg)
return (uint8_t)(ntohl(oammsg->op_code));
}

string ACA_Oam_Server::_get_mac_addr(uint8_t *mac)
string ACA_Zeta_Oam_Server::_get_mac_addr(uint8_t *mac)
{
string mac_string;
stringstream ss;
Expand All @@ -129,7 +129,7 @@ string ACA_Oam_Server::_get_mac_addr(uint8_t *mac)
return mac_string;
}

uint ACA_Oam_Server::_get_tunnel_id(uint8_t vni[3])
uint ACA_Zeta_Oam_Server::_get_tunnel_id(uint8_t vni[3])
{
string tunnel_id;
stringstream ss;
Expand All @@ -146,7 +146,7 @@ uint ACA_Oam_Server::_get_tunnel_id(uint8_t vni[3])
}

//extract data for flow table matching from the oam message
oam_match ACA_Oam_Server::_get_oam_match_field(oam_message *oammsg)
oam_match ACA_Zeta_Oam_Server::_get_oam_match_field(oam_message *oammsg)
{
oam_match match;

Expand All @@ -164,7 +164,7 @@ oam_match ACA_Oam_Server::_get_oam_match_field(oam_message *oammsg)
}

//extract the data used for the flow table action from the oam message
oam_action ACA_Oam_Server::_get_oam_action_field(oam_message *oammsg)
oam_action ACA_Zeta_Oam_Server::_get_oam_action_field(oam_message *oammsg)
{
oam_action action;

Expand All @@ -180,7 +180,7 @@ oam_action ACA_Oam_Server::_get_oam_action_field(oam_message *oammsg)
}

//check whether the udp_dport is the oam server port of the vpc
bool ACA_Oam_Server::_check_oam_server_port(uint udp_dport, oam_match match)
bool ACA_Zeta_Oam_Server::_check_oam_server_port(uint udp_dport, oam_match match)
{
uint tunnel_id = match.vni;
string zeta_gateway_id =
Expand All @@ -198,7 +198,7 @@ bool ACA_Oam_Server::_check_oam_server_port(uint udp_dport, oam_match match)
}
}

void ACA_Oam_Server::_parse_oam_flow_injection(uint udp_dport, oam_message *oammsg)
void ACA_Zeta_Oam_Server::_parse_oam_flow_injection(uint udp_dport, oam_message *oammsg)
{
int overall_rc;

Expand All @@ -222,7 +222,7 @@ void ACA_Oam_Server::_parse_oam_flow_injection(uint udp_dport, oam_message *oamm
return;
}

void ACA_Oam_Server::_parse_oam_flow_deletion(uint udp_dport, oam_message *oammsg)
void ACA_Zeta_Oam_Server::_parse_oam_flow_deletion(uint udp_dport, oam_message *oammsg)
{
int overall_rc;
oam_match match = _get_oam_match_field(oammsg);
Expand All @@ -242,13 +242,13 @@ void ACA_Oam_Server::_parse_oam_flow_deletion(uint udp_dport, oam_message *oamms
return;
}

void ACA_Oam_Server::_parse_oam_none(uint /* in_port */, oam_message *oammsg)
void ACA_Zeta_Oam_Server::_parse_oam_none(uint /* in_port */, oam_message *oammsg)
{
ACA_LOG_ERROR("Wrong OAM message type! (Message type = %d)\n", _get_message_type(oammsg));
return;
}

int ACA_Oam_Server::_add_direct_path(oam_match match, oam_action action)
int ACA_Zeta_Oam_Server::_add_direct_path(oam_match match, oam_action action)
{
unsigned long not_care_culminative_time;
int overall_rc = EXIT_SUCCESS;
Expand Down Expand Up @@ -279,7 +279,7 @@ int ACA_Oam_Server::_add_direct_path(oam_match match, oam_action action)
return overall_rc;
}

int ACA_Oam_Server::_del_direct_path(oam_match match)
int ACA_Zeta_Oam_Server::_del_direct_path(oam_match match)
{
int overall_rc;
string vlan_id = to_string(aca_vlan_manager::ACA_Vlan_Manager::get_instance().get_or_create_vlan_id(
Expand All @@ -302,7 +302,7 @@ int ACA_Oam_Server::_del_direct_path(oam_match match)
}

// add oam port number to cache
void ACA_Oam_Server::add_oam_port_cache(uint port_number)
void ACA_Zeta_Oam_Server::add_oam_port_cache(uint port_number)
{
// -----critical section ends-----
_oam_ports_cache_mutex.lock();
Expand All @@ -314,7 +314,7 @@ void ACA_Oam_Server::add_oam_port_cache(uint port_number)
}

// remove the oam port number from the cache
// int ACA_Oam_Server::remove_oam_port_cache(uint port_number)
// int ACA_Zeta_Oam_Server::remove_oam_port_cache(uint port_number)
// {
// int overall_rc = EXIT_FAILURE;
// // -----critical section starts-----
Expand All @@ -333,12 +333,12 @@ void ACA_Oam_Server::add_oam_port_cache(uint port_number)
// }

// find the oam port number in the cache
bool ACA_Oam_Server::lookup_oam_port_in_cache(uint port_number)
bool ACA_Zeta_Oam_Server::lookup_oam_port_in_cache(uint port_number)
{
if (_oam_ports_cache.find(port_number) != _oam_ports_cache.end()) {
return true;
} else {
return false;
}
}
} // namespace aca_oam_server
} // namespace aca_zeta_oam_server
4 changes: 2 additions & 2 deletions src/zeta/aca_zeta_programming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "aca_log.h"
#include "aca_vlan_manager.h"
#include "aca_ovs_control.h"
#include "aca_oam_server.h"
#include "aca_zeta_oam_server.h"

using namespace alcor::schema;
using namespace aca_ovs_control;
Expand Down Expand Up @@ -170,7 +170,7 @@ int ACA_Zeta_Programming::create_zeta_config(const alcor::schema::AuxGateway cur
create_entry(current_AuxGateway.id(), oam_port);
_create_oam_ofp(oam_port);
// add oam port number to cache
aca_oam_server::ACA_Oam_Server::get_instance().add_oam_port_cache(oam_port);
aca_zeta_oam_server::ACA_Zeta_Oam_Server::get_instance().add_oam_port_cache(oam_port);

_zeta_config_table.find(current_AuxGateway.id(), new_zeta_cfg);
}
Expand Down
16 changes: 8 additions & 8 deletions test/gtest/aca_test_oam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

#include "gtest/gtest.h"
#define private public
#include "aca_oam_server.h"
#include "aca_zeta_oam_server.h"
#include "aca_util.h"
#include <string.h>
#include "aca_ovs_control.h"
#include "aca_vlan_manager.h"

using namespace aca_oam_server;
using namespace aca_zeta_oam_server;

extern string vmac_address_1;
extern string vmac_address_2;
Expand Down Expand Up @@ -60,12 +60,12 @@ TEST(oam_message_test_cases, oams_recv_valid)
stOamMsg.data.msg_inject_flow.inst_dst_mac[5] = 0x65;
stOamMsg.data.msg_inject_flow.idle_timeout = 120;

ACA_Oam_Server::get_instance().oams_recv(55, &stOamMsg);
ACA_Zeta_Oam_Server::get_instance().oams_recv(55, &stOamMsg);

retcode = ACA_Oam_Server::get_instance()._validate_oam_message(&stOamMsg);
retcode = ACA_Zeta_Oam_Server::get_instance()._validate_oam_message(&stOamMsg);
EXPECT_EQ(retcode, true);

retcode = ACA_Oam_Server::get_instance()._get_message_type(&stOamMsg);
retcode = ACA_Zeta_Oam_Server::get_instance()._get_message_type(&stOamMsg);
EXPECT_EQ(retcode, OAM_MSG_FLOW_INJECTION);
}

Expand All @@ -92,7 +92,7 @@ TEST(oam_message_test_cases, add_direct_path_valid)
match.vni));

// add unicast rule
aca_oam_server::ACA_Oam_Server::get_instance()._add_direct_path(match, action);
ACA_Zeta_Oam_Server::get_instance()._add_direct_path(match, action);

string cmd = "table=20,ip,nw_proto=" + match.proto + ",nw_src=" + match.sip +
",nw_dst=" + match.dip + ",tp_src=" + match.sport +
Expand Down Expand Up @@ -126,9 +126,9 @@ TEST(oam_message_test_cases, del_direct_path_valid)
match.vni));

// add unicast rule
aca_oam_server::ACA_Oam_Server::get_instance()._add_direct_path(match, action);
ACA_Zeta_Oam_Server::get_instance()._add_direct_path(match, action);

aca_oam_server::ACA_Oam_Server::get_instance()._del_direct_path(match);
ACA_Zeta_Oam_Server::get_instance()._del_direct_path(match);

string cmd = "table=20,ip,nw_proto=" + match.proto + ",nw_src=" + match.sip +
",nw_dst=" + match.dip + ",tp_src=" + match.sport +
Expand Down

0 comments on commit 19a01b6

Please sign in to comment.