aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/hicn/utils
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/src/hicn/utils
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/src/hicn/utils')
-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
3 files changed, 22 insertions, 26 deletions
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