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
...@@ -232,88 +232,94 @@ int esm_ebr_context_create( ...@@ -232,88 +232,94 @@ int esm_ebr_context_create(
#ifdef NAS_UE #ifdef NAS_UE
// LG ADD TEMP // LG ADD TEMP
{ {
char *tmp = NULL; char *tmp = NULL;
char ipv4_addr[INET_ADDRSTRLEN]; char ipv4_addr[INET_ADDRSTRLEN];
char ipv6_addr[INET6_ADDRSTRLEN]; char ipv6_addr[INET6_ADDRSTRLEN];
char *netmask = NULL; char *netmask = NULL;
char broadcast[INET_ADDRSTRLEN]; char broadcast[INET_ADDRSTRLEN];
struct in_addr in_addr; struct in_addr in_addr;
char command_line[128]; char command_line[128];
int res; int res;
switch (pdn->type) { switch (pdn->type) {
case NET_PDN_TYPE_IPV4V6: case NET_PDN_TYPE_IPV4V6:
ipv6_addr[0] = pdn->ip_addr[4]; ipv6_addr[0] = pdn->ip_addr[4];
// 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);
tmp = inet_ntoa(in_addr);
// AssertFatal(tmp , in_addr.s_addr = htonl(in_addr.s_addr);
// "error in PDN IPv4 address %x",
// in_addr.s_addr); tmp = inet_ntoa(in_addr);
strcpy(ipv4_addr, tmp); //AssertFatal(tmp ,
// "error in PDN IPv4 address %x",
if (IN_CLASSA(in_addr.s_addr)) { // in_addr.s_addr);
netmask = "255.0.0.0"; strcpy(ipv4_addr, tmp);
in_addr.s_addr = pdn->ip_addr[0] << 24;
in_addr.s_addr |= 255 << 16; if (IN_CLASSA(in_addr.s_addr)) {
in_addr.s_addr |= 255 << 8; netmask = "255.0.0.0";
in_addr.s_addr |= 255 ; in_addr.s_addr = pdn->ip_addr[0] << 24 |
tmp = inet_ntoa(in_addr); ((255 << 16) & 0x00FF0000) |
// AssertFatal(tmp , ((255 << 8) & 0x0000FF00) |
// "error in PDN IPv4 address %x", ( 255 & 0x000000FF);
// in_addr.s_addr); in_addr.s_addr = htonl(in_addr.s_addr);
strcpy(broadcast, tmp); tmp = inet_ntoa(in_addr);
} else if (IN_CLASSB(in_addr.s_addr)) { // AssertFatal(tmp ,
netmask = "255.255.0.0"; // "error in PDN IPv4 address %x",
in_addr.s_addr = pdn->ip_addr[0] << 24; // in_addr.s_addr);
in_addr.s_addr |= pdn->ip_addr[1] << 16; strcpy(broadcast, tmp);
in_addr.s_addr |= 255 << 8; } else if (IN_CLASSB(in_addr.s_addr)) {
in_addr.s_addr |= 255 ; netmask = "255.255.0.0";
tmp = inet_ntoa(in_addr); in_addr.s_addr = pdn->ip_addr[0] << 24 |
// AssertFatal(tmp , ((pdn->ip_addr[1] << 16) & 0x00FF0000) |
// "error in PDN IPv4 address %x", ((255 << 8) & 0x0000FF00) |
// in_addr.s_addr); ( 255 & 0x000000FF);
strcpy(broadcast, tmp); in_addr.s_addr = htonl(in_addr.s_addr);
} else if (IN_CLASSC(in_addr.s_addr)) { tmp = inet_ntoa(in_addr);
netmask = "255.255.255.0"; // AssertFatal(tmp ,
in_addr.s_addr = pdn->ip_addr[0] << 24; // "error in PDN IPv4 address %x",
in_addr.s_addr |= pdn->ip_addr[1] << 16; // in_addr.s_addr);
in_addr.s_addr |= pdn->ip_addr[2] << 8; strcpy(broadcast, tmp);
in_addr.s_addr |= 255 ; } else if (IN_CLASSC(in_addr.s_addr)) {
tmp = inet_ntoa(in_addr); netmask = "255.255.255.0";
// AssertFatal(tmp , in_addr.s_addr = pdn->ip_addr[0] << 24 |
// "error in PDN IPv4 address %x", ((pdn->ip_addr[1] << 16) & 0x00FF0000) |
// in_addr.s_addr); ((pdn->ip_addr[2] << 8) & 0x0000FF00) |
strcpy(broadcast, tmp); ( 255 & 0x000000FF);
} else { in_addr.s_addr = htonl(in_addr.s_addr);
netmask = "255.255.255.255"; tmp = inet_ntoa(in_addr);
strcpy(broadcast, ipv4_addr); // AssertFatal(tmp ,
} // "error in PDN IPv4 address %x",
// in_addr.s_addr);
res = sprintf(command_line, strcpy(broadcast, tmp);
"ifconfig oip1 %s netmask %s broadcast %s up", } else {
ipv4_addr, netmask, broadcast); netmask = "255.255.255.255";
// AssertFatal((res > 0) && (res < 128), strcpy(broadcast, ipv4_addr);
// "error in system command line"); }
LOG_TRACE(INFO, "ESM-PROC - executing %s ",
command_line); res = sprintf(command_line,
system(command_line); "ifconfig oip1 %s netmask %s broadcast %s up",
break; ipv4_addr, netmask, broadcast);
// AssertFatal((res > 0) && (res < 128),
case NET_PDN_TYPE_IPV6: // "error in system command line");
break; LOG_TRACE(INFO, "ESM-PROC - executing %s ",
command_line);
default: system(command_line);
break; break;
}
} case NET_PDN_TYPE_IPV6:
// AssertFatal(0, "Forced stop in NAS UE"); break;
default:
break;
}
}
// AssertFatal(0, "Forced stop in NAS UE");
#endif #endif
} }
......
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