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:
@@ -96,25 +96,20 @@ static void cu_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *s
|
||||
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
|
||||
}
|
||||
|
||||
static void cu_task_send_sctp_init_req(instance_t instance, char *my_addr) {
|
||||
static void cu_task_send_sctp_init_req(instance_t instance, char *my_addr)
|
||||
{
|
||||
// 1. get the itti msg, and retrive the nb_id from the message
|
||||
// 2. use RC.rrc[nb_id] to fill the sctp_init_t with the ip, port
|
||||
// 3. creat an itti message to init
|
||||
LOG_I(F1AP, "F1AP_CU_SCTP_REQ(create socket)\n");
|
||||
MessageDef *message_p = NULL;
|
||||
message_p = itti_alloc_new_message (TASK_CU_F1, 0, SCTP_INIT_MSG);
|
||||
message_p->ittiMsg.sctp_init.port = F1AP_PORT_NUMBER;
|
||||
message_p->ittiMsg.sctp_init.ppid = F1AP_SCTP_PPID;
|
||||
message_p->ittiMsg.sctp_init.ipv4 = 1;
|
||||
message_p->ittiMsg.sctp_init.ipv6 = 0;
|
||||
message_p->ittiMsg.sctp_init.nb_ipv4_addr = 1;
|
||||
message_p->ittiMsg.sctp_init.ipv4_address[0] = inet_addr(my_addr);
|
||||
/*
|
||||
* SR WARNING: ipv6 multi-homing fails sometimes for localhost.
|
||||
* * * * Disable it for now.
|
||||
*/
|
||||
message_p->ittiMsg.sctp_init.nb_ipv6_addr = 0;
|
||||
message_p->ittiMsg.sctp_init.ipv6_address[0] = "0:0:0:0:0:0:0:1";
|
||||
size_t addr_len = strlen(my_addr) + 1;
|
||||
LOG_I(F1AP, "F1AP_CU_SCTP_REQ(create socket) for %s len %ld\n", my_addr, addr_len);
|
||||
MessageDef *message_p = itti_alloc_new_message_sized(TASK_CU_F1, 0, SCTP_INIT_MSG, sizeof(sctp_init_t) + addr_len);
|
||||
sctp_init_t *init = &SCTP_INIT_MSG(message_p);
|
||||
init->port = F1AP_PORT_NUMBER;
|
||||
init->ppid = F1AP_SCTP_PPID;
|
||||
char *addr_buf = (char *) (init + 1); // address after ITTI message end, allocated above
|
||||
init->bind_address = addr_buf;
|
||||
memcpy(addr_buf, my_addr, addr_len);
|
||||
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user