aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-10-21 12:02:35 +0200
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-10-21 16:02:15 +0200
commit2e6f86232a6735f563ba502f963b4dda80e06d4e (patch)
tree98a96f949c8fa615d7ce8ef62eab14d930bea02f
parent7204bac00804448a797d4e76ced04a3b84d0d741 (diff)
[HICN-320] HICN Light only configuring the first entry on FIB
Change-Id: Ica111f54b23a9a56433e9b195a3fccd913952ad0 Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
-rw-r--r--hicn-light/src/hicn/config/controlListConnections.c1
-rw-r--r--hicn-light/src/hicn/io/hicnListener.c4
-rw-r--r--hicn-light/src/hicn/socket/ops_linux.c25
-rw-r--r--lib/src/util/ip_address.c11
4 files changed, 20 insertions, 21 deletions
diff --git a/hicn-light/src/hicn/config/controlListConnections.c b/hicn-light/src/hicn/config/controlListConnections.c
index c8a4c1b4b..0e8e2c30b 100644
--- a/hicn-light/src/hicn/config/controlListConnections.c
+++ b/hicn-light/src/hicn/config/controlListConnections.c
@@ -121,7 +121,6 @@ static CommandReturn _controlListConnections_Execute(CommandParser *parser,
// Process/Print payload
- printf("%5s %10s %6s %40s %40s %5s\n", "id", "name", "state", "source", "destination", "type");
for (int i = 0; i < receivedHeader->length; i++) {
list_connections_command *listConnectionsCommand =
(list_connections_command *)(receivedPayload +
diff --git a/hicn-light/src/hicn/io/hicnListener.c b/hicn-light/src/hicn/io/hicnListener.c
index 8409db027..a60c4dd12 100644
--- a/hicn-light/src/hicn/io/hicnListener.c
+++ b/hicn-light/src/hicn/io/hicnListener.c
@@ -415,7 +415,7 @@ bool _hicnListener_BindInet6(ListenerOps *ops, const Address *remoteAddress) {
if (logger_IsLoggable(hicn->logger, LoggerFacility_IO,
PARCLogLevel_Debug)) {
logger_Log(hicn->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
- "hicn_bild failed %d %s", res, hicn_socket_strerror(res));
+ "hicn_bind failed %d %s", res, hicn_socket_strerror(res));
}
} else {
result = true;
@@ -447,7 +447,7 @@ bool _hicnListener_BindInet(ListenerOps *ops, const Address *remoteAddress) {
if (logger_IsLoggable(hicn->logger, LoggerFacility_IO,
PARCLogLevel_Debug)) {
logger_Log(hicn->logger, LoggerFacility_IO, PARCLogLevel_Debug, __func__,
- "hicn_bild failed %d %s", res, hicn_socket_strerror(res));
+ "hicn_bind failed %d %s", res, hicn_socket_strerror(res));
}
} else {
result = true;
diff --git a/hicn-light/src/hicn/socket/ops_linux.c b/hicn-light/src/hicn/socket/ops_linux.c
index f81ceff37..af41f400f 100644
--- a/hicn-light/src/hicn/socket/ops_linux.c
+++ b/hicn-light/src/hicn/socket/ops_linux.c
@@ -574,21 +574,17 @@ 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)) {
- printf("got ip address\n");
memcpy(prefix->address.buffer, RTA_DATA(payload + 1), IPV6_ADDR_LEN);
prefix->family = AF_INET6;
prefix->len = IPV6_ADDR_LEN_BITS;
- printf("returning %d\n", HICN_SOCKET_ERROR_NONE);
return HICN_SOCKET_ERROR_NONE;
}
} else if (address_family == AF_INET) {
if ((payload->ifa_index == interface_id) &&
(payload->ifa_prefixlen < IPV4_ADDR_LEN * 8)) {
- printf("got ip address\n");
memcpy(prefix->address.buffer, RTA_DATA(payload + 1), IPV4_ADDR_LEN);
prefix->family = AF_INET;
prefix->len = IPV4_ADDR_LEN_BITS;
- printf("returning %d\n", HICN_SOCKET_ERROR_NONE);
return HICN_SOCKET_ERROR_NONE;
}
} else {
@@ -600,7 +596,6 @@ ERR_NL:
ERR_RECV:
ERR_SEND:
ERR_SOCKET:
- printf("error getting ip address\n");
return HICN_SOCKET_ERROR_UNSPEC;
}
@@ -624,7 +619,7 @@ int _nl_set_ip_addr(uint32_t interface_id, ip_prefix_t *prefix) {
.payload.ifa_index = interface_id};
/* Set attributes = length/type/value */
- struct rtattr ifa_address = {RTA_LENGTH(ip_prefix_len(prefix)),
+ struct rtattr ifa_address = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)),
IFA_ADDRESS};
struct iovec iov[] = {
{&msg, sizeof(msg)},
@@ -992,13 +987,13 @@ int _nl_del_lo_route(const ip_prefix_t *prefix) {
/* Set attribute = length/type/value */
uint32_t one = 1;
- struct rtattr a_dst = {RTA_LENGTH(ip_prefix_len(prefix)), RTA_DST};
+ struct rtattr a_dst = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)), RTA_DST};
struct rtattr a_ifid_lo = {RTA_LENGTH(sizeof(uint32_t)), RTA_OIF};
struct iovec iov[] = {
{&msg, sizeof(msg)},
/* Ip address */
{&a_dst, sizeof(a_dst)},
- {(void *)&prefix->address.buffer, ip_prefix_len(prefix)},
+ {(void *)&prefix->address.buffer, ip_address_len(&prefix->address, prefix->family)},
/* Interface id */
{&a_ifid_lo, sizeof(a_ifid_lo)},
{&one, sizeof(one)}};
@@ -1154,7 +1149,7 @@ int _nl_add_neigh_proxy(const ip_prefix_t *prefix,
};
/* Message attributes = length/type/value */
- struct rtattr a_dst = {RTA_LENGTH(ip_prefix_len(prefix)), NDA_DST};
+ struct rtattr a_dst = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)), NDA_DST};
/* Iovec describing the packets */
struct iovec iov[] = {
@@ -1231,7 +1226,7 @@ int _nl_add_in_route_table(const ip_prefix_t *prefix,
};
/* Message attributes = length/type/value */
- struct rtattr a_dst = {RTA_LENGTH(ip_prefix_len(prefix)), RTA_DST};
+ struct rtattr a_dst = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)), RTA_DST};
struct rtattr a_oif = {RTA_LENGTH(sizeof(uint32_t)), RTA_OIF};
/* Iovec describing the packets */
@@ -1239,7 +1234,7 @@ int _nl_add_in_route_table(const ip_prefix_t *prefix,
{&msg, sizeof(msg)},
/* Destination prefix / ip address */
{&a_dst, sizeof(a_dst)},
- {(void *)&prefix->address.buffer, ip_prefix_len(prefix)},
+ {(void *)&prefix->address.buffer, ip_address_len(&prefix->address, prefix->family)},
/* Output interface */
{&a_oif, sizeof(a_oif)},
{(void *)&interface_id, sizeof(uint32_t)},
@@ -1333,7 +1328,7 @@ int _nl_add_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
if (prefix) {
/* Message attributes = length/type/value */
- struct rtattr a_src = {RTA_LENGTH(ip_prefix_len(prefix)), FRA_SRC};
+ struct rtattr a_src = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)), FRA_SRC};
struct rtattr a_prio = {RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY};
/* Iovec describing the packets */
@@ -1341,7 +1336,7 @@ int _nl_add_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
{&msg, sizeof(msg)},
/* Source prefix / prefix */
{&a_src, sizeof(a_src)},
- {(void *)&prefix->address.buffer, ip_prefix_len(prefix)},
+ {(void *)&prefix->address.buffer, ip_address_len(&prefix->address, prefix->family)},
/* Priority */
{&a_prio, sizeof(a_prio)},
{(void *)&priority, sizeof(uint32_t)},
@@ -1434,7 +1429,7 @@ int _nl_del_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
/* Message attributes = length/type/value */
if (prefix) {
- struct rtattr a_src = {RTA_LENGTH(ip_prefix_len(prefix)), FRA_SRC};
+ struct rtattr a_src = {RTA_LENGTH(ip_address_len(&prefix->address, prefix->family)), FRA_SRC};
struct rtattr a_prio = {RTA_LENGTH(sizeof(uint32_t)), FRA_PRIORITY};
/* Iovec describing the packets */
@@ -1442,7 +1437,7 @@ int _nl_del_prio_rule(const ip_prefix_t *prefix, uint8_t address_family,
{&msg, sizeof(msg)},
/* Source prefix / prefix */
{&a_src, sizeof(a_src)},
- {(void *)&prefix->address.buffer, ip_prefix_len(prefix)},
+ {(void *)&prefix->address.buffer, ip_address_len(&prefix->address, prefix->family)},
/* Priority */
{&a_prio, sizeof(a_prio)},
{(void *)&priority, sizeof(uint32_t)},
diff --git a/lib/src/util/ip_address.c b/lib/src/util/ip_address.c
index 2cf2aaef3..7afd3e2a4 100644
--- a/lib/src/util/ip_address.c
+++ b/lib/src/util/ip_address.c
@@ -190,9 +190,9 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
char *addr = strdup (ip_address_str);
p = strchr (addr, '/');
- if (!p)
- ip_prefix->len = 0; // until we get the ip address family
- else {
+ if (!p) {
+ ip_prefix->len = ~0; // until we get the ip address family
+ } else {
ip_prefix->len = strtoul (p + 1, &eptr, 10);
*p = 0;
}
@@ -202,11 +202,15 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
switch (ip_prefix->family)
{
case AF_INET6:
+ if (ip_prefix->len == (u8)~0)
+ ip_prefix->len = IPV6_ADDR_LEN_BITS;
if (ip_prefix->len > IPV6_ADDR_LEN_BITS)
goto ERR;
pton_fd = inet_pton (AF_INET6, addr, &ip_prefix->address.buffer);
break;
case AF_INET:
+ if (ip_prefix->len == (u8)~0)
+ ip_prefix->len = IPV4_ADDR_LEN_BITS;
if (ip_prefix->len > IPV4_ADDR_LEN_BITS)
goto ERR;
pton_fd = inet_pton (AF_INET, addr, &ip_prefix->address.buffer);
@@ -220,6 +224,7 @@ ip_prefix_pton (const char *ip_address_str, ip_prefix_t * ip_prefix)
if (pton_fd <= 0)
goto ERR;
+ free(addr);
return 1;
ERR:
free (addr);