From df3f764760d3db8fa5ed6d6423d63697c95eccca Mon Sep 17 00:00:00 2001 From: Lionel Gauthier <lionel.gauthier@eurecom.fr> Date: Thu, 30 Oct 2014 15:50:10 +0000 Subject: [PATCH] It works git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5946 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair-cn/GTPV1-U/gtpv1u_task.c | 7 +- openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c | 24 ++--- openair-cn/OPENAIRHSS/conf/hss_fd.conf | 8 +- openair-cn/OPENAIRHSS/conf/make_certs.sh | 9 +- openair-cn/S1AP/s1ap_mme_handlers.c | 2 +- openair-cn/S6A/freediameter/make_certs.sh | 4 +- openair-cn/S6A/s6a_peer.c | 7 ++ openair-cn/S6A/s6a_task.c | 2 +- openair-cn/SGI/sgi.h | 1 + openair-cn/SGI/sgi_socket.c | 48 ++++++++- openair-cn/SGI/sgi_task.c | 114 ++++++++++++-------- openair-cn/UTILS/CONF/s6a.conf.in | 8 +- openair-cn/UTILS/mme_config.c | 7 +- 13 files changed, 159 insertions(+), 82 deletions(-) diff --git a/openair-cn/GTPV1-U/gtpv1u_task.c b/openair-cn/GTPV1-U/gtpv1u_task.c index 539e2d4770..e4b8fba0ec 100644 --- a/openair-cn/GTPV1-U/gtpv1u_task.c +++ b/openair-cn/GTPV1-U/gtpv1u_task.c @@ -151,9 +151,9 @@ NwGtpv1uRcT gtpv1u_process_stack_req( */ if (NW_GTPV1U_OK != nwGtpv1uMsgGetTpdu(pUlpApi->apiInfo.recvMsgInfo.hMsg, buffer, (NwU32T *)&buffer_len)) { - GTPU_ERROR("Error while retrieving T-PDU"); + GTPU_ERROR("Error while retrieving T-PDU\n"); } - GTPU_DEBUG("Received TPDU from gtpv1u stack %u with size %d", pUlpApi->apiInfo.recvMsgInfo.teid, buffer_len); + GTPU_DEBUG("Received TPDU from gtpv1u stack %u with size %d\n", pUlpApi->apiInfo.recvMsgInfo.teid, buffer_len); message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_TUNNEL_DATA_IND); if (message_p == NULL) { @@ -419,7 +419,8 @@ static void *gtpv1u_thread(void *args) GTPU_ERROR("nwGtpv1uProcessUlpReq failed: while getting teid %u in hashtable S1U_mapping\n", data_req_p->local_S1u_teid); } else { stack_req.apiType = NW_GTPV1U_ULP_API_SEND_TPDU; - stack_req.apiInfo.sendtoInfo.teid = data_req_p->local_S1u_teid; + //stack_req.apiInfo.sendtoInfo.teid = data_req_p->local_S1u_teid; + stack_req.apiInfo.sendtoInfo.teid = gtpv1u_teid2enb_info->teid_enb; BUFFER_TO_NwU32T(gtpv1u_teid2enb_info->enb_ip_addr.address.ipv4_address, stack_req.apiInfo.sendtoInfo.ipAddr); /*nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, diff --git a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c index 91d9fdc320..e97d56224c 100644 --- a/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c +++ b/openair-cn/GTPV1-U/nw-gtpv1u/src/NwGtpv1u.c @@ -506,12 +506,12 @@ nwGtpv1uProcessGpdu( NwGtpv1uStackT *thiz, if(NW_GTPV1U_OK == rc) { NwGtpv1uMsgT *pMsg = (NwGtpv1uMsgT *) hMsg; - GTPU_DEBUG("Received T-PDU over tunnel end-point '%x' of size %u from "NW_IPV4_ADDR, + GTPU_DEBUG("Received T-PDU over tunnel end-point '%x' of size %u from "NW_IPV4_ADDR"\n", ntohl(msgHdr->teid), pMsg->msgLen, NW_IPV4_ADDR_FORMAT((peerIp))); rc = nwGtpSessionSendMsgApiToUlpEntity(pTunnelEndPoint, pMsg); } } else { - GTPU_ERROR("Received T-PDU over non-existent tunnel end-point '%x' from "NW_IPV4_ADDR, + GTPU_ERROR("Received T-PDU over non-existent tunnel end-point '%x' from "NW_IPV4_ADDR"\n", ntohl(msgHdr->teid), NW_IPV4_ADDR_FORMAT((peerIp))); } NW_LEAVE(thiz); @@ -561,7 +561,7 @@ nwGtpv1uHandleEchoReq(NW_IN NwGtpv1uStackT *thiz, */ rc = nwGtpv1uMsgAddIeTV1(hMsg, NW_GTPV1U_IE_RECOVERY, 0x00); - GTPU_INFO("Sending NW_GTP_ECHO_RSP message to %x:%x with seq %u", + GTPU_INFO("Sending NW_GTP_ECHO_RSP message to %x:%x with seq %u\n", peerIp, peerPort, seqNum); @@ -758,12 +758,12 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, switch(msgType) { case NW_GTP_ECHO_REQ: - GTPU_DEBUG("NW_GTP_ECHO_REQ"); + GTPU_DEBUG("NW_GTP_ECHO_REQ\n"); ret = nwGtpv1uHandleEchoReq( thiz, udpData, udpDataLen, peerPort, peerIp); break; case NW_GTP_ERROR_INDICATION: - GTPU_DEBUG("NW_GTP_ERROR_INDICATION"); + GTPU_DEBUG("NW_GTP_ERROR_INDICATION\n"); ret = nwGtpv1uSendUlpMessageIndication( thiz, 0, NW_GTPV1U_ULP_API_RECV_MSG, @@ -777,7 +777,7 @@ nwGtpv1uProcessUdpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, break; case NW_GTP_ECHO_RSP: - GTPU_DEBUG("NW_GTP_ECHO_RSP"); + GTPU_DEBUG("NW_GTP_ECHO_RSP\n"); ret = NW_GTPV1U_OK; break; @@ -815,7 +815,7 @@ nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, switch(pUlpReq->apiType) { case NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT: { - GTPU_DEBUG("Received NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT from ulp"); + GTPU_DEBUG("Received NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT from ulp\n"); rc = NwGtpv1uCreateTunnelEndPoint(thiz, pUlpReq->apiInfo.createTunnelEndPointInfo.teid, pUlpReq->apiInfo.createTunnelEndPointInfo.hUlpSession, @@ -824,25 +824,25 @@ nwGtpv1uProcessUlpReq( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle, break; case NW_GTPV1U_ULP_API_DESTROY_TUNNEL_ENDPOINT: { - GTPU_DEBUG("Received destroy session req from ulp"); + GTPU_DEBUG("Received destroy session req from ulp\n"); rc = nwGtpv1uDestroyTunnelEndPoint(thiz, pUlpReq); } break; case NW_GTPV1U_ULP_API_INITIAL_REQ: { - GTPU_DEBUG("Received initial req from ulp"); + GTPU_DEBUG("Received initial req from ulp\n"); rc = nwGtpv1uInitialReq(thiz, pUlpReq); } break; case NW_GTPV1U_ULP_API_SEND_TPDU: { - GTPU_DEBUG("Received send tpdu req from ulp"); + GTPU_DEBUG("Received send tpdu req from ulp\n"); rc = nwGtpv1uSendto(thiz, pUlpReq); } break; default: - GTPU_DEBUG("Unsupported API received from ulp"); + GTPU_DEBUG("Unsupported API received from ulp\n"); rc = NW_GTPV1U_FAILURE; break; } @@ -869,7 +869,7 @@ nwGtpv1uProcessTimeout(void *timeoutInfo) NW_ASSERT(thiz != NULL); NW_ENTER(thiz); - GTPU_DEBUG("Received timeout event from ULP with timeoutInfo %x!", + GTPU_DEBUG("Received timeout event from ULP with timeoutInfo %x!\n", (unsigned int)timeoutInfo); rc = (((NwGtpv1uTimeoutInfoT *) timeoutInfo)->timeoutCallbackFunc) (timeoutInfo); diff --git a/openair-cn/OPENAIRHSS/conf/hss_fd.conf b/openair-cn/OPENAIRHSS/conf/hss_fd.conf index c2e5836c6d..6e70e62d31 100644 --- a/openair-cn/OPENAIRHSS/conf/hss_fd.conf +++ b/openair-cn/OPENAIRHSS/conf/hss_fd.conf @@ -1,15 +1,15 @@ # -------- Local --------- # Uncomment if the framework cannot resolv it. -Identity = "hss.eur"; +Identity = "hss.pft"; #ListenOn = "192.168.13.177"; # TLS configuration (see previous section) -TLS_Cred = "/mnt/sshfs/trunk/openair-cn/OPENAIRHSS/conf/hss.cert.pem", -"/mnt/sshfs/trunk/openair-cn/OPENAIRHSS/conf/hss.key.pem"; -TLS_CA = "/mnt/sshfs/trunk/openair-cn/OPENAIRHSS/conf/cacert.pem"; +TLS_Cred = "//usr/local/src/openair4G/trunk/openair-cn/OPENAIRHSS/conf/hss.cert.pem", +"//usr/local/src/openair4G/trunk/openair-cn/OPENAIRHSS/conf/hss.key.pem"; +TLS_CA = "/usr/local/src/openair4G/trunk/openair-cn/OPENAIRHSS/conf/cacert.pem"; # Disable use of TCP protocol (only listen and connect in SCTP) # Default : TCP enabled diff --git a/openair-cn/OPENAIRHSS/conf/make_certs.sh b/openair-cn/OPENAIRHSS/conf/make_certs.sh index 04ef7a430d..06d317cfe9 100755 --- a/openair-cn/OPENAIRHSS/conf/make_certs.sh +++ b/openair-cn/OPENAIRHSS/conf/make_certs.sh @@ -40,11 +40,16 @@ echo "Creating certificate for HSS" # openssl req -new -batch -out hss.csr.pem -key hss.key.pem -subj /CN=hss.test.fr/C=FR/ST=Biot/L=Aix/O=test.fr/OU=mobiles # openssl ca -cert cacert.pem -keyfile cakey.pem -in hss.csr.pem -out hss.cert.pem -outdir . -batch -# CA self certificate +# Create a Root Certification Authority Certificate openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM +# Generate a Private Key openssl genrsa -out hss.key.pem 1024 -openssl req -new -batch -out hss.csr.pem -key hss.key.pem -subj /CN=hss.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM + +# Generate a CSR (Certificate Signing Request) that will be self-signed +openssl req -new -batch -out hss.csr.pem -key hss.key.pem -subj /CN=hss.pft/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM + +# Certification authority openssl ca -cert cacert.pem -keyfile cakey.pem -in hss.csr.pem -out hss.cert.pem -outdir . -batch # openssl genrsa -out $hss.key.pem 1024 diff --git a/openair-cn/S1AP/s1ap_mme_handlers.c b/openair-cn/S1AP/s1ap_mme_handlers.c index 1edce1fdc3..1f3e769e6f 100644 --- a/openair-cn/S1AP/s1ap_mme_handlers.c +++ b/openair-cn/S1AP/s1ap_mme_handlers.c @@ -536,7 +536,7 @@ int s1ap_mme_handle_initial_context_setup_response( MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.ipv4 = 1; // TO DO MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.ipv6 = 0; // TO DO MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.interface_type = S1_U_ENODEB_GTP_U; - MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.teid = *((uint32_t *)eRABSetupItemCtxtSURes_p->gTP_TEID.buf); + MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.teid = htonl(*((uint32_t *)eRABSetupItemCtxtSURes_p->gTP_TEID.buf)); memcpy(&MME_APP_INITIAL_CONTEXT_SETUP_RSP(message_p).bearer_s1u_enb_fteid.ipv4_address, eRABSetupItemCtxtSURes_p->transportLayerAddress.buf, 4); diff --git a/openair-cn/S6A/freediameter/make_certs.sh b/openair-cn/S6A/freediameter/make_certs.sh index 97cc258b22..feb1340c76 100755 --- a/openair-cn/S6A/freediameter/make_certs.sh +++ b/openair-cn/S6A/freediameter/make_certs.sh @@ -39,10 +39,10 @@ HOSTNAME=$(hostname -f) echo "Creating certificate for user '$HOSTNAME'" # CA self certificate -openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM +openssl req -new -batch -x509 -days 3650 -nodes -newkey rsa:1024 -out cacert.pem -keyout cakey.pem -subj /CN=pft/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM openssl genrsa -out user.key.pem 1024 -openssl req -new -batch -out user.csr.pem -key user.key.pem -subj /CN=$HOSTNAME.eur/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM +openssl req -new -batch -out user.csr.pem -key user.key.pem -subj /CN=$HOSTNAME.pft/C=FR/ST=PACA/L=Aix/O=Eurecom/OU=CM openssl ca -cert cacert.pem -keyfile cakey.pem -in user.csr.pem -out user.cert.pem -outdir . -batch if [ ! -d /usr/local/etc/freeDiameter ] diff --git a/openair-cn/S6A/s6a_peer.c b/openair-cn/S6A/s6a_peer.c index e6c02b71fd..a9664c55bd 100644 --- a/openair-cn/S6A/s6a_peer.c +++ b/openair-cn/S6A/s6a_peer.c @@ -58,6 +58,13 @@ void s6a_peer_connected_cb(struct peer_info *info, void *arg) message_p = itti_alloc_new_message(TASK_S6A, ACTIVATE_MESSAGE); itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p); + + + /* Inform SGI that connection to HSS is established */ + message_p = itti_alloc_new_message(TASK_S6A, ACTIVATE_MESSAGE); + + itti_send_msg_to_task(TASK_FW_IP, INSTANCE_DEFAULT, message_p); + } /* For test */ diff --git a/openair-cn/S6A/s6a_task.c b/openair-cn/S6A/s6a_task.c index 50ab141267..a6fc771264 100644 --- a/openair-cn/S6A/s6a_task.c +++ b/openair-cn/S6A/s6a_task.c @@ -120,7 +120,7 @@ int s6a_init(const mme_config_t *mme_config_p) S6A_DEBUG("Initializing freeDiameter core...\n"); ret = fd_core_initialize(); if (ret != 0) { - S6A_ERROR("An error occurred during freeDiameter core library initialization\n"); + S6A_ERROR("An error occurred during freeDiameter core library initialization: %d\n",ret); return ret; } else { S6A_DEBUG("Initializing freeDiameter core done\n"); diff --git a/openair-cn/SGI/sgi.h b/openair-cn/SGI/sgi.h index 9740124975..80f5813731 100755 --- a/openair-cn/SGI/sgi.h +++ b/openair-cn/SGI/sgi.h @@ -193,6 +193,7 @@ typedef struct sgi_data_s { int hw_address_of_router_captured; uint32_t local_addr_v4_4_hw_address_router_capture; uint32_t ipv4_addr_of_router; + char hss_associated; #ifdef ENABLE_USE_PCAP_FOR_SGI diff --git a/openair-cn/SGI/sgi_socket.c b/openair-cn/SGI/sgi_socket.c index e5472ec88a..0528469af4 100644 --- a/openair-cn/SGI/sgi_socket.c +++ b/openair-cn/SGI/sgi_socket.c @@ -66,12 +66,14 @@ #include "intertask_interface.h" #ifdef ENABLE_USE_NETFILTER_FOR_SGI +#warning "ENABLE_USE_NETFILTER_FOR_SGI" #define SGI_SOCKET_RAW 1 #define SGI_SOCKET_BIND_TO_IF 1 #undef SGI_MARKING #undef SGI_PACKET_RX_RING #undef SGI_SOCKET_UDP #else +#warning "DISABLE_USE_NETFILTER_FOR_SGI" #define SGI_SOCKET_RAW 1 #define SGI_SOCKET_BIND_TO_IF 1 #undef SGI_PACKET_RX_RING @@ -120,6 +122,37 @@ struct ipv6hdr { #define PKT_OFFSET (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + \ TPACKET_ALIGN(sizeof(struct sockaddr_ll))) +int sgi_create_vlan_interface(char *interface_nameP, int vlan_idP) { + char vlan_interface_name[IFNAMSIZ]; + char command_line[256]; + int ret = 0; + + ret = sprintf(vlan_interface_name, "%s.%d", interface_nameP, vlan_idP); + if (ret > 0) { + ret = sprintf(command_line, "ifconfig %s down > /dev/null 2>&1", vlan_interface_name); + if (ret > 0) ret = system(command_line); else return -1; + + ret = sprintf(command_line, "vconfig rem %s > /dev/null 2>&1", vlan_interface_name); + if (ret > 0) ret = system(command_line); else return -1; + + ret = sprintf(command_line, "vconfig add %s %d", interface_nameP, vlan_idP); + if (ret > 0) ret = system(command_line); else return -1; + + ret = sprintf(command_line, "ifconfig %s up", vlan_interface_name); + if (ret > 0) ret = system(command_line); else return -1; + + ret = sprintf(command_line, "sync"); + if (ret > 0) ret = system(command_line); else return -1; + + ret = sprintf(command_line, "ip -4 addr add 10.0.%d.2/24 dev %s", vlan_idP+200, vlan_interface_name); + if (ret > 0) ret = system(command_line); else return -1; + return 0; + } else { + return -1; + } +} + + int sgi_create_sockets(sgi_data_t *sgi_data_p) { #ifdef SGI_SOCKET_BIND_TO_IF @@ -154,6 +187,10 @@ int sgi_create_sockets(sgi_data_t *sgi_data_p) // work //#define SGI_SOCKET_RAW for (i = 0; i < SGI_MAX_EPS_BEARERS_PER_USER; i++) { + + + sgi_create_vlan_interface(sgi_data_p->interface_name,i+SGI_MIN_EPS_BEARER_ID); + //sgi_data_p->sd[i] = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); // works also sgi_data_p->sd[i] = socket(PF_PACKET, SOCK_RAW, htons(IPPROTO_RAW)); @@ -218,7 +255,7 @@ int sgi_create_sockets(sgi_data_t *sgi_data_p) sprintf(if_name, "%s.%d",sgi_data_p->interface_name,i+SGI_MIN_EPS_BEARER_ID); memset(&socket_address, 0, sizeof(struct sockaddr_ll)); - socket_address.sll_family = PF_PACKET; + socket_address.sll_family = PF_PACKET; //always PF_PACKET //socket_address.sll_addr = ;// Filled when we want to tx //socket_address.sll_halen = ;// Filled when we want to tx @@ -227,13 +264,16 @@ int sgi_create_sockets(sgi_data_t *sgi_data_p) //socket_address.sll_hatype = ;// Filled when packet received //socket_address.sll_pkttype = ;// Filled when packet received socket_address.sll_ifindex = if_nametoindex(if_name); - socket_address.sll_protocol = htons(ETH_P_IP); + socket_address.sll_protocol = htons(ETH_P_IP);/* Protocol phy level */ //socket_address.sll_protocol = htons(ETH_P_ALL); // Now we can bind the socket to send the IP traffic if (bind(sgi_data_p->sd[i], (struct sockaddr *)&socket_address, sizeof(struct sockaddr_ll)) < 0) { SGI_IF_ERROR("Bind socket to %s (%s:%d)\n", if_name, strerror(errno), errno); goto error; + } else { + SGI_IF_DEBUG("Bind EPS bearer ID %d socket %d to %s\n", + i+SGI_MIN_EPS_BEARER_ID, sgi_data_p->sd[i], if_name); } #endif @@ -571,8 +611,8 @@ int sgi_send_data(uint8_t *buffer_pP, uint32_t length, sgi_data_t *sgi_data_pP, #endif //sgi_print_hex_octets(iov[0].iov_base, iov[0].iov_len); //sgi_print_hex_octets(iov[1].iov_base, iov[1].iov_len); - if (writev(sgi_data_pP->sd[mapping_p->eps_bearer_id - SGI_MIN_EPS_BEARER_ID], (const struct iovec *)&iov, 2) < 0) { - SGI_IF_ERROR("Error during send to socket %d bearer id %d : (%s:%d)\n", + if (writev(sgi_data_pP->sd[mapping_p->eps_bearer_id - SGI_MIN_EPS_BEARER_ID], (const struct iovec *)iov, 2) < 0) { + SGI_IF_ERROR("Error during writev to socket %d bearer id %d : (%s:%d)\n", sgi_data_pP->sd[mapping_p->eps_bearer_id - SGI_MIN_EPS_BEARER_ID], mapping_p->eps_bearer_id, strerror(errno), diff --git a/openair-cn/SGI/sgi_task.c b/openair-cn/SGI/sgi_task.c index 8d25d16917..6987fe4b30 100644 --- a/openair-cn/SGI/sgi_task.c +++ b/openair-cn/SGI/sgi_task.c @@ -55,6 +55,7 @@ static void* sgi_task_thread(void *args_p); static int sgi_create_endpoint_request(sgi_data_t *sgi_dataP, SGICreateEndpointReq *req_p); static int sgi_update_endpoint_request(sgi_data_t *sgi_dataP, SGIUpdateEndpointReq *req_p); +static int sgi_init_phase2(sgi_data_t *sgi_data_pP); //----------------------------------------------------------------------------- static pthread_t fw_2_sgi_task_thread; //----------------------------------------------------------------------------- @@ -82,41 +83,54 @@ static void* sgi_task_thread(void *args_p) DevAssert(received_message_p != NULL); - switch (ITTI_MSG_ID(received_message_p)) - { - case GTPV1U_TUNNEL_DATA_IND: { - /* We received data from GTPV1_U incoming from an UE. - * Forward it host adapter. - */ - Gtpv1uTunnelDataInd *data_ind_p; - data_ind_p = &received_message_p->ittiMsg.gtpv1uTunnelDataInd; - sgi_send_data(data_ind_p->buffer, data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid); - /* Buffer is no longer needed, free it */ - free(data_ind_p->buffer); - } - break; - case SGI_CREATE_ENDPOINT_REQUEST: { - SGICreateEndpointReq *req_p; - req_p = &received_message_p->ittiMsg.sgiCreateEndpointReq; - sgi_create_endpoint_request(sgi_data_p, req_p); - - - } - break; - - case SGI_UPDATE_ENDPOINT_REQUEST: { - SGIUpdateEndpointReq *req_p; - req_p = &received_message_p->ittiMsg.sgiUpdateEndpointReq; - sgi_update_endpoint_request(sgi_data_p, req_p); - - + if (sgi_data_p->hss_associated) { + switch (ITTI_MSG_ID(received_message_p)) + { + case GTPV1U_TUNNEL_DATA_IND: { + /* We received data from GTPV1_U incoming from an UE. + * Forward it host adapter. + */ + Gtpv1uTunnelDataInd *data_ind_p; + data_ind_p = &received_message_p->ittiMsg.gtpv1uTunnelDataInd; + sgi_send_data(data_ind_p->buffer, data_ind_p->length, sgi_data_p, data_ind_p->local_S1u_teid); + /* Buffer is no longer needed, free it */ + free(data_ind_p->buffer); + } + break; + case SGI_CREATE_ENDPOINT_REQUEST: { + SGICreateEndpointReq *req_p; + req_p = &received_message_p->ittiMsg.sgiCreateEndpointReq; + sgi_create_endpoint_request(sgi_data_p, req_p); + } + break; + + case SGI_UPDATE_ENDPOINT_REQUEST: { + SGIUpdateEndpointReq *req_p; + req_p = &received_message_p->ittiMsg.sgiUpdateEndpointReq; + sgi_update_endpoint_request(sgi_data_p, req_p); + } + break; + default: { + SGI_IF_ERROR("Unkwnon message ID %d:%s\n", + ITTI_MSG_ID(received_message_p), ITTI_MSG_NAME(received_message_p)); + } + break; } - break; - default: { - SGI_IF_ERROR("Unkwnon message ID %d:%s\n", + }else { + switch (ITTI_MSG_ID(received_message_p)) + { + case ACTIVATE_MESSAGE: { + sgi_data_p->hss_associated = 1; + SGI_IF_DEBUG("HSS ASSOCIATED, CAN START VLANS (bug in freediameter)"); + sgi_init_phase2(sgi_data_p); + } break; + + default: { + SGI_IF_ERROR("Unkwnon or ignored message ID %d:%s\n", ITTI_MSG_ID(received_message_p), ITTI_MSG_NAME(received_message_p)); + } + break; } - break; } itti_free(ITTI_MSG_ORIGIN_ID(received_message_p), received_message_p); received_message_p = NULL; @@ -251,32 +265,40 @@ int sgi_init(const pgw_config_t *pgw_config_p) sgi_data_p->interface_name[len] = '\0'; sgi_data_p->ipv4_addr = pgw_config_p->ipv4.pgw_ipv4_address_for_SGI; - if (strcmp(sgi_data_p->interface_name, PGW_CONFIG_STRING_INTERFACE_DISABLED) != 0) { - sgi_data_p->interface_index = if_nametoindex(sgi_data_p->interface_name); - if (sgi_create_sockets(sgi_data_p) < 0) { + if (pthread_create(&fw_2_sgi_task_thread, NULL, &sgi_task_thread, (void *)sgi_data_p) < 0) { + SGI_IF_ERROR("sgi_task_thread pthread_create: %s", strerror(errno)); + return -1; + } + + return 0; +} + +int sgi_init_phase2(sgi_data_t *sgi_data_pP) { + int i; + + if (strcmp(sgi_data_pP->interface_name, PGW_CONFIG_STRING_INTERFACE_DISABLED) != 0) { + sgi_data_pP->interface_index = if_nametoindex(sgi_data_pP->interface_name); + + if (sgi_create_sockets(sgi_data_pP) < 0) { SGI_IF_ERROR("Could not create socket, leaving thread %s\n", __FUNCTION__); - free(sgi_data_p); + free(sgi_data_pP); return -1; } } else { SGI_IF_WARNING("SGI interface disabled by config file\n"); } - if (pthread_create(&fw_2_sgi_task_thread, NULL, &sgi_task_thread, (void *)sgi_data_p) < 0) { - SGI_IF_ERROR("sgi_task_thread pthread_create: %s", strerror(errno)); - return -1; - } - if (strcmp(sgi_data_p->interface_name, PGW_CONFIG_STRING_INTERFACE_DISABLED) != 0) { + if (strcmp(sgi_data_pP->interface_name, PGW_CONFIG_STRING_INTERFACE_DISABLED) != 0) { #ifdef ENABLE_USE_PCAP_FOR_SGI - if (pthread_create(&sgi_data_p->capture_on_sgi_if_thread, NULL, &sgi_pcap_fw_2_gtpv1u_thread, (void *)sgi_data_p) < 0) { + if (pthread_create(&sgi_data_pP->capture_on_sgi_if_thread, NULL, &sgi_pcap_fw_2_gtpv1u_thread, (void *)sgi_data_pP) < 0) { SGI_IF_ERROR("sgi_pcap_fw_2_gtpv1u_thread pthread_create: %s", strerror(errno)); return -1; } #endif #ifdef ENABLE_USE_NETFILTER_FOR_SGI - if (pthread_create(&sgi_data_p->capture_on_sgi_if_thread, NULL, &sgi_nf_fw_2_gtpv1u_thread, (void *)sgi_data_p) < 0) { + if (pthread_create(&sgi_data_pP->capture_on_sgi_if_thread, NULL, &sgi_nf_fw_2_gtpv1u_thread, (void *)sgi_data_pP) < 0) { SGI_IF_ERROR("sgi_nf_fw_2_gtpv1u_thread pthread_create: %s", strerror(errno)); return -1; } @@ -285,9 +307,9 @@ int sgi_init(const pgw_config_t *pgw_config_p) #ifdef ENABLE_USE_RAW_SOCKET_FOR_SGI for (i=0; i < SGI_MAX_EPS_BEARERS_PER_USER; i++) { sgi_read_thread_args_t *args_p = malloc(sizeof(sgi_read_thread_args_t)); - args_p->sgi_data = sgi_data_p; + args_p->sgi_data = sgi_data_pP; args_p->socket_index = i; - if (pthread_create(&sgi_data_p->capture_on_sgi_if_thread, NULL, &sgi_sock_raw_fw_2_gtpv1u_thread, (void *)args_p) < 0) { + if (pthread_create(&sgi_data_pP->capture_on_sgi_if_thread, NULL, &sgi_sock_raw_fw_2_gtpv1u_thread, (void *)args_p) < 0) { SGI_IF_ERROR("sgi_sock_raw_fw_2_gtpv1u_thread pthread_create: %s", strerror(errno)); return -1; } @@ -296,7 +318,7 @@ int sgi_init(const pgw_config_t *pgw_config_p) //#endif } - while (sgi_data_p->thread_started != SGI_MAX_EPS_BEARERS_PER_USER ) { + while (sgi_data_pP->thread_started != SGI_MAX_EPS_BEARERS_PER_USER ) { usleep(1000); } /*SGI_IF_DEBUG("ARP RESOLVING ROUTER...\n"); diff --git a/openair-cn/UTILS/CONF/s6a.conf.in b/openair-cn/UTILS/CONF/s6a.conf.in index 928f0d1447..4fd08b600c 100644 --- a/openair-cn/UTILS/CONF/s6a.conf.in +++ b/openair-cn/UTILS/CONF/s6a.conf.in @@ -1,8 +1,8 @@ # -------- Local --------- # Uncomment if the framework cannot resolv it. -Identity = "@HOSTNAME@.eur"; -Realm = "eur"; +Identity = "@HOSTNAME@.pft"; +Realm = "pft"; # TLS configuration (see previous section) TLS_Cred = "/usr/local/etc/freeDiameter/user.cert.pem", @@ -24,6 +24,8 @@ AppServThreads = 1; #ListenOn = "192.168.57.100"; +#Port = 3870; +#SecPort = 3871; # -------- Extensions --------- # Uncomment (and create rtd.conf) to specify routing table for this peer. @@ -61,4 +63,4 @@ LoadExtension = "dict_s6a.fdx"; # For only accepting incoming connections, see the acl_wl.fx extension. # ConnectPeer = "hss.test.fr" { ConnectTo = "192.168.56.101"; No_IPv6; No_TCP; Port = 3868; Realm = "test.fr"; }; -# ConnectPeer = "hss.eur" { ConnectTo = "192.168.12.190"; No_IPv6; Port = 3868; }; +#ConnectPeer = "hss.pft" { ConnectTo = "192.168.14.17"; No_IPv6; Port = 3868; }; diff --git a/openair-cn/UTILS/mme_config.c b/openair-cn/UTILS/mme_config.c index 2d4eb4ff7e..d0df783fdd 100644 --- a/openair-cn/UTILS/mme_config.c +++ b/openair-cn/UTILS/mme_config.c @@ -428,7 +428,7 @@ static int config_parse_file(mme_config_t *mme_config_p) (const char **)&sgw_ip_address_for_S1u_S12_S4_up) && config_setting_lookup_string( subsetting, SGW_CONFIG_STRING_SGW_IPV4_ADDRESS_FOR_S11, (const char **)&sgw_ip_address_for_S11) - && config_setting_lookup_int( setting, SGW_CONFIG_STRING_SGW_PORT_FOR_S1U_S12_S4_UP, &alongint) + && config_setting_lookup_int( subsetting, SGW_CONFIG_STRING_SGW_PORT_FOR_S1U_S12_S4_UP, &alongint) ) ) { cidr = strdup(sgw_ip_address_for_S1u_S12_S4_up); @@ -483,9 +483,8 @@ static void config_display(mme_config_t *mme_config_p) fprintf(stdout, " port number ......: %d\n", mme_config_p->s1ap_config.port_number); fprintf(stdout, "- IP:\n"); //fprintf(stdout, " s1-u iface .......: %s\n", mme_config_p->ipv4.sgw_interface_name_for_S1u_S12_S4_up); - //fprintf(stdout, " s1-u ip ..........: %s/%d\n", - // inet_ntoa(*((struct in_addr *)&mme_config_p->ipv4.sgw_ip_address_for_S1u_S12_S4_up)), - // mme_config_p->ipv4.sgw_ip_netmask_for_S1u_S12_S4_up); + fprintf(stdout, " s1-u ip ..........: %s\n", + inet_ntoa(*((struct in_addr *)&mme_config_p->ipv4.sgw_ip_address_for_S1u_S12_S4_up))); //fprintf(stdout, " sgi iface ........: %s\n", mme_config_p->ipv4.pgw_interface_name_for_SGI); //fprintf(stdout, " sgi ip ...........: %s/%d\n", // inet_ntoa(*((struct in_addr *)&mme_config_p->ipv4.pgw_ip_addr_for_SGI)), -- GitLab