aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-light/src/utils/address.c
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-03-06 10:48:06 +0100
committerMauro Sardara <msardara@cisco.com>2019-03-06 12:11:22 +0000
commit0e98ba7a3100268e656fe5e3a21783a5ab6daa53 (patch)
tree2492478ca915291c8f0816426bbddc7d319393c0 /hicn-light/src/utils/address.c
parent9d0002e5cb97d939f2f74ab1e635b616d634e7db (diff)
[HICN-92] Fix byte order mismatch in create listener command
Change-Id: I750b9840543cf53e0d96bd71a0765bd6345013cb Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'hicn-light/src/utils/address.c')
-rw-r--r--hicn-light/src/utils/address.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/hicn-light/src/utils/address.c b/hicn-light/src/utils/address.c
index ee1167de0..a59c6a59d 100644
--- a/hicn-light/src/utils/address.c
+++ b/hicn-light/src/utils/address.c
@@ -119,6 +119,36 @@ Address *addressCreateFromInet6(struct sockaddr_in6 *addr_in6) {
return result;
}
+Address *addressFromInaddr4Port(in_addr_t *addr4, in_port_t *port) {
+ struct sockaddr_in addr;
+ memset(&addr, 0, sizeof(addr));
+
+ // We assume address and port are already written in memory in network byte
+ // order
+ addr.sin_family = AF_INET;
+ addr.sin_port = *port;
+ addr.sin_addr.s_addr = *addr4;
+
+ Address *result = addressCreateFromInet(&addr);
+ return result;
+}
+
+Address *addressFromInaddr6Port(struct in6_addr *addr6, in_port_t *port) {
+ struct sockaddr_in6 addr;
+ memset(&addr, 0, sizeof(addr));
+ addr.sin6_family = AF_INET6;
+
+ // We assume address and port are already written in memory in network byte
+ // order
+ addr.sin6_port = *port;
+ addr.sin6_addr = *addr6;
+ addr.sin6_scope_id = 0;
+ // Other 2 fields: scope_id and flowinfo, do not know what to put inside.
+
+ Address *result = addressCreateFromInet6(&addr);
+ return result;
+}
+
Address *addressCreateFromLink(const uint8_t *linkaddr, size_t length) {
parcAssertNotNull(linkaddr, "Parameter must be non-null");