Fixed last compilation issues.

master
Pedro Alvarez 6 years ago
parent ee04639337
commit e320c33aef

@ -38,15 +38,15 @@ namespace srslte {
bool gtpu_write_header(gtpu_header_t *header, srslte::byte_buffer_t *pdu, srslte::log *gtpu_log) bool gtpu_write_header(gtpu_header_t *header, srslte::byte_buffer_t *pdu, srslte::log *gtpu_log)
{ {
if(header->flags.version != GTPU_VERSION_V1) { if(header->gtpu_flags.flag_bits.version != GTPU_VERSION_V1) {
gtpu_log->error("gtpu_write_header - Unhandled GTP-U Version.\n"); gtpu_log->error("gtpu_write_header - Unhandled GTP-U Version.\n");
return false; return false;
} }
if(header->flags.protocol_type != GTP_PROTO) { if(header->gtpu_flags.flag_bits.protocol_type != GTP_PROTO) {
gtpu_log->error("gtpu_write_header - Unhandled Protocol Type.\n"); gtpu_log->error("gtpu_write_header - Unhandled Protocol Type.\n");
return false; return false;
} }
if(header->flags.ext_header) { if(header->gtpu_flags.flag_bits.ext_header) {
gtpu_log->error("gtpu_write_header - Unhandled Header Extensions.\n"); gtpu_log->error("gtpu_write_header - Unhandled Header Extensions.\n");
return false; return false;
} }
@ -64,7 +64,7 @@ bool gtpu_write_header(gtpu_header_t *header, srslte::byte_buffer_t *pdu, srslte
uint8_t *ptr = pdu->msg; uint8_t *ptr = pdu->msg;
*ptr = header->flags; *ptr = header->gtpu_flags.flags;
ptr++; ptr++;
*ptr = header->message_type; *ptr = header->message_type;
ptr++; ptr++;
@ -79,7 +79,7 @@ bool gtpu_read_header(srslte::byte_buffer_t *pdu, gtpu_header_t *header, srslte:
{ {
uint8_t *ptr = pdu->msg; uint8_t *ptr = pdu->msg;
header->flags = *ptr; header->gtpu_flags.flags = *ptr;
ptr++; ptr++;
header->message_type = *ptr; header->message_type = *ptr;
ptr++; ptr++;

@ -123,8 +123,8 @@ void gtpu::write_pdu(uint16_t rnti, uint32_t lcid, srslte::byte_buffer_t* pdu)
gtpu_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU, RNTI: 0x%x, LCID: %d, n_bytes=%d", rnti, lcid, pdu->N_bytes); gtpu_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU, RNTI: 0x%x, LCID: %d, n_bytes=%d", rnti, lcid, pdu->N_bytes);
gtpu_header_t header; gtpu_header_t header;
bzero(&header,sizeof(header)); bzero(&header,sizeof(header));
header.flags.version = GTPU_VERSION_V1; header.gtpu_flags.flag_bits.version = GTPU_VERSION_V1;
header.flags.protocol_type = GTP_PROTO; header.gtpu_flags.flag_bits.protocol_type = GTP_PROTO;
header.message_type = GTPU_MSG_DATA_PDU; header.message_type = GTPU_MSG_DATA_PDU;
header.length = pdu->N_bytes; header.length = pdu->N_bytes;
header.teid = rnti_bearers[rnti].teids_out[lcid]; header.teid = rnti_bearers[rnti].teids_out[lcid];
@ -282,25 +282,27 @@ void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq)
gtpu_header_t header; gtpu_header_t header;
bzero(&header, sizeof(header)); bzero(&header, sizeof(header));
srslte::byte_buffer_t *pdu = pool_allocate;
//flags //flags
header.flags.version = GTPU_VERSION_V1; header.gtpu_flags.flag_bits.version = GTPU_VERSION_V1;
header.flags.protocol_type = GTP_PROTO; header.gtpu_flags.flag_bits.protocol_type = GTP_PROTO;
header.flags.sequence = 1; header.gtpu_flags.flag_bits.sequence = 1;
uint8_t resp[12]; header.message_type = GTPU_MSG_ECHO_RESPONSE;
bzero(resp, 12); header.teid = 0;
resp[0] = 0x32; //flags header.length = 4;
resp[1] = 0x02; //type header.seq_number = seq;
uint16_to_uint8(4, &resp[2]); //length
uint32_to_uint8(0, &resp[4]); //TEID gtpu_write_header(&header,pdu,gtpu_log);
uint16_to_uint8(seq, &resp[8]); //seq
struct sockaddr_in servaddr; struct sockaddr_in servaddr;
servaddr.sin_family = AF_INET; servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = addr; servaddr.sin_addr.s_addr = addr;
servaddr.sin_port = port; servaddr.sin_port = port;
sendto(fd, resp, 12, MSG_EOR, (struct sockaddr*)&servaddr, sizeof(struct sockaddr_in)); sendto(fd, pdu->msg, 12, MSG_EOR, (struct sockaddr*)&servaddr, sizeof(struct sockaddr_in));
pool->deallocate(pdu);
} }
/**************************************************************************** /****************************************************************************

@ -288,8 +288,8 @@ mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t *msg)
bzero(&header, sizeof(srslte::gtpu_header_t)); bzero(&header, sizeof(srslte::gtpu_header_t));
//Setup GTP-U header //Setup GTP-U header
header.flags.version = GTPU_VERSION_V1; header.gtpu_flags.flag_bits.version = GTPU_VERSION_V1;
header.flags.protocol_type = GTP_PROTO; header.gtpu_flags.flag_bits.protocol_type = GTP_PROTO;
header.message_type = GTPU_MSG_DATA_PDU; header.message_type = GTPU_MSG_DATA_PDU;
header.length = msg->N_bytes; header.length = msg->N_bytes;
header.teid = 0xAAAA; //FIXME Harcoded TEID for now header.teid = 0xAAAA; //FIXME Harcoded TEID for now

@ -330,28 +330,24 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg)
srslte::gtpc_f_teid_ie enb_fteid; srslte::gtpc_f_teid_ie enb_fteid;
struct iphdr *iph = (struct iphdr *) msg->msg; struct iphdr *iph = (struct iphdr *) msg->msg;
if(iph->version != 4) if (iph->version != 4) {
{
m_spgw_log->warning("IPv6 not supported yet.\n"); m_spgw_log->warning("IPv6 not supported yet.\n");
return; return;
} }
if(iph->tot_len < 20) if (iph->tot_len < 20) {
{
m_spgw_log->warning("Invalid IP header length.\n"); m_spgw_log->warning("Invalid IP header length.\n");
return; return;
} }
pthread_mutex_lock(&m_mutex); pthread_mutex_lock(&m_mutex);
gtp_fteid_it = m_ip_to_teid.find(iph->daddr); gtp_fteid_it = m_ip_to_teid.find(iph->daddr);
if(gtp_fteid_it != m_ip_to_teid.end()) if (gtp_fteid_it != m_ip_to_teid.end()) {
{
ip_found = true; ip_found = true;
enb_fteid = gtp_fteid_it->second; enb_fteid = gtp_fteid_it->second;
} }
pthread_mutex_unlock(&m_mutex); pthread_mutex_unlock(&m_mutex);
if(ip_found == false) if (ip_found == false) {
{
//m_spgw_log->console("IP Packet is not for any UE\n"); //m_spgw_log->console("IP Packet is not for any UE\n");
return; return;
} }
@ -364,9 +360,9 @@ spgw::handle_sgi_pdu(srslte::byte_buffer_t *msg)
//Setup GTP-U header //Setup GTP-U header
srslte::gtpu_header_t header; srslte::gtpu_header_t header;
bzero(&header,sizeof(srslte::gtpu_header_t)); bzero(&header,sizeof(srslte::gtpu_header_t));
header.flags.version = GTPU_VERSION_V1; header.gtpu_flags.flag_bits.version = GTPU_VERSION_V1;
header.flags.protocol_type = GTP_PROTO; header.gtpu_flags.flag_bits.protocol_type = GTP_PROTO;
header.message_type = GTPU_MSG_DATA_PDU; header.message_type = GTPU_MSG_DATA_PDU;
header.length = msg->N_bytes; header.length = msg->N_bytes;
header.teid = enb_fteid.teid; header.teid = enb_fteid.teid;

Loading…
Cancel
Save