diff options
Diffstat (limited to 'hicn-light/src/hicn/socket/api.c')
-rw-r--r-- | hicn-light/src/hicn/socket/api.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/hicn-light/src/hicn/socket/api.c b/hicn-light/src/hicn/socket/api.c index 213163675..a3d5a3cfe 100644 --- a/hicn-light/src/hicn/socket/api.c +++ b/hicn-light/src/hicn/socket/api.c @@ -39,7 +39,7 @@ static hicn_conf_t hicn_default_conf = { struct ip_rule_state_ { char tun_name[IF_NAMESIZE]; - ip_address_t ip_address; + ip_prefix_t prefix; uint32_t table_id; uint8_t priority; uint8_t address_family; @@ -160,7 +160,7 @@ void hicn_destroy() { } } else { rc = ops.del_prio_rule( - &rules_to_remove[i].ip_address, rules_to_remove[i].address_family, + &rules_to_remove[i].prefix, rules_to_remove[i].address_family, rules_to_remove[i].priority, rules_to_remove[i].table_id); if (rc < 0) { goto ERR; @@ -204,7 +204,7 @@ int hicn_socket_cmp(hicn_socket_t *a, hicn_socket_t *b) { return b->fd - a->fd; } -ip_address_t *hicn_socket_get_src_ip(hicn_socket_t *socket) { +ip_prefix_t *hicn_socket_get_src_ip(hicn_socket_t *socket) { if (socket->type != HS_CONNECTION) { return NULL; } @@ -252,7 +252,7 @@ int hicn_set_local_endpoint(hicn_socket_t *socket, const char *local_ip_address, */ /* Copy the local IP address inside the connection */ - rc = hicn_ip_pton(local_ip_address, &socket->connection.tun_ip_address); + rc = ip_prefix_pton(local_ip_address, &socket->connection.tun_ip_address); if (rc < 0) { rc = HICN_SOCKET_ERROR_SOCKET_LOCAL_REPR; goto end; @@ -262,13 +262,13 @@ end: return rc; } -int hicn_get_local_address(const ip_address_t *remote_address, - ip_address_t *local_address) { +int hicn_get_local_address(const ip_prefix_t *remote_address, + ip_prefix_t *local_address) { int rc = 0; uint32_t interface_id; - char remote_address_str[INET_MAX_ADDRSTRLEN]; + char remote_address_str[INET_MAX_ADDRSTRLEN + 4 ]; - rc = hicn_ip_ntop(remote_address, remote_address_str, + rc = ip_prefix_ntop_short(remote_address, remote_address_str, sizeof(remote_address_str)); if (rc < 0) { rc = HICN_SOCKET_ERROR_BIND_REMOTE_REPR; @@ -300,7 +300,7 @@ ERR: int hicn_set_remote_endpoint(hicn_socket_t *socket, const char *remote_ip_address) { int af, rc = HICN_SOCKET_ERROR_NONE; - ip_address_t addr; + ip_prefix_t addr; af = get_addr_family(remote_ip_address); if ((af != AF_INET6) && (af != AF_INET)) { @@ -308,8 +308,8 @@ int hicn_set_remote_endpoint(hicn_socket_t *socket, } /* Bind local endpoint if not done yet */ - if (ip_address_empty(&socket->connection.tun_ip_address)) { - char local_ip_address[INET_MAX_ADDRSTRLEN]; + if (ip_prefix_empty(&socket->connection.tun_ip_address)) { + char local_ip_address[INET_MAX_ADDRSTRLEN + 4]; /* Local interface id */ // INFO("Getting interface_id from gateway IP address %s", @@ -338,7 +338,7 @@ int hicn_set_remote_endpoint(hicn_socket_t *socket, ///// /* Convert to representation format */ - rc = hicn_ip_ntop(&addr, local_ip_address, sizeof(local_ip_address)); + rc = ip_prefix_ntop_short(&addr, local_ip_address, sizeof(local_ip_address)); if (rc < 0) { rc = HICN_SOCKET_ERROR_BIND_REMOTE_REPR; goto ERR; @@ -455,8 +455,8 @@ int hicn_listen(hicn_socket_helper_t *hicn, int fd, const char *prefix) { return rc; } - ip_address_t ip_address; - rc = hicn_ip_pton(prefix, &ip_address); + ip_prefix_t ip_prefix; + rc = ip_prefix_pton(prefix, &ip_prefix); if (rc < 0) { return rc; } @@ -467,7 +467,7 @@ int hicn_listen(hicn_socket_helper_t *hicn, int fd, const char *prefix) { if (punting_table_id == -1) punting_table_id = socket->connection.table_id; - rc = ops.add_prio_rule(&ip_address, ip_address.family, 0, + rc = ops.add_prio_rule(&ip_prefix, ip_prefix.family, 0, socket->connection.table_id); if (rc < 0) { return rc; @@ -475,8 +475,8 @@ int hicn_listen(hicn_socket_helper_t *hicn, int fd, const char *prefix) { strcpy(rules_to_remove[rules_counter].tun_name, "NONE"); - rules_to_remove[rules_counter].ip_address = ip_address; - rules_to_remove[rules_counter].address_family = ip_address.family; + rules_to_remove[rules_counter].prefix = ip_prefix; + rules_to_remove[rules_counter].address_family = ip_prefix.family; rules_to_remove[rules_counter].table_id = socket->connection.table_id; rules_to_remove[rules_counter].priority = 0; ++rules_counter; |