Skip to content

Commit 76f7d06

Browse files
authored
Merge pull request #1165 from IRATI/arcfire
Merge arcfire into master
2 parents fac8228 + b695842 commit 76f7d06

File tree

9 files changed

+71
-50
lines changed

9 files changed

+71
-50
lines changed

librina/src/ipc-api.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,15 @@ FlowInformation IPCManager::internalAllocateFlowResponse(const FlowRequestEvent&
323323

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

333336
allocatedFlows[flowRequestEvent.portId] = flow;
334337

@@ -590,10 +593,12 @@ FlowInformation IPCManager::commitPendingFlow(unsigned int sequenceNumber,
590593
if (flow == 0) {
591594
throw FlowAllocationException(IPCManager::unknown_flow_error);
592595
}
593-
596+
#if STUB_API
597+
#else
594598
if (flow->user_ipcp_id == 0) {
595599
initIodev(flow, portId);
596600
}
601+
#endif
597602

598603
pendingFlows.erase(sequenceNumber);
599604

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

679685
allocatedFlows.erase(portId);
680686
delete flow;
681-
#endif
682687
}
683688

684689
void IPCManager::flowDeallocated(int portId)

librina/test/test-01.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ int main() {
9696
<< "; DIF name is: " << flow.difName.processName
9797
<< "; state is: "<<flow.state << "\n";
9898

99-
10099
/* TEST ALLOCATE RESPONSE */
101100
FlowRequestEvent flowRequestEvent = FlowRequestEvent(25, flowSpecification,
102-
true, sourceName, destinationName, difName, 23, 234);
101+
true, sourceName, destinationName, difName, 23, 234, 15, 12);
103102
FlowInformation flow2 = ipcManager->allocateFlowResponse(flowRequestEvent, 0, true);
104103
std::cout << "Accepted flow allocation, portId is " << flow2.portId
105104
<< "; DIF name is: " << flow2.difName.processName
@@ -110,19 +109,17 @@ int main() {
110109
return 1;
111110
}
112111
/* TEST DEALLOCATE FLOW */
113-
ipcManager->requestFlowDeallocation(flow.portId);
114-
ipcManager->flowDeallocationResult(flow.portId, true);
112+
ipcManager->deallocate_flow(flow.portId);
115113
if (!checkAllocatedFlows(1)) {
116114
return 1;
117115
}
118-
ipcManager->requestFlowDeallocation(flow2.portId);
119-
ipcManager->flowDeallocationResult(flow2.portId, true);
116+
ipcManager->deallocate_flow(flow2.portId);
120117
if (!checkAllocatedFlows(0)) {
121118
return -1;
122119
}
123120

124121
try {
125-
ipcManager->requestFlowDeallocation(234);
122+
ipcManager->deallocate_flow(234);
126123
} catch (IPCException &e) {
127124
std::cout << "Caught expected exception: " << e.what() << "\n";
128125
}

librina/test/test-02.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int main() {
7979
/* TEST ALLOCATE FLOW */
8080
FlowSpecification *flowSpec = new FlowSpecification();
8181
FlowRequestEvent * flowRequest = new FlowRequestEvent(*flowSpec,
82-
true, *sourceName, *difName, 1234, 4545);
82+
true, *sourceName, *difName, 1234, 4545, 15, 20, 4);
8383
flowRequest->portId = 430;
8484
ipcProcess1->allocateFlow(*flowRequest, 23);
8585

@@ -92,17 +92,17 @@ int main() {
9292
ApplicationRegistrationInformation(APPLICATION_REGISTRATION_SINGLE_DIF);
9393
appRegInfo.difName = *difName;
9494
ApplicationRegistrationRequestEvent * event = new
95-
ApplicationRegistrationRequestEvent(appRegInfo, 34);
95+
ApplicationRegistrationRequestEvent(appRegInfo, 34, 3, 4);
9696
applicationManager->applicationRegistered(*event, *difName, 0);
9797

9898
/* TEST APPLICATION UNREGISTERED */
9999
ApplicationUnregistrationRequestEvent * event2 = new
100-
ApplicationUnregistrationRequestEvent(*sourceName, *difName, 34);
100+
ApplicationUnregistrationRequestEvent(*sourceName, *difName, 34, 1, 2);
101101
applicationManager->applicationUnregistered(*event2, 0);
102102

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

108108
factory.destroy(ipcProcess1);

librina/test/test-parsers.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,8 +3284,8 @@ int main()
32843284
result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_MODIFY_FTE_REQUEST);
32853285
if (result < 0) return result;
32863286

3287-
result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_DUMP_FT_REPLY);
3288-
if (result < 0) return result;
3287+
/*result = test_irati_kmsg_rmt_dump_ft(RINA_C_RMT_DUMP_FT_REPLY);
3288+
if (result < 0) return result;*/
32893289

