aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2021-03-23 14:58:34 +0100
committerMauro Sardara <msardara@cisco.com>2021-03-30 15:23:55 +0000
commita5a6ffb506aa3c2a0c7fe8fd09abf3f737984aa5 (patch)
treecfb82e9667e287b08c665d4d671b6e767490d403 /lib
parenta070b0de9f9e9cbca150eea4eda74757ca588bed (diff)
[HICN-645] Fix data structures to support hicn-light-daemon and hicn-light-control communication
The daemon should be able to start, receive commands from hicn-light-control and execute them. Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I0ca5bb3d9bdfb37ac8cfa9f671f6c162c9a394f5 Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/hicn/face.h9
-rw-r--r--lib/includes/hicn/util/ip_address.h11
-rw-r--r--lib/src/face.c21
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/includes/hicn/face.h b/lib/includes/hicn/face.h
index 45a1b97da..0d116b64b 100644
--- a/lib/includes/hicn/face.h
+++ b/lib/includes/hicn/face.h
@@ -138,6 +138,13 @@ foreach_face_type
#undef _
} face_type_t;
+typedef enum {
+ FACE_PROTOCOL_HICN,
+ FACE_PROTOCOL_UDP,
+ FACE_PROTOCOL_TCP,
+ FACE_PROTOCOL_UNKNOWN,
+} face_protocol_t;
+
#define face_type_is_valid(face_type) \
(((face_type) >= FACE_TYPE_UNDEFINED) && (face_type < FACE_TYPE_N))
#define face_type_is_defined(face_type) \
@@ -209,5 +216,7 @@ face_snprintf(char * s, size_t size, const face_t * face);
policy_tags_t face_get_tags(const face_t * face);
int face_set_tags(face_t * face, policy_tags_t tags);
+face_protocol_t get_protocol(face_type_t face_type);
+
#endif /* HICN_FACE_H */
diff --git a/lib/includes/hicn/util/ip_address.h b/lib/includes/hicn/util/ip_address.h
index 27880047c..a43f16754 100644
--- a/lib/includes/hicn/util/ip_address.h
+++ b/lib/includes/hicn/util/ip_address.h
@@ -135,6 +135,17 @@ const u8 * ip_address_get_buffer(const ip_address_t * ip_address, int family);
int ip_address_ntop (const ip_address_t * ip_address, char *dst,
const size_t len, int family);
int ip_address_pton (const char *ip_address_str, ip_address_t * ip_address);
+
+/**
+ * @brief Return the ip_address provided as parameter in string format.
+ * E.g. (for ipv4): "0.0.0.0"
+ *
+ * @param[in, out] s String to store the parsed address
+ * @param[in] size Size of the string @p s
+ * @param[in] ip_address Address to parse to string
+ * @param[in] family Address family (e.g. AF_INET, AF_INET6)
+ * @return int Length of the string generated parsing the addr
+ */
int ip_address_snprintf(char * s, size_t size, const ip_address_t * ip_address,
int family);
int ip_address_to_sockaddr(const ip_address_t * ip_address, struct sockaddr *sa,
diff --git a/lib/src/face.c b/lib/src/face.c
index 6d0d9c486..7b3bbe3c3 100644
--- a/lib/src/face.c
+++ b/lib/src/face.c
@@ -420,3 +420,24 @@ face_set_tags(face_t * face, policy_tags_t tags)
face->tags = tags;
return 1;
}
+
+face_protocol_t
+get_protocol(face_type_t face_type) {
+ switch (face_type) {
+ case FACE_TYPE_HICN:
+ case FACE_TYPE_HICN_LISTENER:
+ return FACE_PROTOCOL_HICN;
+
+ case FACE_TYPE_TCP:
+ case FACE_TYPE_TCP_LISTENER:
+ return FACE_PROTOCOL_TCP;
+
+ case FACE_TYPE_UDP:
+ case FACE_TYPE_UDP_LISTENER:
+ return FACE_PROTOCOL_UDP;
+ break;
+
+ default:
+ return FACE_PROTOCOL_UNKNOWN;
+ }
+}