Rewrite sctp_create_new_listener() to handle DNS, IPv6
Rewrite sctp_create_new_listener() to use getaddrinfo() to look up IPv4/IPv6 addresses via a common interface. This allows to use e.g. DNS, and enables the SCTP library to listen on IPv6 ports. To support the above, the corresponding message is changed to not take an IPv4 address on 4 bytes (and separate IPv6), but a single name that will be resolved via getaddrinfo() The previous init message used to allow multiple IPv4/IPv6 addresses; since this is not used anywhere, remove the corresponding functionality. Modify all uses of this ITTI message to copy te SCTP init bind addr into ITTI message.
This commit is contained in:
@@ -217,29 +217,16 @@ int x2ap_eNB_init_sctp (x2ap_eNB_instance_t *instance_p,
|
||||
net_ip_address_t *local_ip_addr,
|
||||
uint32_t enb_port_for_X2C) {
|
||||
// Create and alloc new message
|
||||
MessageDef *message;
|
||||
sctp_init_t *sctp_init = NULL;
|
||||
DevAssert(instance_p != NULL);
|
||||
DevAssert(local_ip_addr != NULL);
|
||||
message = itti_alloc_new_message (TASK_X2AP, 0, SCTP_INIT_MSG_MULTI_REQ);
|
||||
sctp_init = &message->ittiMsg.sctp_init_multi;
|
||||
size_t addr_len = strlen(local_ip_addr->ipv4_address) + 1;
|
||||
MessageDef *message = itti_alloc_new_message_sized(TASK_X2AP, 0, SCTP_INIT_MSG_MULTI_REQ, sizeof(sctp_init_t) + addr_len);
|
||||
sctp_init_t *sctp_init = &message->ittiMsg.sctp_init_multi;
|
||||
sctp_init->port = enb_port_for_X2C;
|
||||
sctp_init->ppid = X2AP_SCTP_PPID;
|
||||
sctp_init->ipv4 = 1;
|
||||
sctp_init->ipv6 = 0;
|
||||
sctp_init->nb_ipv4_addr = 1;
|
||||
#if 0
|
||||
memcpy(&sctp_init->ipv4_address,
|
||||
local_ip_addr,
|
||||
sizeof(*local_ip_addr));
|
||||
#endif
|
||||
sctp_init->ipv4_address[0] = inet_addr(local_ip_addr->ipv4_address);
|
||||
/*
|
||||
* SR WARNING: ipv6 multi-homing fails sometimes for localhost.
|
||||
* * * * Disable it for now.
|
||||
*/
|
||||
sctp_init->nb_ipv6_addr = 0;
|
||||
sctp_init->ipv6_address[0] = "0:0:0:0:0:0:0:1";
|
||||
char *addr_buf = (char *) (sctp_init + 1);
|
||||
sctp_init->bind_address = addr_buf;
|
||||
memcpy(addr_buf, local_ip_addr->ipv4_address, addr_len);
|
||||
return itti_send_msg_to_task (TASK_SCTP, instance_p->instance, message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user