mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-25 16:44:04 +00:00
removed some useless Linux calls
This commit is contained in:
parent
26e8372c75
commit
8bb4ea85b8
@ -389,11 +389,6 @@ int ppp_oldmain() {
|
|||||||
argv[0]);
|
argv[0]);
|
||||||
exit(EXIT_NOT_ROOT);
|
exit(EXIT_NOT_ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ppp_available()) {
|
|
||||||
option_error("%s", no_ppp_msg);
|
|
||||||
exit(EXIT_NO_KERNEL_SUPPORT);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PPP_OPTIONS
|
#if PPP_OPTIONS
|
||||||
@ -435,11 +430,6 @@ int ppp_oldmain() {
|
|||||||
fd_devnull = i;
|
fd_devnull = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize system-dependent stuff.
|
|
||||||
*/
|
|
||||||
linux_sys_init();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Detach ourselves from the terminal, if required,
|
* Detach ourselves from the terminal, if required,
|
||||||
* and identify who is running us.
|
* and identify who is running us.
|
||||||
@ -454,7 +444,7 @@ int ppp_oldmain() {
|
|||||||
else
|
else
|
||||||
p = "(unknown)";
|
p = "(unknown)";
|
||||||
}
|
}
|
||||||
syslog(LOG_NOTICE, "pppd %s started by %s, uid %d", VERSION, p, uid);
|
syslog(LOG_NOTICE, "pppd started by %s, uid %d", p, uid);
|
||||||
script_setenv("PPPLOGNAME", p, 0);
|
script_setenv("PPPLOGNAME", p, 0);
|
||||||
|
|
||||||
if (devnam[0])
|
if (devnam[0])
|
||||||
|
@ -57,7 +57,6 @@
|
|||||||
#include <sys/types.h> /* for u_int32_t, if defined */
|
#include <sys/types.h> /* for u_int32_t, if defined */
|
||||||
#include <sys/time.h> /* for struct timeval */
|
#include <sys/time.h> /* for struct timeval */
|
||||||
#include <net/ppp_defs.h>
|
#include <net/ppp_defs.h>
|
||||||
#include "patchlevel.h"
|
|
||||||
|
|
||||||
#if defined(__STDC__)
|
#if defined(__STDC__)
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -603,11 +602,9 @@ int str_to_epdisc __P((struct epdisc *, char *)); /* endpt disc. from str */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Procedures exported from sys-*.c */
|
/* Procedures exported from sys-*.c */
|
||||||
void sys_init __P((void)); /* Do system-dependent initialization */
|
|
||||||
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
void sys_cleanup __P((void)); /* Restore system state before exiting */
|
||||||
int sys_check_options __P((void)); /* Check options specified */
|
int sys_check_options __P((void)); /* Check options specified */
|
||||||
void sys_close __P((void)); /* Clean up in a child before execing */
|
void sys_close __P((void)); /* Clean up in a child before execing */
|
||||||
int ppp_available __P((void)); /* Test whether ppp kernel support exists */
|
|
||||||
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
int get_pty __P((int *, int *, char *, int)); /* Get pty master/slave */
|
||||||
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
int open_ppp_loopback __P((void)); /* Open loopback for demand-dialling */
|
||||||
int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
int tty_establish_ppp __P((int)); /* Turn serial port into a ppp interface */
|
||||||
|
@ -294,28 +294,6 @@ static int modify_flags(int fd, int clear_bits, int set_bits)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* sys_init - System-dependent initialization.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void linux_sys_init(void)
|
|
||||||
{
|
|
||||||
/* Get an internet socket for doing socket ioctls. */
|
|
||||||
sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (sock_fd < 0)
|
|
||||||
fatal("Couldn't create IP socket: %m(%d)", errno);
|
|
||||||
|
|
||||||
#ifdef INET6
|
|
||||||
sock6_fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
|
||||||
if (sock6_fd < 0)
|
|
||||||
sock6_fd = -errno; /* save errno for later */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FD_ZERO(&in_fds);
|
|
||||||
max_in_fd = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* sys_cleanup - restore any system state we modified before exiting:
|
* sys_cleanup - restore any system state we modified before exiting:
|
||||||
@ -2061,144 +2039,6 @@ ppp_registered(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
*
|
|
||||||
* ppp_available - check whether the system has any ppp interfaces
|
|
||||||
* (in fact we check whether we can do an ioctl on ppp0).
|
|
||||||
*/
|
|
||||||
|
|
||||||
int ppp_available(void)
|
|
||||||
{
|
|
||||||
int s, ok, fd, err;
|
|
||||||
struct ifreq ifr;
|
|
||||||
int size;
|
|
||||||
int my_version, my_modification, my_patch;
|
|
||||||
int osmaj, osmin, ospatch;
|
|
||||||
|
|
||||||
/* get the kernel version now, since we are called before sys_init */
|
|
||||||
uname(&utsname);
|
|
||||||
osmaj = osmin = ospatch = 0;
|
|
||||||
sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch);
|
|
||||||
kernel_version = KVERSION(osmaj, osmin, ospatch);
|
|
||||||
|
|
||||||
fd = open("/dev/ppp", O_RDWR);
|
|
||||||
if (fd >= 0) {
|
|
||||||
new_style_driver = 1;
|
|
||||||
|
|
||||||
/* XXX should get from driver */
|
|
||||||
driver_version = 2;
|
|
||||||
driver_modification = 4;
|
|
||||||
driver_patch = 0;
|
|
||||||
close(fd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
err = errno;
|
|
||||||
|
|
||||||
if (kernel_version >= KVERSION(2,3,13)) {
|
|
||||||
error("Couldn't open the /dev/ppp device: %m");
|
|
||||||
if (errno == ENOENT)
|
|
||||||
no_ppp_msg =
|
|
||||||
"You need to create the /dev/ppp device node by\n"
|
|
||||||
"executing the following command as root:\n"
|
|
||||||
" mknod /dev/ppp c 108 0\n";
|
|
||||||
else if (errno == ENODEV || errno == ENXIO)
|
|
||||||
no_ppp_msg =
|
|
||||||
"Please load the ppp_generic kernel module.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we are running on a really really old kernel */
|
|
||||||
no_ppp_msg =
|
|
||||||
"This system lacks kernel support for PPP. This could be because\n"
|
|
||||||
"the PPP kernel module could not be loaded, or because PPP was not\n"
|
|
||||||
"included in the kernel configuration. If PPP was included as a\n"
|
|
||||||
"module, try `/sbin/modprobe -v ppp'. If that fails, check that\n"
|
|
||||||
"ppp.o exists in /lib/modules/`uname -r`/net.\n"
|
|
||||||
"See README.linux file in the ppp distribution for more details.\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Open a socket for doing the ioctl operations.
|
|
||||||
*/
|
|
||||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (s < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
|
|
||||||
ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
|
|
||||||
/*
|
|
||||||
* If the device did not exist then attempt to create one by putting the
|
|
||||||
* current tty into the PPP discipline. If this works then obtain the
|
|
||||||
* flags for the device again.
|
|
||||||
*/
|
|
||||||
if (!ok) {
|
|
||||||
if (ppp_registered()) {
|
|
||||||
strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
|
|
||||||
ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Ensure that the hardware address is for PPP and not something else
|
|
||||||
*/
|
|
||||||
if (ok)
|
|
||||||
ok = ioctl (s, SIOCGIFHWADDR, (caddr_t) &ifr) >= 0;
|
|
||||||
|
|
||||||
if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
|
|
||||||
ok = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the PPP device. Validate the version of the driver at this
|
|
||||||
* point to ensure that this program will work with the driver.
|
|
||||||
*/
|
|
||||||
if (ok) {
|
|
||||||
char abBuffer [1024];
|
|
||||||
|
|
||||||
ifr.ifr_data = abBuffer;
|
|
||||||
size = ioctl (s, SIOCGPPPVER, (caddr_t) &ifr);
|
|
||||||
if (size < 0) {
|
|
||||||
error("Couldn't read driver version: %m");
|
|
||||||
ok = 0;
|
|
||||||
no_ppp_msg = "Sorry, couldn't verify kernel driver version\n";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
decode_version(abBuffer,
|
|
||||||
&driver_version,
|
|
||||||
&driver_modification,
|
|
||||||
&driver_patch);
|
|
||||||
/*
|
|
||||||
* Validate the version of the driver against the version that we used.
|
|
||||||
*/
|
|
||||||
decode_version(VERSION,
|
|
||||||
&my_version,
|
|
||||||
&my_modification,
|
|
||||||
&my_patch);
|
|
||||||
|
|
||||||
/* The version numbers must match */
|
|
||||||
if (driver_version != my_version)
|
|
||||||
ok = 0;
|
|
||||||
|
|
||||||
/* The modification levels must be legal */
|
|
||||||
if (driver_modification < 3) {
|
|
||||||
if (driver_modification >= 2) {
|
|
||||||
/* we can cope with 2.2.0 and above */
|
|
||||||
driver_is_old = 1;
|
|
||||||
} else {
|
|
||||||
ok = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close (s);
|
|
||||||
if (!ok) {
|
|
||||||
slprintf(route_buffer, sizeof(route_buffer),
|
|
||||||
"Sorry - PPP driver version %d.%d.%d is out of date\n",
|
|
||||||
driver_version, driver_modification, driver_patch);
|
|
||||||
|
|
||||||
no_ppp_msg = route_buffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
*
|
*
|
||||||
* Update the wtmp file with the appropriate user name and tty device.
|
* Update the wtmp file with the appropriate user name and tty device.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user