Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions librina/src/ipc-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,15 @@ FlowInformation IPCManager::internalAllocateFlowResponse(const FlowRequestEvent&

// If the user of the flow is an application, init the I/O dev so that
// data can be read and written to the flow via read/write calls
#if STUB_API
#else
if (ipcProcessId == 0) {
initIodev(flow, flowRequestEvent.portId);
if (fcntl(flow->fd, F_SETFL, blocking ? 0 : O_NONBLOCK)) {
LOG_WARN("Failed to set blocking mode on fd %d", flow->fd);
}
}
#endif

allocatedFlows[flowRequestEvent.portId] = flow;

Expand Down Expand Up @@ -590,10 +593,12 @@ FlowInformation IPCManager::commitPendingFlow(unsigned int sequenceNumber,
if (flow == 0) {
throw FlowAllocationException(IPCManager::unknown_flow_error);
}

#if STUB_API
#else
if (flow->user_ipcp_id == 0) {
initIodev(flow, portId);
}
#endif

pendingFlows.erase(sequenceNumber);

Expand Down Expand Up @@ -675,10 +680,10 @@ void IPCManager::deallocate_flow(int portId)
msg.event_id = 0;
irati_ctrl_mgr->send_msg((struct irati_msg_base *) &msg, true);
}
#endif

allocatedFlows.erase(portId);
delete flow;
#endif
}

void IPCManager::flowDeallocated(int portId)
Expand Down
11 changes: 4 additions & 7 deletions librina/test/test-01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ int main() {
<< "; DIF name is: " << flow.difName.processName
<< "; state is: "<<flow.state << "\n";


/* TEST ALLOCATE RESPONSE */
FlowRequestEvent flowRequestEvent = FlowRequestEvent(25, flowSpecification,
true, sourceName, destinationName, difName, 23, 234);
true, sourceName, destinationName, difName, 23, 234, 15, 12);
FlowInformation flow2 = ipcManager->allocateFlowResponse(flowRequestEvent, 0, true);
std::cout << "Accepted flow allocation, portId is " << flow2.portId
<< "; DIF name is: " << flow2.difName.processName
Expand All @@ -110,19 +109,17 @@ int main() {
return 1;
}
/* TEST DEALLOCATE FLOW */
ipcManager->requestFlowDeallocation(flow.portId);
ipcManager->flowDeallocationResult(flow.portId, true);
ipcManager->deallocate_flow(flow.portId);
if (!checkAllocatedFlows(1)) {
return 1;
}
ipcManager->requestFlowDeallocation(flow2.portId);
ipcManager->flowDeallocationResult(flow2.portId, true);
ipcManager->deallocate_flow(flow2.portId);
if (!checkAllocatedFlows(0)) {
return -1;
}

try {
ipcManager->requestFlowDeallocation(234);
ipcManager->deallocate_flow(234);
} catch (IPCException &e) {
std::cout << "Caught expected exception: " << e.what() << "\n";
}
Expand Down
8 changes: 4 additions & 4 deletions librina/test/test-02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main() {
/* TEST ALLOCATE FLOW */
FlowSpecification *flowSpec = new FlowSpecification();
FlowRequestEvent * flowRequest = new FlowRequestEvent(*flowSpec,
true, *sourceName, *difName, 1234, 4545);
true, *sourceName, *difName, 1234, 4545, 15, 20, 4);
flowRequest->portId = 430;
ipcProcess1->allocateFlow(*flowRequest, 23);

Expand All @@ -92,17 +92,17 @@ int main() {
ApplicationRegistrationInformation(APPLICATION_REGISTRATION_SINGLE_DIF);
appRegInfo.difName = *difName;
ApplicationRegistrationRequestEvent * event = new
ApplicationRegistrationRequestEvent(appRegInfo, 34);
ApplicationRegistrationRequestEvent(appRegInfo, 34, 3, 4);
applicationManager->applicationRegistered(*event, *difName, 0);

/* TEST APPLICATION UNREGISTERED */
ApplicationUnregistrationRequestEvent * event2 = new
ApplicationUnregistrationRequestEvent(*sourceName, *difName, 34);
ApplicationUnregistrationRequestEvent(*sourceName, *difName, 34, 1, 2);
applicationManager->applicationUnregistered(*event2, 0);

/* TEST FLOW ALLOCATED */
FlowRequestEvent * flowEvent = new FlowRequestEvent(25, *flowSpec,
true, *sourceName, *destinationName, *difName, 3, 2323);
true, *sourceName, *destinationName, *difName, 3, 2323, 2, 3);
applicationManager->flowAllocated(*flowEvent);

factory.destroy(ipcProcess1);
Expand Down
4 changes: 2 additions & 2 deletions librina/test/test-parsers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3284,8 +3284,8 @@ int main()
result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_MODIFY_FTE_REQUEST);
if (result < 0) return result;

