aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-11-07 16:42:01 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-11-08 01:36:45 +0100
commit1bf749aa3e4b0ccc40057b2587af5211926a1431 (patch)
tree1e59105d64e7dc13f4f1cd4ae8437bb8bb932292 /hicn-light
parenta30d495f6e91f3bed0420bf76c19315fe0de8801 (diff)
[HICN-385] fix route removal in hicnctrl, code uniformization in hicn-light control api
Change-Id: Id097368dcde993775f206623195cc5aa57b4fe12 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'hicn-light')
-rw-r--r--hicn-light/src/hicn/config/configuration.c32
-rw-r--r--hicn-light/src/hicn/config/configurationListeners.c16
-rw-r--r--hicn-light/src/hicn/config/controlAddConnection.c8
-rw-r--r--hicn-light/src/hicn/config/controlAddListener.c5
-rw-r--r--hicn-light/src/hicn/config/controlAddPolicy.c4
-rw-r--r--hicn-light/src/hicn/config/controlAddPunting.c4
-rw-r--r--hicn-light/src/hicn/config/controlAddRoute.c4
-rw-r--r--hicn-light/src/hicn/config/controlListPolicies.c1
-rw-r--r--hicn-light/src/hicn/config/controlRemovePolicy.c4
-rw-r--r--hicn-light/src/hicn/config/controlRemoveRoute.c4
-rw-r--r--hicn-light/src/hicn/config/controlSetStrategy.c4
-rw-r--r--hicn-light/src/hicn/core/name.c6
-rw-r--r--hicn-light/src/hicn/core/name.h2
-rw-r--r--hicn-light/src/hicn/core/nameBitvector.c4
-rw-r--r--hicn-light/src/hicn/processor/fibEntry.c2
-rw-r--r--hicn-light/src/hicn/socket/ops_linux.c50
-rw-r--r--hicn-light/src/hicn/utils/commands.h34
-rw-r--r--hicn-light/src/hicn/utils/utils.c8
-rw-r--r--hicn-light/src/hicn/utils/utils.h6
19 files changed, 107 insertions, 91 deletions
diff --git a/hicn-light/src/hicn/config/configuration.c b/hicn-light/src/hicn/config/configuration.c
index c10b01c30..01192569f 100644
--- a/hicn-light/src/hicn/config/configuration.c
+++ b/hicn-light/src/hicn/config/configuration.c
@@ -305,11 +305,11 @@ struct iovec *configuration_ProcessRegistrationList(Configuration *config,
if (addressGetType(addressEntry) == ADDR_INET) {
addressGetInet(addressEntry, &tmpAddr);
listRouteCommand->addressType = ADDR_INET;
- listRouteCommand->address.ipv4 = tmpAddr.sin_addr.s_addr;
+ listRouteCommand->address.v4.as_inaddr = tmpAddr.sin_addr;
} else if (addressGetType(addressEntry) == ADDR_INET6) {
addressGetInet6(addressEntry, &tmpAddr6);
listRouteCommand->addressType = ADDR_INET6;
- listRouteCommand->address.ipv6 = tmpAddr6.sin6_addr;
+ listRouteCommand->address.v6.as_in6addr = tmpAddr6.sin6_addr;
}
listRouteCommand->connid = numberSet_GetItem(nexthops, j);
listRouteCommand->len = nameBitvector_GetLength(prefix);
@@ -370,14 +370,14 @@ struct iovec *configuration_ProcessCreateTunnel(Configuration *config,
if (control->ipType == ADDR_INET) {
source =
- addressFromInaddr4Port(&control->localIp.ipv4, &control->localPort);
+ addressFromInaddr4Port(&control->localIp.v4.as_u32, &control->localPort);
destination =
- addressFromInaddr4Port(&control->remoteIp.ipv4, &control->remotePort);
+ addressFromInaddr4Port(&control->remoteIp.v4.as_u32, &control->remotePort);
} else if (control->ipType == ADDR_INET6) {
source =
- addressFromInaddr6Port(&control->localIp.ipv6, &control->localPort);
+ addressFromInaddr6Port(&control->localIp.v6.as_in6addr, &control->localPort);
destination =
- addressFromInaddr6Port(&control->remoteIp.ipv6, &control->remotePort);
+ addressFromInaddr6Port(&control->remoteIp.v6.as_in6addr, &control->remotePort);
} else {
printf("Invalid IP type.\n"); // will generate a Nack
}
@@ -714,14 +714,14 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config,
// get local port/address
addressGetInet(localAddress, &tmpAddr);
listConnectionsCommand->connectionData.localPort = tmpAddr.sin_port;
- listConnectionsCommand->connectionData.localIp.ipv4 =
- tmpAddr.sin_addr.s_addr;
+ listConnectionsCommand->connectionData.localIp.v4.as_inaddr =
+ tmpAddr.sin_addr;
memset(&tmpAddr, 0, sizeof(tmpAddr));
// get remote port/address
addressGetInet(remoteAddress, &tmpAddr);
listConnectionsCommand->connectionData.remotePort = tmpAddr.sin_port;
- listConnectionsCommand->connectionData.remoteIp.ipv4 =
- tmpAddr.sin_addr.s_addr;
+ listConnectionsCommand->connectionData.remoteIp.v4.as_inaddr =
+ tmpAddr.sin_addr;
} else if (addressGetType(localAddress) == ADDR_INET6 &&
addressGetType(remoteAddress) == ADDR_INET6) {
@@ -730,12 +730,12 @@ struct iovec *configuration_ProcessConnectionList(Configuration *config,
// get local port/address
addressGetInet6(localAddress, &tmpAddr6);
listConnectionsCommand->connectionData.localPort = tmpAddr6.sin6_port;
- listConnectionsCommand->connectionData.localIp.ipv6 = tmpAddr6.sin6_addr;
+ listConnectionsCommand->connectionData.localIp.v6.as_in6addr = tmpAddr6.sin6_addr;
memset(&tmpAddr6, 0, sizeof(tmpAddr6));
// get remote port/address
addressGetInet6(remoteAddress, &tmpAddr6);
listConnectionsCommand->connectionData.remotePort = tmpAddr6.sin6_port;
- listConnectionsCommand->connectionData.remoteIp.ipv6 = tmpAddr6.sin6_addr;
+ listConnectionsCommand->connectionData.remoteIp.v6.as_in6addr = tmpAddr6.sin6_addr;
} // no need further else, control on the addressed already done at the
// time of insertion in the connection table
@@ -789,7 +789,7 @@ struct iovec *configuration_ProcessListenersList(Configuration *config,
(const Address *)listenerEntry->getListenAddress(listenerEntry),
&tmpAddr);
listListenersCommand->addressType = ADDR_INET;
- listListenersCommand->address.ipv4 = tmpAddr.sin_addr.s_addr;
+ listListenersCommand->address.v4.as_inaddr = tmpAddr.sin_addr;
listListenersCommand->port = tmpAddr.sin_port;
} else if (addressGetType((const Address *)listenerEntry->getListenAddress(
listenerEntry)) == ADDR_INET6) {
@@ -797,7 +797,7 @@ struct iovec *configuration_ProcessListenersList(Configuration *config,
(const Address *)listenerEntry->getListenAddress(listenerEntry),
&tmpAddr6);
listListenersCommand->addressType = ADDR_INET6;
- listListenersCommand->address.ipv6 = tmpAddr6.sin6_addr;
+ listListenersCommand->address.v6.as_in6addr = tmpAddr6.sin6_addr;
listListenersCommand->port = tmpAddr6.sin6_port;
}
@@ -1209,11 +1209,11 @@ struct iovec *configuration_ProcessPolicyList(Configuration *config,
if (addressGetType(addressEntry) == ADDR_INET) {
addressGetInet(addressEntry, &tmpAddr);
listPoliciesCommand->addressType = ADDR_INET;
- listPoliciesCommand->address.ipv4 = tmpAddr.sin_addr.s_addr;
+ listPoliciesCommand->address.v4.as_inaddr = tmpAddr.sin_addr;
} else if (addressGetType(addressEntry) == ADDR_INET6) {
addressGetInet6(addressEntry, &tmpAddr6);
listPoliciesCommand->addressType = ADDR_INET6;
- listPoliciesCommand->address.ipv6 = tmpAddr6.sin6_addr;
+ listPoliciesCommand->address.v6.as_in6addr = tmpAddr6.sin6_addr;
}
listPoliciesCommand->len = nameBitvector_GetLength(prefix);
listPoliciesCommand->policy = fibEntry_GetPolicy(entry);
diff --git a/hicn-light/src/hicn/config/configurationListeners.c b/hicn-light/src/hicn/config/configurationListeners.c
index 8abbeb781..21bfe7640 100644
--- a/hicn-light/src/hicn/config/configurationListeners.c
+++ b/hicn-light/src/hicn/config/configurationListeners.c
@@ -364,7 +364,7 @@ bool _addHicn(Configuration *config, add_listener_command *control,
switch (control->addressType) {
case ADDR_INET: {
localAddress =
- addressFromInaddr4Port(&control->address.ipv4, &control->port);
+ addressFromInaddr4Port(&control->address.v4.as_u32, &control->port);
success = _setupHicnListenerOnInet4(configuration_GetForwarder(config),
symbolic, localAddress);
break;
@@ -372,7 +372,7 @@ bool _addHicn(Configuration *config, add_listener_command *control,
case ADDR_INET6: {
localAddress =
- addressFromInaddr6Port(&control->address.ipv6, &control->port);
+ addressFromInaddr6Port(&control->address.v6.as_in6addr, &control->port);
success = _setupHicnListenerOnInet6(configuration_GetForwarder(config),
symbolic, localAddress);
break;
@@ -416,11 +416,11 @@ bool _addIP(Configuration *config, add_listener_command *control,
if (control->connectionType == UDP_CONN) {
success =
_setupUdpListenerOnInet(configuration_GetForwarder(config), symbolic,
- &control->address.ipv4, &control->port, control->interfaceName);
+ &control->address.v4.as_u32, &control->port, control->interfaceName);
} else if (control->connectionType == TCP_CONN) {
success =
_setupTcpListenerOnInet(configuration_GetForwarder(config), symbolic,
- &control->address.ipv4, &control->port, control->interfaceName);
+ &control->address.v4.as_u32, &control->port, control->interfaceName);
}
break;
}
@@ -428,11 +428,11 @@ bool _addIP(Configuration *config, add_listener_command *control,
case ADDR_INET6: {
if (control->connectionType == UDP_CONN) {
success = _setupUdpListenerOnInet6Light(
- configuration_GetForwarder(config), symbolic, &control->address.ipv6,
+ configuration_GetForwarder(config), symbolic, &control->address.v6.as_in6addr,
&control->port, control->interfaceName);
} else if (control->connectionType == TCP_CONN) {
success = _setupTcpListenerOnInet6Light(
- configuration_GetForwarder(config), symbolic, &control->address.ipv6,
+ configuration_GetForwarder(config), symbolic, &control->address.v6.as_in6addr,
&control->port, control->interfaceName, 0);
}
break;
@@ -522,12 +522,12 @@ struct iovec *configurationListeners_AddPunting(Configuration *config,
bool success = false;
if (control->addressType == ADDR_INET) {
- Address *address = addressFromInaddr4Port(&control->address.ipv4, &port);
+ Address *address = addressFromInaddr4Port(&control->address.v4.as_u32, &port);
Punting *punting = puntingCreate(symbolicOrConnid, address, len);
success = _AddPuntingInet(config, punting, ingressId);
addressDestroy(&address);
} else if (control->addressType == ADDR_INET6) {
- Address *address = addressFromInaddr6Port(&control->address.ipv6, &port);
+ Address *address = addressFromInaddr6Port(&control->address.v6.as_in6addr, &port);
Punting *punting = puntingCreate(symbolicOrConnid, address, len);
success = _AddPuntingInet6(config, punting, ingressId);
addressDestroy(&address);
diff --git a/hicn-light/src/hicn/config/controlAddConnection.c b/hicn-light/src/hicn/config/controlAddConnection.c
index eaa680bde..e5af5a251 100644
--- a/hicn-light/src/hicn/config/controlAddConnection.c
+++ b/hicn-light/src/hicn/config/controlAddConnection.c
@@ -228,15 +228,15 @@ static CommandReturn _controlAddConnection_CreateTunnel(
parcMemory_AllocateAndClear(sizeof(add_connection_command));
// check and set IP addresses
- if (inet_pton(AF_INET, remote_ip, &addConnectionCommand->remoteIp.ipv4) ==
+ if (inet_pton(AF_INET, remote_ip, &addConnectionCommand->remoteIp.v4.as_u32) ==
1 &&
- inet_pton(AF_INET, local_ip, &addConnectionCommand->localIp.ipv4) == 1) {
+ inet_pton(AF_INET, local_ip, &addConnectionCommand->localIp.v4.as_u32) == 1) {
addConnectionCommand->ipType = ADDR_INET;
} else if (inet_pton(AF_INET6, remote_ip,
- &addConnectionCommand->remoteIp.ipv6) == 1 &&
+ &addConnectionCommand->remoteIp.v6.as_in6addr) == 1 &&
inet_pton(AF_INET6, local_ip,
- &addConnectionCommand->localIp.ipv6) == 1) {
+ &addConnectionCommand->localIp.v6.as_in6addr) == 1) {
addConnectionCommand->ipType = ADDR_INET6;
} else {
diff --git a/hicn-light/src/hicn/config/controlAddListener.c b/hicn-light/src/hicn/config/controlAddListener.c
index 1a94ff252..d4537b855 100644
--- a/hicn-light/src/hicn/config/controlAddListener.c
+++ b/hicn-light/src/hicn/config/controlAddListener.c
@@ -106,11 +106,10 @@ static CommandReturn _CreateListener(CommandParser *parser, CommandOps *ops,
parcMemory_AllocateAndClear(sizeof(add_listener_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &addListenerCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &addListenerCommand->address.v4.as_u32) == 1) {
addListenerCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &addListenerCommand->address.ipv6) ==
- 1) {
+ } else if (inet_pton(AF_INET6, addr, &addListenerCommand->address.v6.as_in6addr) == 1) {
addListenerCommand->addressType = ADDR_INET6;
} else {
diff --git a/hicn-light/src/hicn/config/controlAddPolicy.c b/hicn-light/src/hicn/config/controlAddPolicy.c
index 9bca3355e..29120446b 100644
--- a/hicn-light/src/hicn/config/controlAddPolicy.c
+++ b/hicn-light/src/hicn/config/controlAddPolicy.c
@@ -104,7 +104,7 @@ static CommandReturn _controlAddPolicy_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(add_policy_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &addPolicyCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &addPolicyCommand->address.v4.as_u32) == 1) {
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addPolicyCommand);
@@ -112,7 +112,7 @@ static CommandReturn _controlAddPolicy_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
addPolicyCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &addPolicyCommand->address.ipv6) == 1) {
+ } else if (inet_pton(AF_INET6, addr, &addPolicyCommand->address.v6.as_in6addr) == 1) {
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addPolicyCommand);
diff --git a/hicn-light/src/hicn/config/controlAddPunting.c b/hicn-light/src/hicn/config/controlAddPunting.c
index ff441f7f0..e3fb57c6b 100644
--- a/hicn-light/src/hicn/config/controlAddPunting.c
+++ b/hicn-light/src/hicn/config/controlAddPunting.c
@@ -109,7 +109,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(add_punting_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &addPuntingCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &addPuntingCommand->address.v4.as_u32) == 1) {
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addPuntingCommand);
@@ -117,7 +117,7 @@ static CommandReturn _controlAddPunting_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
addPuntingCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &addPuntingCommand->address.ipv6) == 1) {
+ } else if (inet_pton(AF_INET6, addr, &addPuntingCommand->address.v6.as_in6addr) == 1) {
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addPuntingCommand);
diff --git a/hicn-light/src/hicn/config/controlAddRoute.c b/hicn-light/src/hicn/config/controlAddRoute.c
index 086cf3a2b..8a1adf6d6 100644
--- a/hicn-light/src/hicn/config/controlAddRoute.c
+++ b/hicn-light/src/hicn/config/controlAddRoute.c
@@ -113,7 +113,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(add_route_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &addRouteCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &addRouteCommand->address.v4.as_u32) == 1) {
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&addRouteCommand);
@@ -121,7 +121,7 @@ static CommandReturn _controlAddRoute_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
addRouteCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &addRouteCommand->address.ipv6) == 1) {
+ } else if (inet_pton(AF_INET6, addr, &addRouteCommand->address.v6.as_in6addr) == 1) {
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
parcMemory_Deallocate(&addRouteCommand);
diff --git a/hicn-light/src/hicn/config/controlListPolicies.c b/hicn-light/src/hicn/config/controlListPolicies.c
index c70d8baea..9aff68c69 100644
--- a/hicn-light/src/hicn/config/controlListPolicies.c
+++ b/hicn-light/src/hicn/config/controlListPolicies.c
@@ -69,7 +69,6 @@ static CommandReturn _controlListPolicies_HelpExecute(CommandParser *parser,
#define MAXSZ_STR_STAT 10
#define MAXSZ_APP_NAME 25
-#define MAXSZ_PREFIX 25
typedef struct {
#define _(x, y) char x[MAXSZ_POLICY_TAG_STATE];
diff --git a/hicn-light/src/hicn/config/controlRemovePolicy.c b/hicn-light/src/hicn/config/controlRemovePolicy.c
index 510203886..bd2e6e6d8 100644
--- a/hicn-light/src/hicn/config/controlRemovePolicy.c
+++ b/hicn-light/src/hicn/config/controlRemovePolicy.c
@@ -96,7 +96,7 @@ static CommandReturn _controlRemovePolicy_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(remove_policy_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &removePolicyCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &removePolicyCommand->address.v4.as_u32) == 1) {
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&removePolicyCommand);
@@ -104,7 +104,7 @@ static CommandReturn _controlRemovePolicy_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
removePolicyCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &removePolicyCommand->address.ipv6) ==
+ } else if (inet_pton(AF_INET6, addr, &removePolicyCommand->address.v6.as_in6addr) ==
1) {
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
diff --git a/hicn-light/src/hicn/config/controlRemoveRoute.c b/hicn-light/src/hicn/config/controlRemoveRoute.c
index 0626886de..0f46211c1 100644
--- a/hicn-light/src/hicn/config/controlRemoveRoute.c
+++ b/hicn-light/src/hicn/config/controlRemoveRoute.c
@@ -104,7 +104,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(remove_route_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &removeRouteCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &removeRouteCommand->address.v4.as_u32) == 1) {
if (len > 32) {
printf("ERROR: exceeded INET mask length, max=32\n");
parcMemory_Deallocate(&removeRouteCommand);
@@ -112,7 +112,7 @@ static CommandReturn _controlRemoveRoute_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
removeRouteCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &removeRouteCommand->address.ipv6) ==
+ } else if (inet_pton(AF_INET6, addr, &removeRouteCommand->address.v6.as_in6addr) ==
1) {
if (len > 128) {
printf("ERROR: exceeded INET6 mask length, max=128\n");
diff --git a/hicn-light/src/hicn/config/controlSetStrategy.c b/hicn-light/src/hicn/config/controlSetStrategy.c
index b2968712f..d8b326f42 100644
--- a/hicn-light/src/hicn/config/controlSetStrategy.c
+++ b/hicn-light/src/hicn/config/controlSetStrategy.c
@@ -123,7 +123,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser,
parcMemory_AllocateAndClear(sizeof(set_strategy_command));
// check and set IP address
- if (inet_pton(AF_INET, addr, &setStrategyCommand->address.ipv4) == 1) {
+ if (inet_pton(AF_INET, addr, &setStrategyCommand->address.v4.as_u32) == 1) {
if (len == UINT32_MAX) {
printf("Netmask not specified: set to 32 by default\n");
len = 32;
@@ -134,7 +134,7 @@ static CommandReturn _controlSetStrategy_Execute(CommandParser *parser,
return CommandReturn_Failure;
}
setStrategyCommand->addressType = ADDR_INET;
- } else if (inet_pton(AF_INET6, addr, &setStrategyCommand->address.ipv6) ==
+ } else if (inet_pton(AF_INET6, addr, &setStrategyCommand->address.v6.as_in6addr) ==
1) {
if (len == UINT32_MAX) {
printf("Netmask not specified: set to 128 by default\n");
diff --git a/hicn-light/src/hicn/core/name.c b/hicn-light/src/hicn/core/name.c
index f4ea7dbca..7ef3fcc01 100644
--- a/hicn-light/src/hicn/core/name.c
+++ b/hicn-light/src/hicn/core/name.c
@@ -112,15 +112,15 @@ Name *name_CreateFromPacket(const uint8_t *packet, MessagePacketType type) {
return name;
}
-Name *name_CreateFromAddress(address_type addressType, union commandAddr addr,
+Name *name_CreateFromAddress(address_type addressType, ip_address_t addr,
uint8_t len) {
Name *name = parcMemory_AllocateAndClear(sizeof(Name));
parcAssertNotNull(name, "parcMemory_AllocateAndClear(%zu) returned NULL",
sizeof(Name));
if (addressType == ADDR_INET) {
- name->content_name = nameBitvector_CreateFromInAddr(addr.ipv4, len);
+ name->content_name = nameBitvector_CreateFromInAddr(addr.v4.as_u32, len);
} else if (addressType == ADDR_INET6) {
- name->content_name = nameBitvector_CreateFromIn6Addr(&addr.ipv6, len);
+ name->content_name = nameBitvector_CreateFromIn6Addr(&addr.v6.as_in6addr, len);
} else {
parcTrapNotImplemented("Unkown packet type");
}
diff --git a/hicn-light/src/hicn/core/name.h b/hicn-light/src/hicn/core/name.h
index f2ae1f64e..29c8439f8 100644
--- a/hicn-light/src/hicn/core/name.h
+++ b/hicn-light/src/hicn/core/name.h
@@ -93,7 +93,7 @@ void name_setLen(Name *name, uint8_t len);
* Creates a name from a Address
*
*/
-Name *name_CreateFromAddress(address_type addressType, union commandAddr addr,
+Name *name_CreateFromAddress(address_type addressType, ip_address_t addr,
uint8_t len);
#ifdef WITH_POLICY
diff --git a/hicn-light/src/hicn/core/nameBitvector.c b/hicn-light/src/hicn/core/nameBitvector.c
index 9a734359c..ab459b126 100644
--- a/hicn-light/src/hicn/core/nameBitvector.c
+++ b/hicn-light/src/hicn/core/nameBitvector.c
@@ -266,7 +266,7 @@ void nameBitvector_clear(NameBitvector *a, uint8_t start_from){
int nameBitvector_ToIPAddress(const NameBitvector *name,
ip_prefix_t *prefix) {
if (name->IPversion == IPv4_TYPE) {
- struct in_addr *addr = (struct in_addr *)(&prefix->address.buffer);
+ struct in_addr *addr = (struct in_addr *)(&prefix->address.v4.buffer);
prefix->family = AF_INET;
prefix->len = IPV4_ADDR_LEN_BITS;
@@ -283,7 +283,7 @@ int nameBitvector_ToIPAddress(const NameBitvector *name,
addr->s_addr = (addr->s_addr | addr_1);
} else {
- struct in6_addr *addr = (struct in6_addr *)(&prefix->address.buffer);
+ struct in6_addr *addr = (struct in6_addr *)(&prefix->address.v6.buffer);
prefix->family = AF_INET6;
prefix->len = name->len; // IPV6_ADDR_LEN_BITS;
diff --git a/hicn-light/src/hicn/processor/fibEntry.c b/hicn-light/src/hicn/processor/fibEntry.c
index 28cf6b13c..1aaa3ace9 100644
--- a/hicn-light/src/hicn/processor/fibEntry.c
+++ b/hicn-light/src/hicn/processor/fibEntry.c
@@ -58,7 +58,7 @@ struct fib_entry {
const Forwarder * forwarder;
policy_t policy;
policy_counters_t policy_counters;
- NumberSet *available_nexthops;
+// NumberSet *available_nexthops;
#ifdef WITH_MAPME
/* In case of no multipath, this stores the previous decision taken by policy */
unsigned previous_nexthop;
diff --git a/hicn-light/src/hicn/socket/ops_linux.c b/hicn-light/src/hicn/socket/ops_linux.c
index 96636039f..8bfc438f3 100644
--- a/hicn-light/src/hicn/socket/ops_linux.c
+++ b/hicn-light/src/hicn/socket/ops_linux.c
@@ -574,7 +574,7 @@ int _nl_get_ip_addr(uint32_t interface_id, uint8_t address_family,
if (address_family == AF_INET6) {
if ((payload->ifa_index == interface_id) &&
(payload->ifa_prefixlen < IPV6_ADDR_LEN * 8)) {
- memcpy(prefix->address.buffer, RTA_DATA(payload + 1), IPV6_ADDR_LEN);
+ memcpy(prefix->address.v6.buffer, RTA_DATA(payload + 1), IPV6_ADDR_LEN);
prefix->family = AF_INET6;
prefix->len = IPV6_ADDR_LEN_BITS;
return HICN_SOCKET_ERROR_NONE;
@@ -582,7 +582,7 @@ int _nl_get_ip_addr(uint32_t interface_id, uint8_t address_family,
} else if (address_family == AF_INET) {
if ((payload->ifa_index == interface_id) &&
(payload->ifa_prefixlen < IPV4_ADDR_LEN * 8)) {
- memcpy(prefix->address.buffer, RTA_DATA(payload + 1), IPV4_ADDR_LEN);
+ memcpy(prefix->address.v4.buffer, RTA_DATA(payload + 1), IPV4_ADDR_LEN);
prefix->family = AF_INET;
prefix->len = IPV4_ADDR_LEN_BITS;
return HICN_SOCKET_ERROR_NONE;
@@ -621,10 +621,13 @@ int _nl_set_ip_addr(uint32_t interface_id, ip_prefix_t *prefix) {
/* Set attributes = length/type/value */
struct rtattr ifa_address = {RTA_LENGTH(ip_address_len(prefix->family)),
IFA_ADDRESS};
- struct iovec iov[] = {
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR_ADDRESS;
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
{&ifa_address, sizeof(ifa_address)},
- {(void *)&prefix->address.buffer, sizeof(prefix->address.buffer)},
+ {(void*)address, ip_address_len(prefix->family)},
};
msg.hdr.nlmsg_len = iov_length(iov, ARRAY_SIZE(iov));
@@ -658,6 +661,7 @@ ERR_NL:
ERR_RECV:
ERR_SEND:
ERR_SOCKET:
+ERR_ADDRESS:
return -1;
}
@@ -989,11 +993,14 @@ int _nl_del_lo_route(const ip_prefix_t *prefix) {
uint32_t one = 1;
struct rtattr a_dst = {RTA_LENGTH(ip_address_len(prefix->family)), RTA_DST};
struct rtattr a_ifid_lo = {RTA_LENGTH(sizeof(uint32_t)), RTA_OIF};
- struct iovec iov[] = {
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR;
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Ip address */
{&a_dst, sizeof(a_dst)},
- {(void *)&prefix->address.buffer, ip_address_len(prefix->family)},
+ {(void*)address, ip_address_len(prefix->family)},
/* Interface id */
{&a_ifid_lo, sizeof(a_ifid_lo)},
{&one, sizeof(one)}};
@@ -1151,12 +1158,16 @@ int _nl_add_neigh_proxy(const ip_prefix_t *prefix,
/* Message attributes = length/type/value */
struct rtattr a_dst = {RTA_LENGTH(ip_address_len(prefix->family)), NDA_DST};
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR;
+
/* Iovec describing the packets */
- struct iovec iov[] = {
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Ip address */
{&a_dst, sizeof(a_dst)},
- {(void *)&prefix->address.buffer, sizeof(prefix->address.buffer)},
+ {(void*)address, ip_address_len(prefix->family)},
};
msg.hdr.nlmsg_len = iov_length(iov, ARRAY_SIZE(iov));
@@ -1229,12 +1240,16 @@ int _nl_add_in_route_table(const ip_prefix_t *prefix,
struct rtattr a_dst = {RTA_LENGTH(ip_address_len(prefix->family)), RTA_DST};
struct rtattr a_oif = {RTA_LENGTH(sizeof(uint32_t)), RTA_OIF};
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR;
+
/* Iovec describing the packets */
- struct iovec iov[] = {
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Destination prefix / ip address */
{&a_dst, sizeof(a_dst)},
- {(void *)&prefix->address.buffer, ip_address_len(prefix->family)},
+ {(void*)address, ip_address_len(prefix->family)},
/* Output interface */
{&a_oif, sizeof(a_oif)},
{(void *)&interface_id, sizeof(uint32_t)},
@@ -1331,12 +1346,15 @@ int _nl_add_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
struct rtattr a_src = {RTA_LENGTH(ip_address_len(prefix->family)), FRA_SRC};
struct rtattr a_prio = {RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY};
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR;
/* Iovec describing the packets */
- struct iovec iov[] = {
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Source prefix / prefix */
{&a_src, sizeof(a_src)},
- {(void *)&prefix->address.buffer, ip_address_len(prefix->family)},
+ {(void*)address, ip_address_len(prefix->family)},
/* Priority */
{&a_prio, sizeof(a_prio)},
{(void *)&priority, sizeof(uint32_t)},
@@ -1432,12 +1450,16 @@ int _nl_del_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
struct rtattr a_src = {RTA_LENGTH(ip_address_len(prefix->family)), FRA_SRC};
struct rtattr a_prio = {RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY};
+ const void * address = ip_address_get_buffer(&prefix->address, prefix->family);
+ if (!address)
+ goto ERR;
+
/* Iovec describing the packets */
- struct iovec iov[] = {
+ const struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Source prefix / prefix */
{&a_src, sizeof(a_src)},
- {(void *)&prefix->address.buffer, ip_address_len(prefix->family)},
+ {(void*)address, ip_address_len(prefix->family)},
/* Priority */
{&a_prio, sizeof(a_prio)},
{(void *)&priority, sizeof(uint32_t)},
diff --git a/hicn-light/src/hicn/utils/commands.h b/hicn-light/src/hicn/utils/commands.h
index 60d4cd5fa..a5bc15e8a 100644
--- a/hicn-light/src/hicn/utils/commands.h
+++ b/hicn-light/src/hicn/utils/commands.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <hicn/util/ip_address.h>
#ifdef WITH_POLICY
#include <hicn/policy.h>
#endif /* WITH_POLICY */
@@ -40,11 +41,6 @@
typedef struct in6_addr ipv6_addr_t;
typedef uint32_t ipv4_addr_t;
-union commandAddr {
- ipv4_addr_t ipv4;
- ipv6_addr_t ipv6;
-};
-
typedef enum {
REQUEST_LIGHT = 0xc0, // this is a command
RESPONSE_LIGHT,
@@ -119,7 +115,7 @@ typedef enum { ETHER_MODE, IP_MODE, HICN_MODE } listener_mode;
typedef struct {
char symbolic[SYMBOLIC_NAME_LEN];
char interfaceName[SYMBOLIC_NAME_LEN];
- union commandAddr address;
+ ip_address_t address;
uint16_t port;
// uint16_t etherType;
uint8_t addressType;
@@ -134,8 +130,8 @@ typedef struct {
typedef struct {
char symbolic[SYMBOLIC_NAME_LEN];
//char interfaceName[SYMBOLIC_NAME_LEN];
- union commandAddr remoteIp;
- union commandAddr localIp;
+ ip_address_t remoteIp;
+ ip_address_t localIp;
uint16_t remotePort;
uint16_t localPort;
uint8_t ipType;
@@ -180,7 +176,7 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- union commandAddr address;
+ ip_address_t address;
uint16_t cost;
uint8_t addressType;
uint8_t len;
@@ -191,7 +187,7 @@ typedef struct {
//========== [04] LIST ROUTE ==========
typedef struct {
- union commandAddr address;
+ ip_address_t address;
uint32_t connid;
uint16_t cost;
uint8_t addressType;
@@ -216,7 +212,7 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- union commandAddr address;
+ ip_address_t address;
uint8_t addressType;
uint8_t len;
} remove_route_command;
@@ -250,7 +246,7 @@ typedef enum {
} strategy_type;
typedef struct {
- union commandAddr address;
+ ip_address_t address;
uint8_t strategyType;
uint8_t addressType;
uint8_t len;
@@ -271,7 +267,7 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
- union commandAddr address;
+ ip_address_t address;
uint8_t addressType;
uint8_t len;
} add_punting_command;
@@ -281,7 +277,7 @@ typedef struct {
//========== [13] LIST LISTENER ==========
typedef struct {
- union commandAddr address;
+ ip_address_t address;
char listenerName[SYMBOLIC_NAME_LEN];
char interfaceName[SYMBOLIC_NAME_LEN];
uint32_t connid;
@@ -311,27 +307,27 @@ typedef struct {
typedef struct {
char symbolicOrConnid[SYMBOLIC_NAME_LEN];
uint8_t admin_state;
- uint16_t pad16;
+ uint8_t pad8[3];
} connection_set_admin_state_command;
#ifdef WITH_POLICY
typedef struct {
- union commandAddr address;
+ ip_address_t address;
uint8_t addressType;
uint8_t len;
policy_t policy;
} add_policy_command;
typedef struct {
- union commandAddr address;
+ ip_address_t address;
uint8_t addressType;
uint8_t len;
policy_t policy;
} list_policies_command;
typedef struct {
- union commandAddr address;
+ ip_address_t address;
uint8_t addressType;
uint8_t len;
} remove_policy_command;
@@ -358,7 +354,7 @@ static inline int payloadLengthDaemon(command_id id) {
case ADD_ROUTE:
return sizeof(add_route_command);
case LIST_ROUTES:
- return 0; // list rout`es: payload always 0
+ return 0; // list routes: payload always 0
case REMOVE_CONNECTION:
return sizeof(remove_connection_command);
case REMOVE_LISTENER:
diff --git a/hicn-light/src/hicn/utils/utils.c b/hicn-light/src/hicn/utils/utils.c
index 93a3efd81..36596f943 100644
--- a/hicn-light/src/hicn/utils/utils.c
+++ b/hicn-light/src/hicn/utils/utils.c
@@ -131,18 +131,18 @@ char *utils_BuildStringFromInet6(struct in6_addr *addr6, in_port_t *port) {
}
char *utils_CommandAddressToString(address_type addressType,
- union commandAddr *address,
+ ip_address_t *address,
in_port_t *port) {
char *result;
switch (addressType) {
case ADDR_INET: {
- result = utils_BuildStringFromInet(&address->ipv4, port);
+ result = utils_BuildStringFromInet(&address->v4.as_u32, port);
break;
}
case ADDR_INET6: {
- result = utils_BuildStringFromInet6(&address->ipv6, port);
+ result = utils_BuildStringFromInet6(&address->v6.as_in6addr, port);
break;
}
@@ -217,7 +217,7 @@ struct iovec *utils_SendRequest(ControlState *state, command_id command,
}
const char *utils_PrefixLenToString(address_type addressType,
- union commandAddr *address,
+ ip_address_t *address,
uint8_t *prefixLen) {
char len[4]; // max size + 1
sprintf(len, "%u", (unsigned)*prefixLen);
diff --git a/hicn-light/src/hicn/utils/utils.h b/hicn-light/src/hicn/utils/utils.h
index ce8cb4e17..1fe88e62c 100644
--- a/hicn-light/src/hicn/utils/utils.h
+++ b/hicn-light/src/hicn/utils/utils.h
@@ -50,7 +50,7 @@ struct iovec *utils_CreateNack(header_control_message *header, void *payload,
*to be a `in_addr_t * or `a struct in6_addr *.
*/
char *utils_CommandAddressToString(address_type addressType,
- union commandAddr *address, in_port_t *port);
+ ip_address_t *address, in_port_t *port);
/**
*Given a command payload, it generates the header and send the request to the
@@ -64,7 +64,7 @@ struct iovec *utils_SendRequest(ControlState *state, command_id command,
*form [add]:[port]/[len].
*/
const char *utils_PrefixLenToString(address_type addressType,
- union commandAddr *address,
+ ip_address_t *address,
uint8_t *prefixLen);
-#endif \ No newline at end of file
+#endif