Skip to content
Snippets Groups Projects
Commit 551ae96c authored by COUTURIER Christophe's avatar COUTURIER Christophe
Browse files

new version ready for L3!

parent 0c0fcb34
Branches
No related tags found
No related merge requests found
......@@ -8,19 +8,15 @@ set(ard_net_lib_sources
ard_error.cpp
ard_event_manager.cpp
ard_network_layer_one.cpp
# ard_network_layer_three.cpp
ard_callbacks.cpp
ard_globals.cpp
ard_network_layer_two_message.cpp
# ard_network_layer_three_message.cpp
ard_network_application_message.cpp
ard_network_address.cpp
ard_memcpy.cpp
ard_network_address.cpp
ard_circular_buffer.h
ard_fake_network_interfaces.h
# ard_network_layer_three_routing.cpp
)
ard_fake_network_interfaces.h)
add_library(ard_net_lib STATIC ${ard_net_lib_sources})
......
Can we remove the following files:
- ard_network_layer_routing (.h and .cpp)
- ard_network_policy_based (.h and .cpp)
Can we remove the ArdNetworkLayerThreeDummy class (ard_network_layer_three)?
\ No newline at end of file
......@@ -61,7 +61,8 @@ PktBufPtr AppSwitch::processRxData(PktBufPtr a_p, AnyAddr a_src_addr,
sendSwitchStatusMessage(m_last_requester_addr);
if (m_notify_general_controller)
sendSwitchStatusMessage(GetAppAddress(APP_DEV_CONTROLLER, c_SUPERVISION_NETWORK_ADD)); // Inform the central controller
sendSwitchStatusMessage(GetAppAddress(APP_DEV_CONTROLLER,
ArdNetConstants::occ_network_number)); // Inform the central controller
*p_result = true;
return (ard_move(a_p));
}
......@@ -181,7 +182,8 @@ void AppSwitch::sendStateToControllerIfNeeded(){
if (m_previous_direction != currentDirection){
sendSwitchStatusMessage(m_last_requester_addr); // Inform the last requester
if (m_notify_general_controller)
sendSwitchStatusMessage(GetAppAddress(APP_DEV_CONTROLLER, c_SUPERVISION_NETWORK_ADD)); // Inform the central controller
sendSwitchStatusMessage(GetAppAddress(APP_DEV_CONTROLLER,
ArdNetConstants::occ_network_number)); // Inform the central controller
m_previous_direction = currentDirection;
}
}
......
......@@ -81,7 +81,8 @@ PktBufPtr AppTrain::processRxData(PktBufPtr a_p, AnyAddr a_src_addr,
sendTrainStatusMessage(m_last_requester_addr);
if (m_notify_general_controller)
sendTrainStatusMessage(GetAppAddress(APP_DEV_CONTROLLER, c_SUPERVISION_NETWORK_ADD)); // Inform the central controller
sendTrainStatusMessage(GetAppAddress(APP_DEV_CONTROLLER,
ArdNetConstants::occ_network_number)); // Inform the central controller
*p_result = true;
return (ard_move(a_p));
}
......@@ -199,7 +200,8 @@ void AppTrain::sendStateToControllerIfNeeded(){
{
sendTrainStatusMessage(m_last_requester_addr); // Inform the last requester
if (m_notify_general_controller)
sendTrainStatusMessage(GetAppAddress(APP_DEV_CONTROLLER, c_SUPERVISION_NETWORK_ADD)); // Inform the central controller
sendTrainStatusMessage(GetAppAddress(APP_DEV_CONTROLLER,
ArdNetConstants::occ_network_number)); // Inform the central controller
m_last_sent_traction_state = m_traction_ON;
m_last_sent_traction_speed = m_adjusted_speed;
m_last_traction_direction = m_traction_direction;
......
......@@ -66,7 +66,7 @@ typedef Print &(*PrintStreamManipulator)(Print &);
// take in a function with the custom signature
inline Print &operator<<(Print &stream, PrintStreamManipulator manip) {
// call the function, and return it's value
// call the function, and return its value
return manip(stream);
}
......
......@@ -8,13 +8,21 @@
template <>
L3Addr mapAddr<AppAddr, L3Addr>(AppAddr a_addr, AppAddr a_this_addr) {
uint16_t net_add = ((a_addr.m_addr & 0xF0) << 4) & 0xFF00;
uint16_t net_add = ((a_this_addr.m_addr & 0xF0) << 4) & 0xFF00;
uint8_t app_add = a_addr.m_addr & 0x0F;
// If the target device is the OCC (don't care about the network),
// the network is the OCC network
if (app_add == APP_DEV_OCC)
net_add = ArdNetConstants::occ_network_number << 8;
// info_pr(ARD_F("App to L3:"), a_addr.m_addr, ARD_F(", "), a_this_addr.m_addr, ARD_F("\n") );
// info_pr(ARD_F(" L3 add:"), net_add + app_add, ARD_F("\n") );
return L3Addr(net_add + app_add);
}
template <> AppAddr mapAddr<L3Addr, AppAddr>(L3Addr a_addr, L3Addr a_this_addr){
uint8_t myNetAdd = (uint8_t)((a_this_addr.m_addr & 0xFF00) >> 8);
uint8_t netAdd = (uint8_t)((a_addr.m_addr & 0xFF00) >> 8);
uint8_t devAdd = (uint8_t)(a_addr.m_addr & 0x0F);
......@@ -30,35 +38,46 @@ template <> L2Addr mapAddr<L3Addr, L2Addr>(L3Addr a_addr, L3Addr a_this_addr) {
uint8_t devAdd = (uint8_t)(a_addr.m_addr & 0x0F);
uint8_t dev;
uint8_t net = (netAdd & 0x0F) << 4;
uint8_t net = (myNetAdd & 0x0F) << 4;
if (netAdd != ArdNetConstants::router_network_number) {
if (netAdd != ArdNetConstants::occ_network_number) {
dev = devAdd;
} else {
dev = (uint8_t)APP_DEV_GATEWAY;
dev = (uint8_t)L2_DEV_GATEWAY;
}
// info_pr(ARD_F("L3 to L2:"), a_addr.m_addr, ARD_F(", "), a_this_addr.m_addr, ARD_F("\n") );
// info_pr(ARD_F(" netAdd:"), netAdd, ARD_F(", occNet:"), ArdNetConstants::occ_network_number, ARD_F("\n") );
// info_pr(ARD_F(" L2 add:"), net+dev, ARD_F("\n") );
return L2Addr(net + dev);
}
// App -> L2
template <>
L2Addr mapAddr<AppAddr, L2Addr>(AppAddr a_addr, AppAddr a_this_addr) {
// info_pr(ARD_F("App to L2:"), a_addr.m_addr, ARD_F(", "), a_this_addr.m_addr,
// ARD_F("\n") );
return (L2Addr(a_addr.m_addr));
}
// L2 -> App
template <> AppAddr mapAddr<L2Addr, AppAddr>(L2Addr a_addr, L2Addr a_this_addr){
// info_pr(ARD_F("L2 to App:"), a_addr.m_addr, ARD_F(", "), a_this_addr.m_addr,
// ARD_F("\n") );
return AppAddr(a_addr.m_addr);
}
// L2 -> L1
template <> L1Addr mapAddr<L2Addr, L1Addr>(L2Addr a_addr, L2Addr m_this_addr) {
return L1Addr();
}
// L3 -> L1
template <> L1Addr mapAddr<L3Addr, L1Addr>(L3Addr a_addr, L3Addr m_this_addr) {
return L1Addr();
}
template <> AppAddr mapAddr<L2Addr, AppAddr>(L2Addr a_addr, L2Addr a_this_addr){
// info_pr(ARD_F("L2 to App:"), a_addr.m_addr, ARD_F(", "), a_this_addr.m_addr,
// ARD_F("\n") );
return AppAddr(a_addr.m_addr);
}
// Any -> App
template <> AppAddr mapAddr<AnyAddr, AppAddr>(AnyAddr a_addr, AnyAddr m_this_addr) {
switch (a_addr.m_addr_type) {
case AddrType::L1:
......@@ -110,28 +129,20 @@ uint8_t GetDevAddress(AppAddr a_app_addr){
}
// FIXME: The code below is from the SAR, we need to port it to the new
// version (sendInterface).
L3Addr GetL3Address(AppDevices a_dev, uint8_t a_network) {
uint16_t net_add = (a_network << 8) & 0xFF00;
lib_debug_pr(ARD_F("net_add = "), net_add, ARD_F(" net = "), a_network,
ARD_F("\n"));
switch (a_dev) {
case APP_DEV_CONTROLLER:
return L3Addr(net_add + uint8_t(a_dev));
break;
case APP_DEV_TRAIN:
return L3Addr(net_add + uint8_t(a_dev));
break;
case APP_DEV_SWITCH:
return L3Addr(net_add + uint8_t(a_dev));
break;
case APP_DEV_GATEWAY:
return L3Addr(net_add + uint8_t(a_dev));
break;
case APP_DEV_BCAST:
return L3Addr(net_add + uint8_t(a_dev));
break;
case APP_DEV_OCC:
return L3Addr(ArdNetConstants::occ_network_number<<8 + uint8_t(a_dev));
break;
default:
error_pr(ARD_F("GetL3Address called with wrong device type\n"));
} // END of switch(a_dev)
......@@ -157,7 +168,7 @@ L2Addr GetL2Address(L3Addr a_l3_add, uint8_t a_local_network_number) {
net = (netAdd << 4) & 0xF0;
} else {
net = (a_local_network_number << 4) & 0xF0;
devAdd = (uint8_t)APP_DEV_GATEWAY;
devAdd = (uint8_t)L2_DEV_GATEWAY;
}
return L2Addr(net + devAdd);
......@@ -167,19 +178,19 @@ L2Addr GetL2Address(AppDevices a_dev, uint8_t a_network) {
uint8_t net = (a_network << 4) & 0xF0;
switch (a_dev) {
case APP_DEV_CONTROLLER:
return L2Addr(net + 0);
return L2Addr(net + L2_DEV_CONTROLLER);
break;
case APP_DEV_TRAIN:
return L2Addr(net + 1);
return L2Addr(net + L2_DEV_TRAIN);
break;
case APP_DEV_SWITCH:
return L2Addr(net + 8);
return L2Addr(net + L2_DEV_SWITCH);
break;
case APP_DEV_GATEWAY:
return L2Addr(net + 0xE);
return L2Addr(net + L2_DEV_GATEWAY);
break;
case APP_DEV_BCAST:
return L2Addr(net + 0xF);
return L2Addr(net + L2_DEV_BCAST);
break;
default:
error_pr("GetL2Address called with wrong device type\n");
......
......@@ -153,17 +153,25 @@ template <> L1Addr mapAddr<L2Addr, L1Addr>(L2Addr a_addr, L2Addr a_this_addr);
template <> AppAddr mapAddr<AnyAddr, AppAddr>(AnyAddr a_addr, AnyAddr m_this_addr);
template <> AppAddr mapAddr<L2Addr, AppAddr>(L2Addr a_addr, L2Addr a_this_addr);
// FIXME: turn the enum into enum class...
// FIXME: turn these enums into enum class...
enum AppDevices {
APP_DEV_CONTROLLER = 0x00,
APP_DEV_TRAIN = 0x01,
APP_DEV_SWITCH = 0x08,
APP_DEV_OCC = 0x0D,
APP_DEV_GATEWAY = 0x0E,
APP_DEV_BCAST = 0x0F
};
enum L2DevicesAdd {
L2_DEV_CONTROLLER = APP_DEV_CONTROLLER,
L2_DEV_TRAIN = APP_DEV_TRAIN,
L2_DEV_SWITCH = APP_DEV_TRAIN,
L2_DEV_GATEWAY = APP_DEV_GATEWAY,
L2_DEV_BCAST = APP_DEV_BCAST
};
namespace ArdNetConstants {
constexpr uint8_t router_network_number = 0x0E; /**< The address of the ethernet network */
constexpr uint8_t broadcast_network_number = 0x0F; /**< The network number for broadcast */
constexpr uint8_t occ_network_number = 0xFE; /**< The address of the OCC network */
}
// FIXME: move the corresponding code to the send interfaces.
......@@ -173,8 +181,6 @@ L2Addr GetL2Address(L3Addr a_l3_add, uint8_t a_local_network_number);
L2Addr GetL2Address(AppDevices a_dev, uint8_t a_network);
L2Addr GetL2Address(L3Addr a_l3_add);
const uint8_t c_SUPERVISION_NETWORK_ADD = 254;
AppAddr GetAppAddress(uint8_t a_dev, uint8_t a_network);
uint8_t GetNetAddress(AppAddr a_app_addr);
......
......@@ -308,20 +308,6 @@ protected:
enum class RoutingInterfaceName { left, right, none };
/**
* @brief Abstract Base (template) Class for the routing interface.
*
* This template defines only the interface of the routing module. The
* input is the Each
* implementation must provide its own routing table.
*
* @tparam T The address type.
*/
template<typename T> class RoutingInterface{
public:
virtual RoutingInterfaceName getOutputInterface(T dst_addr)=0;
};
template <typename T> class ArdNetworkRoutingLayer {
public:
/**
......@@ -343,8 +329,6 @@ public:
* left interface.
* @param a_send_interface_right A pointer to the send interface for the
* right interface.
* @param a_routing_interface A pointer to the routing interface
* implementing the routing logic.
* @param a_this_addr_left The address of this network layer instance on
* the left interface.
* @param a_this_addr_right The address of this network layer instance on
......@@ -356,13 +340,11 @@ public:
ArdEventManager *a_event_manager,
SendInterface<T> *a_send_interface_left,
SendInterface<T> *a_send_interface_right,
RoutingInterface<T> *a_routing_interface,
T a_this_addr_left, T a_this_addr_right)
: m_mem_pool(a_mem_pool), m_ard_sys_int(a_ard_sys_int),
m_event_manager(a_event_manager),
m_send_interface_left(a_send_interface_left),
m_send_interface_right(a_send_interface_right),
m_routing_interface(a_routing_interface),
m_this_addr_left(a_this_addr_left),
m_this_addr_right(a_this_addr_right), m_l_id(0) {}
......@@ -372,7 +354,6 @@ protected:
ArdEventManager *m_event_manager;
SendInterface<T> *m_send_interface_left;
SendInterface<T> *m_send_interface_right;
RoutingInterface<T> *m_routing_interface;
uint8_t m_l_id;
T m_this_addr_left;
T m_this_addr_right;
......
#include "ard_network_layer_two_message.h"
#include "ard_memcpy.h"
#include "ard_utils.h"
/********************************************************************
* Layer Two Messages *
......@@ -45,7 +44,7 @@ PktBufPtr L2Message::serialize(PktBufPtr a_sdu,
ard_error(ARD_F("L2Message Serialize with non valid pointer"));
}
m_pkt_buff->curr_size = l2_header_size + payload_size;
return (ard_move(a_sdu));
return (a_sdu);
}
PktBufPtr L2Message::serialize(PktMemPool *a_mpool)
......
# It is supposed that sar has been configured in ~/.ssh/config
CALLING_DIR=`pwd`
SCRIPT_DIR=`dirname "$0"`
cd $SCRIPT_DIR
#rsync -r --del generated-docs/html/ int-res:/web/int-res/doxygen/
rsync -r --del generated-docs/html/ sar-res:/web/sar-res/doxygen/
cd $CALLING_DIR
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment