Commit 00483797 authored by Laurent THOMAS's avatar Laurent THOMAS

code review comment

parent aa47fa4c
...@@ -108,7 +108,7 @@ instance_t legacyInstanceMapping=0; ...@@ -108,7 +108,7 @@ instance_t legacyInstanceMapping=0;
#define GTPV1U_HEADER_SIZE (8) #define GTPV1U_HEADER_SIZE (8)
static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen, static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, int msgType, teid_t teid, uint8_t *Msg,int msgLen,
bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) { bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) {
AssertFatal(extHdrFlag==false,"Not developped"); AssertFatal(extHdrFlag==false,"Not developped");
int headerAdditional=0; int headerAdditional=0;
...@@ -149,6 +149,7 @@ instance_t legacyInstanceMapping=0; ...@@ -149,6 +149,7 @@ instance_t legacyInstanceMapping=0;
to.sin_addr.s_addr = peerIp ; to.sin_addr.s_addr = peerIp ;
LOG_D(GTPU,"sending packet size: %d to %s\n",fullSize, inet_ntoa(to.sin_addr) ); LOG_D(GTPU,"sending packet size: %d to %s\n",fullSize, inet_ntoa(to.sin_addr) );
int ret; int ret;
if ((ret=sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) )) != fullSize ) { if ((ret=sendto(h, (void *)buffer, (size_t)fullSize, 0,(struct sockaddr *)&to, sizeof(to) )) != fullSize ) {
LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u, ret: %d, errno: %d\n", LOG_E(GTPU, "[SD %d] Failed to send data to " IPV4_ADDR " on port %d, buffer size %u, ret: %d, errno: %d\n",
h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize, ret, errno); h, IPV4_ADDR_FORMAT(peerIp), peerPort, fullSize, ret, errno);
...@@ -309,6 +310,7 @@ static int udpServerSocket(openAddr_s addr) { ...@@ -309,6 +310,7 @@ static int udpServerSocket(openAddr_s addr) {
LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status)); LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status));
return -1; return -1;
} }
int sockfd=-1; int sockfd=-1;
// loop through all the results and bind to the first we can // loop through all the results and bind to the first we can
...@@ -496,12 +498,12 @@ int gtpv1u_create_s1u_tunnel(instance_t instance, ...@@ -496,12 +498,12 @@ int gtpv1u_create_s1u_tunnel(instance_t instance,
create_tunnel_req->num_tunnels, create_tunnel_req->num_tunnels,
create_tunnel_req->sgw_S1u_teid[0]); create_tunnel_req->sgw_S1u_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4, AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4,
"From legacy code not clear, seems impossible (bearer=%d)\n", "From legacy code not clear, seems impossible (bearer=%d)\n",
create_tunnel_req->eps_bearer_id[i]); create_tunnel_req->eps_bearer_id[i]);
int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4; int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4;
teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti, teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti,
incoming_rb_id, incoming_rb_id,
create_tunnel_req->eps_bearer_id[i], create_tunnel_req->eps_bearer_id[i],
...@@ -565,6 +567,7 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance, ...@@ -565,6 +567,7 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance,
create_tunnel_req->num_tunnels, create_tunnel_req->num_tunnels,
create_tunnel_req->outgoing_teid[0]); create_tunnel_req->outgoing_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport(); tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) { for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti, teid_t teid=newGtpuCreateTunnel(instance, create_tunnel_req->rnti,
create_tunnel_req->incoming_rb_id[i], create_tunnel_req->incoming_rb_id[i],
...@@ -600,7 +603,7 @@ int gtpv1u_create_x2u_tunnel( ...@@ -600,7 +603,7 @@ int gtpv1u_create_x2u_tunnel(
AssertFatal( false, "to be developped\n"); AssertFatal( false, "to be developped\n");
} }
int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) { int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti) {
LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n", LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n",
instance, rnti); instance, rnti);
pthread_mutex_lock(&globGtp.gtp_lock); pthread_mutex_lock(&globGtp.gtp_lock);
...@@ -628,14 +631,14 @@ int gtpv1u_create_x2u_tunnel( ...@@ -628,14 +631,14 @@ int gtpv1u_create_x2u_tunnel(
return !GTPNOK; return !GTPNOK;
} }
// Legacy delete tunnel finish by deleting all the rnti // Legacy delete tunnel finish by deleting all the rnti
// so the list of bearer provided is only a design bug // so the list of bearer provided is only a design bug
int gtpv1u_delete_s1u_tunnel( const instance_t instance, int gtpv1u_delete_s1u_tunnel( const instance_t instance,
const gtpv1u_enb_delete_tunnel_req_t *const req_pP) { const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
return newGtpuDeleteAllTunnels(instance, req_pP->rnti); return newGtpuDeleteAllTunnels(instance, req_pP->rnti);
} }
int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id) { int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id) {
LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n", LOG_D(GTPU, "[%ld] Start delete tunnels for RNTI %x\n",
instance, rnti); instance, rnti);
pthread_mutex_lock(&globGtp.gtp_lock); pthread_mutex_lock(&globGtp.gtp_lock);
...@@ -652,6 +655,7 @@ int gtpv1u_create_x2u_tunnel( ...@@ -652,6 +655,7 @@ int gtpv1u_create_x2u_tunnel(
for (int i=0; i<nbTunnels; i++) { for (int i=0; i<nbTunnels; i++) {
auto ptr2=ptrRNTI->second.bearers.find(pdusession_id[i]); auto ptr2=ptrRNTI->second.bearers.find(pdusession_id[i]);
if ( ptr2 == ptrRNTI->second.bearers.end() ) { if ( ptr2 == ptrRNTI->second.bearers.end() ) {
LOG_E(GTPU,"[%ld] GTP-U instance: delete of not existing tunnel RNTI:RAB: %x/%x\n", instance, rnti,pdusession_id[i]); LOG_E(GTPU,"[%ld] GTP-U instance: delete of not existing tunnel RNTI:RAB: %x/%x\n", instance, rnti,pdusession_id[i]);
} else { } else {
...@@ -663,10 +667,11 @@ int gtpv1u_create_x2u_tunnel( ...@@ -663,10 +667,11 @@ int gtpv1u_create_x2u_tunnel(
if (ptrRNTI->second.bearers.size() == 0 ) if (ptrRNTI->second.bearers.size() == 0 )
// no tunnels on this rnti, erase the ue entry // no tunnels on this rnti, erase the ue entry
inst->ue2te_mapping.erase(ptrRNTI); inst->ue2te_mapping.erase(ptrRNTI);
pthread_mutex_unlock(&globGtp.gtp_lock); pthread_mutex_unlock(&globGtp.gtp_lock);
LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb); LOG_I(GTPU, "[%ld] Deleted all tunnels for RNTI %x (%d tunnels deleted)\n", instance, rnti, nb);
return !GTPNOK; return !GTPNOK;
} }
int gtpv1u_delete_x2u_tunnel( const instance_t instanceP, int gtpv1u_delete_x2u_tunnel( const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t *const req_pP) { const gtpv1u_enb_delete_tunnel_req_t *const req_pP) {
...@@ -675,7 +680,7 @@ int gtpv1u_delete_x2u_tunnel( const instance_t instanceP, ...@@ -675,7 +680,7 @@ int gtpv1u_delete_x2u_tunnel( const instance_t instanceP,
} }
int gtpv1u_delete_ngu_tunnel( const instance_t instance, int gtpv1u_delete_ngu_tunnel( const instance_t instance,
gtpv1u_gnb_delete_tunnel_req_t * req) { gtpv1u_gnb_delete_tunnel_req_t *req) {
return newGtpuDeleteTunnels(instance, req->rnti, req->num_pdusession, req->pdusession_id); return newGtpuDeleteTunnels(instance, req->rnti, req->num_pdusession, req->pdusession_id);
} }
...@@ -696,14 +701,12 @@ static int Gtpv1uHandleEchoReq(int h, ...@@ -696,14 +701,12 @@ static int Gtpv1uHandleEchoReq(int h,
return GTPNOK; return GTPNOK;
} }
uint16_t seq=ntohs(*(uint16_t*)(msgHdr+1)); uint16_t seq=ntohs(*(uint16_t *)(msgHdr+1));
LOG_D(GTPU, "[%d] Received a echo request, TEID: %d, seq: %hu\n", h, msgHdr->teid, seq); LOG_D(GTPU, "[%d] Received a echo request, TEID: %d, seq: %hu\n", h, msgHdr->teid, seq);
uint8_t recovery[2]={14,0}; uint8_t recovery[2]= {14,0};
return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid), return gtpv1uCreateAndSendMsg(h, peerIp, peerPort, GTP_ECHO_RSP, ntohl(msgHdr->teid),
recovery, sizeof recovery, recovery, sizeof recovery,
1, 0, 0, seq, 0, 0); 1, 0, 0, seq, 0, 0);
} }
static int Gtpv1uHandleError(int h, static int Gtpv1uHandleError(int h,
......
...@@ -52,7 +52,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer ...@@ -52,7 +52,7 @@ teid_t newGtpuCreateTunnel(instance_t instance, rnti_t rnti, int incoming_bearer
transport_layer_addr_t remoteAddr, int port, gtpCallback callBack); transport_layer_addr_t remoteAddr, int port, gtpCallback callBack);
void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid); void GtpuUpdateTunnelOutgoingTeid(instance_t instance, rnti_t rnti, ebi_t bearer_id, teid_t newOutgoingTeid);
int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti); int newGtpuDeleteAllTunnels(instance_t instance, rnti_t rnti);
int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id); int newGtpuDeleteTunnels(instance_t instance, rnti_t rnti, int nbTunnels, pdusessionid_t *pdusession_id);
instance_t gtpv1Init(openAddr_t context); instance_t gtpv1Init(openAddr_t context);
void *gtpv1uTask(void *args); void *gtpv1uTask(void *args);
......
...@@ -86,28 +86,28 @@ gtpv1u_new_data_req( ...@@ -86,28 +86,28 @@ gtpv1u_new_data_req(
uint32_t buf_offset);*/ uint32_t buf_offset);*/
int gtpv1u_eNB_init(void); int gtpv1u_eNB_init(void);
void *gtpv1u_eNB_process_itti_msg(void*); void *gtpv1u_eNB_process_itti_msg(void *);
void *gtpv1u_eNB_task(void *args); void *gtpv1u_eNB_task(void *args);
int int
gtpv1u_create_x2u_tunnel( gtpv1u_create_x2u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_create_x2u_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_enb_create_x2u_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_x2u_tunnel_resp_t * const create_tunnel_resp_pP); gtpv1u_enb_create_x2u_tunnel_resp_t *const create_tunnel_resp_pP);
int int
gtpv1u_create_s1u_tunnel( gtpv1u_create_s1u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_enb_create_tunnel_resp_t * const create_tunnel_resp_pP); gtpv1u_enb_create_tunnel_resp_t *const create_tunnel_resp_pP);
int int
gtpv1u_update_s1u_tunnel( gtpv1u_update_s1u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_enb_create_tunnel_req_t *const create_tunnel_req_pP,
const rnti_t prior_rnti); const rnti_t prior_rnti);
int gtpv1u_delete_x2u_tunnel( int gtpv1u_delete_x2u_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP); const gtpv1u_enb_delete_tunnel_req_t *const req_pP);
#endif /* GTPV1U_ENB_TASK_H_ */ #endif /* GTPV1U_ENB_TASK_H_ */
...@@ -37,8 +37,8 @@ void *nr_gtpv1u_gNB_task(void *args); ...@@ -37,8 +37,8 @@ void *nr_gtpv1u_gNB_task(void *args);
int int
gtpv1u_create_ngu_tunnel( gtpv1u_create_ngu_tunnel(
const instance_t instanceP, const instance_t instanceP,
const gtpv1u_gnb_create_tunnel_req_t * const create_tunnel_req_pP, const gtpv1u_gnb_create_tunnel_req_t *const create_tunnel_req_pP,
gtpv1u_gnb_create_tunnel_resp_t * const create_tunnel_resp_pP); gtpv1u_gnb_create_tunnel_resp_t *const create_tunnel_resp_pP);
int int
gtpv1u_update_ngu_tunnel( gtpv1u_update_ngu_tunnel(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment