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