result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_DUMP_FT_REPLY);
if (result < 0) return result;
/*result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_DUMP_FT_REPLY);
if (result < 0) return result;*/

result = test_irati_kmsg_ipcp_conn_create_arrived(RINA_C_IPCP_CONN_CREATE_REQUEST);
if (result < 0) return result;
Expand Down
8 changes: 7 additions & 1 deletion rinad/src/ipcp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ test_encoders_SOURCES = \
enrollment-task.cc enrollment-task.h \
resource-allocator.cc resource-allocator.h \
rib-daemon.h rib-daemon.cc \
routing.cc security-manager.cc
routing.cc security-manager.cc \
shim-wifi/shim-wifi-ipc-process.cc \
shim-wifi/shim-wifi-ipc-process.h \
shim-wifi/wpa_controller.h \
shim-wifi/wpa_controller.cc \
$(shimwifi_SOURCES)
test_encoders_CFLAGS = $(shimwifi_CFLAGS)
test_encoders_CPPFLAGS = $(testsCPPFLAGS)
test_encoders_LDADD = $(testsLIBS)

Expand Down
23 changes: 20 additions & 3 deletions rinad/src/ipcp/plugins/default/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COMMONCPPFLAGS = \
$(CPPFLAGS_EXTRA) \
$(LIBRINA_CFLAGS) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/common
-I$(top_srcdir)/src/common

COMMONLIBS = \
$(builddir)/../../../common/librinad.la \
Expand Down Expand Up @@ -42,6 +42,17 @@ plugins_LTLIBRARIES += default.la

testsCPPFLAGS = $(COMMONCPPFLAGS)
testsLIBS = $(COMMONLIBS)

shimwifi_CPPFLAGS = -I$(top_srcdir)/src/ipcp/shim-wifi/wpa_supplicant

shimwifi_CFLAGS = -DCONFIG_CTRL_IFACE \
-DCONFIG_CTRL_IFACE_UNIX

shimwifi_SOURCES = \
../../shim-wifi/wpa_supplicant/wpa_ctrl.c \
../../shim-wifi/wpa_supplicant/os_unix.c \
../../shim-wifi/wpa_controller.cc ../../shim-wifi/wpa_controller.h \
../../shim-wifi/shim-wifi-ipc-process.cc ../../shim-wifi/shim-wifi-ipc-process.h

test_routing_SOURCES = \
test-routing.cc \
Expand All @@ -56,8 +67,11 @@ test_routing_SOURCES = \
../../rib-daemon.h ../../rib-daemon.cc \
../../routing.cc \
../../security-manager.cc \
$(shimwifi_SOURCES) \
routing-ps.cc routing-ps.h
test_routing_CPPFLAGS = $(testsCPPFLAGS) \
test_routing_CFLAGS = $(shimwifi_CFLAGS)
test_routing_CPPFLAGS = -I$(top_srcdir)/src/ipcp/ \
$(testsCPPFLAGS) \
-DPLUGINSDIR=\"$(pkglibdir)/ipcp\"
test_routing_LDADD = $(testsLIBS)

Expand All @@ -74,8 +88,11 @@ test_encoders_SOURCES = \
../../rib-daemon.h ../../rib-daemon.cc \
../../routing.cc \
../../security-manager.cc \
$(shimwifi_SOURCES) \
routing-ps.cc routing-ps.h
test_encoders_CPPFLAGS = $(testsCPPFLAGS) \
test_encoders_CFLAGS = $(shimwifi_CFLAGS)
test_encoders_CPPFLAGS = -I$(top_srcdir)/src/ipcp/ \
$(testsCPPFLAGS) \
-DPLUGINSDIR=\"$(pkglibdir)/ipcp\"
test_encoders_LDADD = $(testsLIBS)

Expand Down
36 changes: 16 additions & 20 deletions rinad/src/ipcp/plugins/default/test-encoders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ bool test_flow_state_object()
encoder.encode(fso, encoded_obj);
encoder.decode(encoded_obj, recovered_obj);

if (fso.get_name() != recovered_obj.get_name()) {
if (fso.name != recovered_obj.name) {
LOG_IPCP_ERR("Names are different; original: %s, recovered: %s",
fso.get_name().c_str(),
recovered_obj.get_name().c_str());
fso.name.c_str(),
recovered_obj.name.c_str());
return false;
}

if (fso.get_neighborname() != recovered_obj.get_neighborname()) {
if (fso.neighbor_name != recovered_obj.neighbor_name) {
LOG_IPCP_ERR("Neighbor names are different; original: %s, recovered: %s",
fso.get_neighborname().c_str(),
recovered_obj.get_neighborname().c_str());
fso.neighbor_name.c_str(),
recovered_obj.neighbor_name.c_str());
return false;
}

