tcpip.c (20233) | tcpip.c (20247) |
---|---|
1/* | 1/* |
2 * $Id: tcpip.c,v 1.49 1996/11/07 08:03:29 jkh Exp $ | 2 * $Id: tcpip.c,v 1.50 1996/12/09 06:37:46 jkh Exp $ |
3 * 4 * Copyright (c) 1995 5 * Gary J Palmer. All rights reserved. 6 * Copyright (c) 1996 7 * Jordan K. Hubbard. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 194 unchanged lines hidden (view full) --- 205 wattrset(ds_win, dialog_attr); 206 sprintf(title, " Configuration for Interface %s ", devp->name); 207 mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title); 208 209 /* Initialise vars from previous device values */ 210 if (devp->private) { 211 DevInfo *di = (DevInfo *)devp->private; 212 | 3 * 4 * Copyright (c) 1995 5 * Gary J Palmer. All rights reserved. 6 * Copyright (c) 1996 7 * Jordan K. Hubbard. All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 194 unchanged lines hidden (view full) --- 205 wattrset(ds_win, dialog_attr); 206 sprintf(title, " Configuration for Interface %s ", devp->name); 207 mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title); 208 209 /* Initialise vars from previous device values */ 210 if (devp->private) { 211 DevInfo *di = (DevInfo *)devp->private; 212 |
213 strcpy(ipaddr, di->ipaddr); 214 strcpy(netmask, di->netmask); 215 strcpy(extras, di->extras); | 213 SAFE_STRCPY(ipaddr, di->ipaddr); 214 SAFE_STRCPY(netmask, di->netmask); 215 SAFE_STRCPY(extras, di->extras); |
216 } 217 else { /* See if there are any defaults */ 218 char *cp; 219 220 if (!ipaddr[0]) { 221 if ((cp = variable_get(VAR_IPADDR)) != NULL) | 216 } 217 else { /* See if there are any defaults */ 218 char *cp; 219 220 if (!ipaddr[0]) { 221 if ((cp = variable_get(VAR_IPADDR)) != NULL) |
222 strcpy(ipaddr, cp); | 222 SAFE_STRCPY(ipaddr, cp); |
223 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_IPADDR))) != NULL) | 223 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_IPADDR))) != NULL) |
224 strcpy(ipaddr, cp); | 224 SAFE_STRCPY(ipaddr, cp); |
225 } 226 if (!netmask[0]) { 227 if ((cp = variable_get(VAR_NETMASK)) != NULL) | 225 } 226 if (!netmask[0]) { 227 if ((cp = variable_get(VAR_NETMASK)) != NULL) |
228 strcpy(netmask, cp); | 228 SAFE_STRCPY(netmask, cp); |
229 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_NETMASK))) != NULL) | 229 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_NETMASK))) != NULL) |
230 strcpy(netmask, cp); | 230 SAFE_STRCPY(netmask, cp); |
231 } 232 if (!extras[0]) { 233 if ((cp = variable_get(VAR_EXTRAS)) != NULL) | 231 } 232 if (!extras[0]) { 233 if ((cp = variable_get(VAR_EXTRAS)) != NULL) |
234 strcpy(extras, cp); | 234 SAFE_STRCPY(extras, cp); |
235 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_EXTRAS))) != NULL) | 235 else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_EXTRAS))) != NULL) |
236 strcpy(extras, cp); | 236 SAFE_STRCPY(extras, cp); |
237 } 238 } 239 /* Look up values already recorded with the system, or blank the string variables ready to accept some new data */ 240 tmp = variable_get(VAR_HOSTNAME); 241 if (tmp) | 237 } 238 } 239 /* Look up values already recorded with the system, or blank the string variables ready to accept some new data */ 240 tmp = variable_get(VAR_HOSTNAME); 241 if (tmp) |
242 strcpy(hostname, tmp); | 242 SAFE_STRCPY(hostname, tmp); |
243 else 244 bzero(hostname, sizeof(hostname)); 245 tmp = variable_get(VAR_DOMAINNAME); 246 if (tmp) | 243 else 244 bzero(hostname, sizeof(hostname)); 245 tmp = variable_get(VAR_DOMAINNAME); 246 if (tmp) |
247 strcpy(domainname, tmp); | 247 SAFE_STRCPY(domainname, tmp); |
248 else 249 bzero(domainname, sizeof(domainname)); 250 tmp = variable_get(VAR_GATEWAY); 251 if (tmp) | 248 else 249 bzero(domainname, sizeof(domainname)); 250 tmp = variable_get(VAR_GATEWAY); 251 if (tmp) |
252 strcpy(gateway, tmp); | 252 SAFE_STRCPY(gateway, tmp); |
253 else 254 bzero(gateway, sizeof(gateway)); 255 tmp = variable_get(VAR_NAMESERVER); 256 if (tmp) | 253 else 254 bzero(gateway, sizeof(gateway)); 255 tmp = variable_get(VAR_NAMESERVER); 256 if (tmp) |
257 strcpy(nameserver, tmp); | 257 SAFE_STRCPY(nameserver, tmp); |
258 else 259 bzero(nameserver, sizeof(nameserver)); 260 261 /* Loop over the layout list, create the objects, and add them 262 onto the chain of objects that dialog uses for traversal*/ 263 n = 0; 264#define lt layout[n] 265 while (lt.help != NULL) { --- 43 unchanged lines hidden (view full) --- 309 display_helpline(ds_win, LINES - 1, COLS - 1); 310 311 /* Ask for libdialog to do its stuff */ 312 ret = PollObj(&obj); 313 314 if (n == LAYOUT_HOSTNAME) { 315 /* We are in the Hostname field - calculate the domainname */ 316 if ((tmp = index(hostname, '.')) != NULL) { | 258 else 259 bzero(nameserver, sizeof(nameserver)); 260 261 /* Loop over the layout list, create the objects, and add them 262 onto the chain of objects that dialog uses for traversal*/ 263 n = 0; 264#define lt layout[n] 265 while (lt.help != NULL) { --- 43 unchanged lines hidden (view full) --- 309 display_helpline(ds_win, LINES - 1, COLS - 1); 310 311 /* Ask for libdialog to do its stuff */ 312 ret = PollObj(&obj); 313 314 if (n == LAYOUT_HOSTNAME) { 315 /* We are in the Hostname field - calculate the domainname */ 316 if ((tmp = index(hostname, '.')) != NULL) { |
317 strncpy(domainname, tmp + 1, strlen(tmp + 1)); 318 domainname[strlen(tmp+1)] = '\0'; | 317 sstrncpy(domainname, tmp + 1, strlen(tmp + 1)); |
319 RefreshStringObj(layout[LAYOUT_DOMAINNAME].obj); 320 } 321 } 322 else if (n == LAYOUT_IPADDR) { 323 /* Insert a default value for the netmask, 0xffffff00 is 324 the most appropriate one (entire class C, or subnetted 325 class A/B network). */ 326 if(netmask[0] == '\0') { --- 53 unchanged lines hidden (view full) --- 380 381 /* They tried some key combination we don't support - tell them! */ 382 default: 383 beep(); 384 } 385 386 /* BODGE ALERT! */ 387 if (((tmp = index(hostname, '.')) != NULL) && (strlen(domainname)==0)) { | 318 RefreshStringObj(layout[LAYOUT_DOMAINNAME].obj); 319 } 320 } 321 else if (n == LAYOUT_IPADDR) { 322 /* Insert a default value for the netmask, 0xffffff00 is 323 the most appropriate one (entire class C, or subnetted 324 class A/B network). */ 325 if(netmask[0] == '\0') { --- 53 unchanged lines hidden (view full) --- 379 380 /* They tried some key combination we don't support - tell them! */ 381 default: 382 beep(); 383 } 384 385 /* BODGE ALERT! */ 386 if (((tmp = index(hostname, '.')) != NULL) && (strlen(domainname)==0)) { |
388 strncpy(domainname, tmp + 1, strlen(tmp + 1)); 389 domainname[strlen(tmp+1)] = '\0'; | 387 sstrncpy(domainname, tmp + 1, strlen(tmp + 1)); |
390 RefreshStringObj(layout[1].obj); 391 } 392 } 393 394 /* Clear this crap off the screen */ 395 dialog_clear_norefresh(); 396 use_helpfile(NULL); 397 --- 13 unchanged lines hidden (view full) --- 411 if (gateway[0]) 412 variable_set2(VAR_GATEWAY, gateway); 413 if (nameserver[0]) 414 variable_set2(VAR_NAMESERVER, nameserver); 415 416 if (!devp->private) 417 devp->private = (DevInfo *)safe_malloc(sizeof(DevInfo)); 418 di = devp->private; | 388 RefreshStringObj(layout[1].obj); 389 } 390 } 391 392 /* Clear this crap off the screen */ 393 dialog_clear_norefresh(); 394 use_helpfile(NULL); 395 --- 13 unchanged lines hidden (view full) --- 409 if (gateway[0]) 410 variable_set2(VAR_GATEWAY, gateway); 411 if (nameserver[0]) 412 variable_set2(VAR_NAMESERVER, nameserver); 413 414 if (!devp->private) 415 devp->private = (DevInfo *)safe_malloc(sizeof(DevInfo)); 416 di = devp->private; |
419 strcpy(di->ipaddr, ipaddr); 420 strcpy(di->netmask, netmask); 421 strcpy(di->extras, extras); | 417 SAFE_STRCPY(di->ipaddr, ipaddr); 418 SAFE_STRCPY(di->netmask, netmask); 419 SAFE_STRCPY(di->extras, extras); |
422 423 sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask); 424 sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name); 425 variable_set2(ifn, temp); 426 ifaces = variable_get(VAR_INTERFACES); 427 if (!ifaces) 428 variable_set2(VAR_INTERFACES, ifaces = "lo0"); 429 /* Only add it if it's not there already */ --- 67 unchanged lines hidden --- | 420 421 sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask); 422 sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name); 423 variable_set2(ifn, temp); 424 ifaces = variable_get(VAR_INTERFACES); 425 if (!ifaces) 426 variable_set2(VAR_INTERFACES, ifaces = "lo0"); 427 /* Only add it if it's not there already */ --- 67 unchanged lines hidden --- |