aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ggsn/ggsn.c19
-rw-r--r--sgsnemu/sgsnemu.c11
2 files changed, 22 insertions, 8 deletions
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 75a76a4..a9d7e4f 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -329,12 +329,21 @@ int main(int argc, char **argv)
/* DNS1 and DNS2 */
dns1.s_addr = 0;
- if (args_info.pcodns1_arg)
- inet_aton(args_info.pcodns1_arg, &dns1);
-
+ if (args_info.pcodns1_arg) {
+ if (0 >= inet_pton(AF_INET, args_info.pcodns1_arg, &dns1)) {
+ sys_err(LOG_ERR, __FILE__, __LINE__, 0,
+ "Failed to convert pcodns1!");
+ exit(1);
+ }
+ }
dns2.s_addr = 0;
- if (args_info.pcodns2_arg)
- inet_aton(args_info.pcodns2_arg, &dns2);
+ if (args_info.pcodns2_arg) {
+ if (0 >= inet_pton(AF_INET, args_info.pcodns2_arg, &dns2)) {
+ sys_err(LOG_ERR, __FILE__, __LINE__, 0,
+ "Failed to convert pcodns2!");
+ exit(1);
+ }
+ }
pco.l = 20;
pco.v[0] = 0x80; /* x0000yyy x=1, yyy=000: PPP */
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index a224386..9099d3f 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -511,14 +511,19 @@ int process_options(int argc, char **argv) {
options.defaultroute = args_info.defaultroute_flag;
- /* pinghost */
+ /* pinghost */
/* Store ping host as in_addr */
if (args_info.pinghost_arg) {
- if (!inet_aton(args_info.pinghost_arg, &options.pinghost)) {
+ if (!(host = gethostbyname(args_info.pinghost_arg))) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0,
"Invalid ping host: %s!", args_info.pinghost_arg);
return -1;
}
+ else {
+ memcpy(&options.pinghost.s_addr, host->h_addr, host->h_length);
+ printf("Using ping host: %s (%s)\n",
+ args_info.pinghost_arg, inet_ntoa(options.pinghost));
+ }
}
/* Other ping parameters */
@@ -927,7 +932,7 @@ int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) {
if ((options.createif) && (!options.net.s_addr)) {
struct in_addr m;
- inet_aton("255.255.255.255", &m);
+ inet_pton(AF_INET, "255.255.255.255", &m);
/* printf("Setting up interface and routing\n");*/
tun_addaddr(tun, &addr, &addr, &m);
if (options.defaultroute) {