32903290
result = test_irati_kmsg_ipcp_conn_create_arrived(RINA_C_IPCP_CONN_CREATE_REQUEST);
32913291
if (result < 0) return result;

rinad/src/ipcp/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ test_encoders_SOURCES = \
7878
enrollment-task.cc enrollment-task.h \
7979
resource-allocator.cc resource-allocator.h \
8080
rib-daemon.h rib-daemon.cc \
81-
routing.cc security-manager.cc
81+
routing.cc security-manager.cc \
82+
shim-wifi/shim-wifi-ipc-process.cc \
83+
shim-wifi/shim-wifi-ipc-process.h \
84+
shim-wifi/wpa_controller.h \
85+
shim-wifi/wpa_controller.cc \
86+
$(shimwifi_SOURCES)
87+
test_encoders_CFLAGS = $(shimwifi_CFLAGS)
8288
test_encoders_CPPFLAGS = $(testsCPPFLAGS)
8389
test_encoders_LDADD = $(testsLIBS)
8490

rinad/src/ipcp/plugins/default/Makefile.am

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COMMONCPPFLAGS = \
1111
$(CPPFLAGS_EXTRA) \
1212
$(LIBRINA_CFLAGS) \
1313
-I$(top_srcdir)/src \
14-
-I$(top_srcdir)/src/common
14+
-I$(top_srcdir)/src/common
1515

1616
COMMONLIBS = \
1717
$(builddir)/../../../common/librinad.la \
@@ -42,6 +42,17 @@ plugins_LTLIBRARIES += default.la
4242

4343
testsCPPFLAGS = $(COMMONCPPFLAGS)
4444
testsLIBS = $(COMMONLIBS)
45+
46+
shimwifi_CPPFLAGS = -I$(top_srcdir)/src/ipcp/shim-wifi/wpa_supplicant
47+
48+
shimwifi_CFLAGS = -DCONFIG_CTRL_IFACE \
49+
-DCONFIG_CTRL_IFACE_UNIX
50+
51+
shimwifi_SOURCES = \
52+
../../shim-wifi/wpa_supplicant/wpa_ctrl.c \
53+
../../shim-wifi/wpa_supplicant/os_unix.c \
54+
../../shim-wifi/wpa_controller.cc ../../shim-wifi/wpa_controller.h \
55+
../../shim-wifi/shim-wifi-ipc-process.cc ../../shim-wifi/shim-wifi-ipc-process.h
4556

4657
test_routing_SOURCES = \
4758
test-routing.cc \
@@ -56,8 +67,11 @@ test_routing_SOURCES = \
5667
../../rib-daemon.h ../../rib-daemon.cc \
5768
../../routing.cc \
5869
../../security-manager.cc \
70+
$(shimwifi_SOURCES) \
5971
routing-ps.cc routing-ps.h
60-
test_routing_CPPFLAGS = $(testsCPPFLAGS) \
72+
test_routing_CFLAGS = $(shimwifi_CFLAGS)
73+
test_routing_CPPFLAGS = -I$(top_srcdir)/src/ipcp/ \
74+
$(testsCPPFLAGS) \
6175
-DPLUGINSDIR=\"$(pkglibdir)/ipcp\"
6276
test_routing_LDADD = $(testsLIBS)
6377

