Commit 374388df authored by Lionel Gauthier's avatar Lionel Gauthier

correct IPv4 address

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7183 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e39b5915
...@@ -247,23 +247,27 @@ int esm_ebr_context_create( ...@@ -247,23 +247,27 @@ int esm_ebr_context_create(
// etc // etc
case NET_PDN_TYPE_IPV4: case NET_PDN_TYPE_IPV4:
in_addr.s_addr = pdn->ip_addr[0] << 24; // in_addr is in network byte order
in_addr.s_addr |= pdn->ip_addr[1] << 16; in_addr.s_addr = pdn->ip_addr[0] << 24 |
in_addr.s_addr |= pdn->ip_addr[2] << 8; ((pdn->ip_addr[1] << 16) & 0x00FF0000) |
in_addr.s_addr |= pdn->ip_addr[3] ; ((pdn->ip_addr[2] << 8) & 0x0000FF00) |
( pdn->ip_addr[3] & 0x000000FF);
in_addr.s_addr = htonl(in_addr.s_addr);
tmp = inet_ntoa(in_addr); tmp = inet_ntoa(in_addr);
// AssertFatal(tmp , //AssertFatal(tmp ,
// "error in PDN IPv4 address %x", // "error in PDN IPv4 address %x",
// in_addr.s_addr); // in_addr.s_addr);
strcpy(ipv4_addr, tmp); strcpy(ipv4_addr, tmp);
if (IN_CLASSA(in_addr.s_addr)) { if (IN_CLASSA(in_addr.s_addr)) {
netmask = "255.0.0.0"; netmask = "255.0.0.0";
in_addr.s_addr = pdn->ip_addr[0] << 24; in_addr.s_addr = pdn->ip_addr[0] << 24 |
in_addr.s_addr |= 255 << 16; ((255 << 16) & 0x00FF0000) |
in_addr.s_addr |= 255 << 8; ((255 << 8) & 0x0000FF00) |
in_addr.s_addr |= 255 ; ( 255 & 0x000000FF);
in_addr.s_addr = htonl(in_addr.s_addr);
tmp = inet_ntoa(in_addr); tmp = inet_ntoa(in_addr);
// AssertFatal(tmp , // AssertFatal(tmp ,
// "error in PDN IPv4 address %x", // "error in PDN IPv4 address %x",
...@@ -271,10 +275,11 @@ int esm_ebr_context_create( ...@@ -271,10 +275,11 @@ int esm_ebr_context_create(
strcpy(broadcast, tmp); strcpy(broadcast, tmp);
} else if (IN_CLASSB(in_addr.s_addr)) { } else if (IN_CLASSB(in_addr.s_addr)) {
netmask = "255.255.0.0"; netmask = "255.255.0.0";
in_addr.s_addr = pdn->ip_addr[0] << 24; in_addr.s_addr = pdn->ip_addr[0] << 24 |
in_addr.s_addr |= pdn->ip_addr[1] << 16; ((pdn->ip_addr[1] << 16) & 0x00FF0000) |
in_addr.s_addr |= 255 << 8; ((255 << 8) & 0x0000FF00) |
in_addr.s_addr |= 255 ; ( 255 & 0x000000FF);
in_addr.s_addr = htonl(in_addr.s_addr);
tmp = inet_ntoa(in_addr); tmp = inet_ntoa(in_addr);
// AssertFatal(tmp , // AssertFatal(tmp ,
// "error in PDN IPv4 address %x", // "error in PDN IPv4 address %x",
...@@ -282,10 +287,11 @@ int esm_ebr_context_create( ...@@ -282,10 +287,11 @@ int esm_ebr_context_create(
strcpy(broadcast, tmp); strcpy(broadcast, tmp);
} else if (IN_CLASSC(in_addr.s_addr)) { } else if (IN_CLASSC(in_addr.s_addr)) {
netmask = "255.255.255.0"; netmask = "255.255.255.0";
in_addr.s_addr = pdn->ip_addr[0] << 24; in_addr.s_addr = pdn->ip_addr[0] << 24 |
in_addr.s_addr |= pdn->ip_addr[1] << 16; ((pdn->ip_addr[1] << 16) & 0x00FF0000) |
in_addr.s_addr |= pdn->ip_addr[2] << 8; ((pdn->ip_addr[2] << 8) & 0x0000FF00) |
in_addr.s_addr |= 255 ; ( 255 & 0x000000FF);
in_addr.s_addr = htonl(in_addr.s_addr);
tmp = inet_ntoa(in_addr); tmp = inet_ntoa(in_addr);
// AssertFatal(tmp , // AssertFatal(tmp ,
// "error in PDN IPv4 address %x", // "error in PDN IPv4 address %x",
......
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