if (fso.get_addresses().size() != recovered_obj.get_addresses().size()) {
if (fso.addresses.size() != recovered_obj.addresses.size()) {
LOG_IPCP_ERR("Address sizes are different");
return false;
}
Expand All @@ -73,7 +73,7 @@ bool test_flow_state_object()
return false;
}

if (fso.get_neighboraddresses().size() != recovered_obj.get_neighboraddresses().size()) {
if (fso.neighbor_addresses.size() != recovered_obj.neighbor_addresses.size()) {
LOG_IPCP_ERR("Neighbor address sizes are different");
return false;
}
Expand All @@ -83,31 +83,27 @@ bool test_flow_state_object()
return false;
}

if (fso.get_cost() != recovered_obj.get_cost()) {
if (fso.cost != recovered_obj.cost) {
LOG_IPCP_ERR("Costs are different; original: %u, recovered: %u",
fso.get_cost(),
recovered_obj.get_cost());
fso.cost, recovered_obj.cost);
return false;
}

if (fso.get_sequencenumber() != recovered_obj.get_sequencenumber()) {
if (fso.seq_num != recovered_obj.seq_num) {
LOG_IPCP_ERR("Sequence numbers are different; original: %d, recovered: %d",
fso.get_sequencenumber(),
recovered_obj.get_sequencenumber());
fso.seq_num, recovered_obj.seq_num);
return false;
}

if (fso.is_state() != recovered_obj.is_state()) {
if (fso.state_up != recovered_obj.state_up) {
LOG_IPCP_ERR("States are different; original: %d, recovered: %d",
fso.is_state(),
recovered_obj.is_state());
fso.state_up, recovered_obj.state_up);
return false;
}

if (fso.get_age() != recovered_obj.get_age()) {
if (fso.age != recovered_obj.age) {
LOG_IPCP_ERR("Ages are different; original: %u, recovered: %u",
fso.get_age(),
recovered_obj.get_age());
fso.age, recovered_obj.age);
return false;
}

Expand Down
14 changes: 7 additions & 7 deletions rinad/src/ipcp/plugins/default/test-routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -769,23 +769,23 @@ void populateAddresses(std::list<rina::RoutingTableEntry *>& rt,
++jt;

while (jt != fsos.end()) {
if (it->get_name() == jt->get_neighborname() &&
it->get_neighborname() == jt->get_name()) {
if (it->name == jt->neighbor_name &&
it->neighbor_name == jt->name) {

aux = it->get_addresses();
aux = it->addresses;
for (kt = aux.begin(); kt != aux.end(); ++kt) {
if (jt->contains_neighboraddress(*kt))
addresses.push_back(*kt);
}
name_address_map[it->get_name()] = addresses;
name_address_map[it->name] = addresses;
addresses.clear();

aux = it->get_neighboraddresses();
aux = it->neighbor_addresses;
for (kt = aux.begin(); kt != aux.end(); ++kt) {
if (jt->contains_address(*kt))
addresses.push_back(*kt);
}
name_address_map[it->get_neighborname()] = addresses;
name_address_map[it->neighbor_name] = addresses;
addresses.clear();

break;
Expand Down Expand Up @@ -1066,7 +1066,7 @@ int getRoutingTable_MultipathGraphRoutesTest() {
for (it = rtable.begin(); it != rtable.end(); ++it) {
const rina::RoutingTableEntry& e = **it;
if (e.destination.name == "d") {
if (e.nextHopNames.size() != 3) {
if (e.nextHopNames.size() != 4) {
result = -1;
}
}
Expand Down
8 changes: 4 additions & 4 deletions rinad/src/ipcp/test-encoders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ bool test_flow () {
rina::DTCPRateBasedFlowControlConfig rate_to_encode;

// Set
flow_to_encode.source_naming_info = rina::ApplicationProcessNamingInformation("test", "1");
flow_to_encode.destination_naming_info = rina::ApplicationProcessNamingInformation("test2", "1");
flow_to_encode.local_naming_info = rina::ApplicationProcessNamingInformation("test", "1");
flow_to_encode.remote_naming_info = rina::ApplicationProcessNamingInformation("test2", "1");
dtp_config_to_encode.set_dtcp_present(true);
dtp_config_to_encode.set_seq_num_rollover_threshold(1234);
dtp_config_to_encode.set_initial_a_timer(14561);
Expand Down Expand Up @@ -90,9 +90,9 @@ bool test_flow () {
encoder.decode(encoded_obj, flow_decoded);

// Assert
if (flow_to_encode.source_naming_info.processName != flow_decoded.source_naming_info.processName)
if (flow_to_encode.local_naming_info.processName != flow_decoded.local_naming_info.processName)
return false;
if (flow_to_encode.source_naming_info.processInstance != flow_decoded.source_naming_info.processInstance)
if (flow_to_encode.local_naming_info.processInstance != flow_decoded.local_naming_info.processInstance)
return false;

rina::Connection *pconnection_decoded = flow_decoded.connections.front();
Expand Down