diff --git a/srsepc/src/mbms-gw/mbms-gw.cc b/srsepc/src/mbms-gw/mbms-gw.cc index a3d18a68d..3031fc1c8 100644 --- a/srsepc/src/mbms-gw/mbms-gw.cc +++ b/srsepc/src/mbms-gw/mbms-gw.cc @@ -285,8 +285,6 @@ mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t *msg) { uint8_t version; srslte::gtpu_header_t header; - in_addr_t baddr = inet_addr("172.16.0.255"); - in_addr_t saddr = inet_addr("172.16.0.254"); //Setup GTP-U header header.flags = 0x30; @@ -301,44 +299,14 @@ mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t *msg) return; } - //IP+UDP Headers + //IP Headers struct iphdr *iph = (struct iphdr *) msg->msg; - struct udphdr *udph = (struct udphdr *) (msg->msg + iph->ihl*4); if(iph->version != 4) { m_mbms_gw_log->warning("IPv6 not supported yet.\n"); return; } - //Replace Destination IP with broadcast address - iph->daddr = baddr; - - //Replace Source IP with address in same subnet - iph->saddr = saddr; - - //Replace IP cheksum - iph->check = 0; - iph->check = in_cksum((uint16_t*)msg->msg,4*(msg->msg[0] & 0x0F)); - - //Set Pseudo Header - struct pseudo_hdr phdr; - phdr.src_addr = iph->saddr; - phdr.dst_addr = iph->daddr; - phdr.protocol = IPPROTO_UDP; - phdr.placeholder = 0; - phdr.udp_len = udph->len; - - //Set Pseudo Datagram - udph->check = 0; - int psize = sizeof(struct pseudo_hdr) + ntohs(udph->len); - uint8_t * pseudo_dgram = (uint8_t*) malloc(psize); - memcpy(pseudo_dgram, &phdr,sizeof(struct pseudo_hdr)); - memcpy(pseudo_dgram+sizeof(pseudo_hdr),udph,ntohs(udph->len)); - - //Recompute UDP checksum - udph->check = in_cksum((uint16_t*) pseudo_dgram, psize); - free(pseudo_dgram); - //Write GTP-U header into packet if(!srslte::gtpu_write_header(&header, msg)) { @@ -355,31 +323,4 @@ mbms_gw::handle_sgi_md_pdu(srslte::byte_buffer_t *msg) } } -uint16_t -mbms_gw::in_cksum(uint16_t *iphdr, int count) -{ - - //RFC 1071 - uint32_t sum = 0; - uint16_t padd = 0; - uint16_t result; - while(count > 1) - { - sum+= *iphdr++; - count -= 2; - } - if( count > 0 ) - { - padd = * (uint8_t *) iphdr; - sum += padd; - } - /*Fold 32-bit sum to 16-bit*/ - // while(sum>>16) - // sum = (sum & 0xffff) + (sum >> 16); - sum = (sum>>16)+(sum & 0xFFFF); - sum = sum + (sum >> 16); - result = (uint16_t) ~sum; - return result; -} - } //namespace srsepc