@@ -74,8 +88,11 @@ test_encoders_SOURCES = \
7488
../../rib-daemon.h ../../rib-daemon.cc \
7589
../../routing.cc \
7690
../../security-manager.cc \
91+
$(shimwifi_SOURCES) \
7792
routing-ps.cc routing-ps.h
78-
test_encoders_CPPFLAGS = $(testsCPPFLAGS) \
93+
test_encoders_CFLAGS = $(shimwifi_CFLAGS)
94+
test_encoders_CPPFLAGS = -I$(top_srcdir)/src/ipcp/ \
95+
$(testsCPPFLAGS) \
7996
-DPLUGINSDIR=\"$(pkglibdir)/ipcp\"
8097
test_encoders_LDADD = $(testsLIBS)
8198

rinad/src/ipcp/plugins/default/test-encoders.cc

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ bool test_flow_state_object()
4949
encoder.encode(fso, encoded_obj);
5050
encoder.decode(encoded_obj, recovered_obj);
5151

52-
if (fso.get_name() != recovered_obj.get_name()) {
52+
if (fso.name != recovered_obj.name) {
5353
LOG_IPCP_ERR("Names are different; original: %s, recovered: %s",
54-
fso.get_name().c_str(),
55-
recovered_obj.get_name().c_str());
54+
fso.name.c_str(),
55+
recovered_obj.name.c_str());
5656
return false;
5757
}
5858

59-
if (fso.get_neighborname() != recovered_obj.get_neighborname()) {
59+
if (fso.neighbor_name != recovered_obj.neighbor_name) {
6060
LOG_IPCP_ERR("Neighbor names are different; original: %s, recovered: %s",
61-
fso.get_neighborname().c_str(),
62-
recovered_obj.get_neighborname().c_str());
61+
fso.neighbor_name.c_str(),
62+
recovered_obj.neighbor_name.c_str());
6363
return false;
6464
}
6565

66-
if (fso.get_addresses().size() != recovered_obj.get_addresses().size()) {
66+
if (fso.addresses.size() != recovered_obj.addresses.size()) {
6767
LOG_IPCP_ERR("Address sizes are different");
6868
return false;
6969
}
@@ -73,7 +73,7 @@ bool test_flow_state_object()
7373
return false;
7474
}
7575

76-
if (fso.get_neighboraddresses().size() != recovered_obj.get_neighboraddresses().size()) {
76+
if (fso.neighbor_addresses.size() != recovered_obj.neighbor_addresses.size()) {
7777
LOG_IPCP_ERR("Neighbor address sizes are different");
7878
return false;
7979
}
@@ -83,31 +83,27 @@ bool test_flow_state_object()
8383
return false;
8484
}
8585

86-
if (fso.get_cost() != recovered_obj.get_cost()) {
86+
if (fso.cost != recovered_obj.cost) {
8787
LOG_IPCP_ERR("Costs are different; original: %u, recovered: %u",
88-
fso.get_cost(),
89-
recovered_obj.get_cost());
88+
fso.cost, recovered_obj.cost);
9089
return false;
9190
}
9291

93-
if (fso.get_sequencenumber() != recovered_obj.get_sequencenumber()) {
92+
if (fso.seq_num != recovered_obj.seq_num) {
9493
LOG_IPCP_ERR("Sequence numbers are different; original: %d, recovered: %d",
95-
fso.get_sequencenumber(),
96-
recovered_obj.get_sequencenumber());
94+
fso.seq_num, recovered_obj.seq_num);
9795
return false;
9896
}
9997

100-
if (fso.is_state() != recovered_obj.is_state()) {
98+
if (fso.state_up != recovered_obj.state_up) {
10199
LOG_IPCP_ERR("States are different; original: %d, recovered: %d",
102-
fso.is_state(),
103-
recovered_obj.is_state());
100+
fso.state_up, recovered_obj.state_up);
104101
return false;
105102
}
106103

107-
if (fso.get_age() != recovered_obj.get_age()) {
104+
if (fso.age != recovered_obj.age) {
108105
LOG_IPCP_ERR("Ages are different; original: %u, recovered: %u",
109-
fso.get_age(),
110-
recovered_obj.get_age());
106+
fso.age, recovered_obj.age);
111107
return false;
112108
}
113109

rinad/src/ipcp/plugins/default/test-routing.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,23 +769,23 @@ void populateAddresses(std::list<rina::RoutingTableEntry *>& rt,
769769
++jt;
770770

771771
while (jt != fsos.end()) {
772-
if (it->get_name() == jt->get_neighborname() &&
773-
it->get_neighborname() == jt->get_name()) {
772+
if (it->name == jt->neighbor_name &&
773+
it->neighbor_name == jt->name) {
774774

775-
aux = it->get_addresses();
775+
aux = it->addresses;
776776
for (kt = aux.begin(); kt != aux.end(); ++kt) {
777777
if (jt->contains_neighboraddress(*kt))
778778
addresses.push_back(*kt);
779779
}
780-
name_address_map[it->get_name()] = addresses;
780+
name_address_map[it->name] = addresses;
781781
addresses.clear();
782782

783-
aux = it->get_neighboraddresses();
783+
aux = it->neighbor_addresses;
784784
for (kt = aux.begin(); kt != aux.end(); ++kt) {
785785
if (jt->contains_address(*kt))
786786
addresses.push_back(*kt);
787787
}
788-
name_address_map[it->get_neighborname()] = addresses;
788+
name_address_map[it->neighbor_name] = addresses;
789789
addresses.clear();
790790

791791
break;
@@ -1066,7 +1066,7 @@ int getRoutingTable_MultipathGraphRoutesTest() {
10661066
for (it = rtable.begin(); it != rtable.end(); ++it) {
10671067
const rina::RoutingTableEntry& e = **it;
10681068
if (e.destination.name == "d") {
1069-
if (e.nextHopNames.size() != 3) {
1069+
if (e.nextHopNames.size() != 4) {
10701070
result = -1;
10711071
}
10721072
}

rinad/src/ipcp/test-encoders.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ bool test_flow () {
4949
rina::DTCPRateBasedFlowControlConfig rate_to_encode;
5050

5151
// Set
52-
flow_to_encode.source_naming_info = rina::ApplicationProcessNamingInformation("test", "1");
53-
flow_to_encode.destination_naming_info = rina::ApplicationProcessNamingInformation("test2", "1");
52+
flow_to_encode.local_naming_info = rina::ApplicationProcessNamingInformation("test", "1");
53+
flow_to_encode.remote_naming_info = rina::ApplicationProcessNamingInformation("test2", "1");
5454
dtp_config_to_encode.set_dtcp_present(true);
5555
dtp_config_to_encode.set_seq_num_rollover_threshold(1234);
5656
dtp_config_to_encode.set_initial_a_timer(14561);
@@ -90,9 +90,9 @@ bool test_flow () {
9090
encoder.decode(encoded_obj, flow_decoded);
9191

9292
// Assert
93-
if (flow_to_encode.source_naming_info.processName != flow_decoded.source_naming_info.processName)
93+
if (flow_to_encode.local_naming_info.processName != flow_decoded.local_naming_info.processName)
9494
return false;
95-
if (flow_to_encode.source_naming_info.processInstance != flow_decoded.source_naming_info.processInstance)
95+
if (flow_to_encode.local_naming_info.processInstance != flow_decoded.local_naming_info.processInstance)
9696
return false;
9797

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

0 commit comments

Comments
 (0)