亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? sys-linux.c

?? unix and linux net driver
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* * sys-linux.c - System-dependent procedures for setting up * PPP interfaces on Linux systems * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University.  The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */#include <sys/ioctl.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <sys/errno.h>#include <sys/file.h>#include <sys/stat.h>#include <sys/utsname.h>#include <sys/sysmacros.h>#include <stdio.h>#include <stdlib.h>#include <syslog.h>#include <string.h>#include <time.h>#include <memory.h>#include <utmp.h>#include <mntent.h>#include <signal.h>#include <fcntl.h>#include <ctype.h>#include <termios.h>#include <unistd.h>/* This is in netdevice.h. However, this compile will fail miserably if   you attempt to include netdevice.h because it has so many references   to __memcpy functions which it should not attempt to do. So, since I   really don't use it, but it must be defined, define it now. */#ifndef MAX_ADDR_LEN#define MAX_ADDR_LEN 7#endif#if __GLIBC__ >= 2#include <asm/types.h>		/* glibc 2 conflicts with linux/types.h */#include <net/if.h>#include <net/if_arp.h>#include <net/route.h>#include <netinet/if_ether.h>#else#include <linux/types.h>#include <linux/if.h>#include <linux/if_arp.h>#include <linux/route.h>#include <linux/if_ether.h>#endif#include <netinet/in.h>#include <arpa/inet.h>#include <linux/ppp_defs.h>#include <linux/if_ppp.h>#include "pppd.h"#include "fsm.h"#include "ipcp.h"#include "patchlevel.h"#ifdef IPX_CHANGE#include "ipxcp.h"#if __GLIBC__ >= 2 && \    !(defined(__powerpc__) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 0)#include <netipx/ipx.h>#else#include <linux/ipx.h>#endif#endif /* IPX_CHANGE */#ifdef LOCKLIB#include <sys/locks.h>#endif#ifdef INET6#ifndef _LINUX_IN6_H/* *    This is in linux/include/net/ipv6.h. */struct in6_ifreq {    struct in6_addr ifr6_addr;    __u32 ifr6_prefixlen;    unsigned int ifr6_ifindex;};#endif#define IN6_LLADDR_FROM_EUI64(sin6, eui64) do {			\	memset(&sin6.s6_addr, 0, sizeof(struct in6_addr));	\	sin6.s6_addr16[0] = htons(0xfe80); 			\	eui64_copy(eui64, sin6.s6_addr32[2]);			\	} while (0)#endif /* INET6 *//* We can get an EIO error on an ioctl if the modem has hung up */#define ok_error(num) ((num)==EIO)static int tty_disc = N_TTY;	/* The TTY discipline */static int ppp_disc = N_PPP;	/* The PPP discpline */static int initfdflags = -1;	/* Initial file descriptor flags for fd */static int ppp_fd = -1;		/* fd which is set to PPP discipline */static int sock_fd = -1;	/* socket for doing interface ioctls */static int slave_fd = -1;static int master_fd = -1;#ifdef INET6static int sock6_fd = -1;#endif /* INET6 */static int ppp_dev_fd = -1;	/* fd for /dev/ppp (new style driver) */static fd_set in_fds;		/* set of fds that wait_input waits for */static int max_in_fd;		/* highest fd set in in_fds */static int has_proxy_arp       = 0;static int driver_version      = 0;static int driver_modification = 0;static int driver_patch        = 0;static int driver_is_old       = 0;static int restore_term        = 0;	/* 1 => we've munged the terminal */static struct termios inittermios;	/* Initial TTY termios */static int new_style_driver = 0;static char loop_name[20];static unsigned char inbuf[512]; /* buffer for chars read from loopback */static int	if_is_up;	/* Interface has been marked up */static u_int32_t default_route_gateway;	/* Gateway for default route added */static u_int32_t proxy_arp_addr;	/* Addr for proxy arp entry added */static char proxy_arp_dev[16];		/* Device for proxy arp entry */static u_int32_t our_old_addr;		/* for detecting address changes */static int	dynaddr_set;		/* 1 if ip_dynaddr set */static int	looped;			/* 1 if using loop */static struct utsname utsname;	/* for the kernel version */static int kernel_version;#define KVERSION(j,n,p)	((j)*1000000 + (n)*1000 + (p))#define MAX_IFS		100#define FLAGS_GOOD (IFF_UP          | IFF_BROADCAST)#define FLAGS_MASK (IFF_UP          | IFF_BROADCAST | \		    IFF_POINTOPOINT | IFF_LOOPBACK  | IFF_NOARP)#define SIN_ADDR(x)	(((struct sockaddr_in *) (&(x)))->sin_addr.s_addr)/* Prototypes for procedures local to this file. */static int get_flags (int fd);static void set_flags (int fd, int flags);static int translate_speed (int bps);static int baud_rate_of (int speed);static void close_route_table (void);static int open_route_table (void);static int read_route_table (struct rtentry *rt);static int defaultroute_exists (struct rtentry *rt);static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr,			   char *name, int namelen);static void decode_version (char *buf, int *version, int *mod, int *patch);static int set_kdebugflag(int level);static int ppp_registered(void);extern u_char	inpacket_buf[];	/* borrowed from main.c *//* * SET_SA_FAMILY - set the sa_family field of a struct sockaddr, * if it exists. */#define SET_SA_FAMILY(addr, family)			\    memset ((char *) &(addr), '\0', sizeof(addr));	\    addr.sa_family = (family);/* * Determine if the PPP connection should still be present. */extern int hungup;/* new_fd is the fd of a tty */static void set_ppp_fd (int new_fd){	SYSDEBUG ((LOG_DEBUG, "setting ppp_fd to %d\n", new_fd));	ppp_fd = new_fd;	if (!new_style_driver)		ppp_dev_fd = new_fd;}static int still_ppp(void){	if (new_style_driver)		return !hungup && ppp_fd >= 0;	if (!hungup || ppp_fd == slave_fd)		return 1;	if (slave_fd >= 0) {		set_ppp_fd(slave_fd);		return 1;	}	return 0;}/******************************************************************** * * Functions to read and set the flags value in the device driver */static int get_flags (int fd){        int flags;    if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &flags) < 0) {	if ( ok_error (errno) )	    flags = 0;	else	    fatal("ioctl(PPPIOCGFLAGS): %m");    }    SYSDEBUG ((LOG_DEBUG, "get flags = %x\n", flags));    return flags;}/********************************************************************/static void set_flags (int fd, int flags){        SYSDEBUG ((LOG_DEBUG, "set flags = %x\n", flags));    if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &flags) < 0) {	if (! ok_error (errno) )	    fatal("ioctl(PPPIOCSFLAGS, %x): %m", flags, errno);    }}/******************************************************************** * * sys_init - System-dependent initialization. */void sys_init(void){    int flags;    openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP);    setlogmask(LOG_UPTO(LOG_INFO));    if (debug)	setlogmask(LOG_UPTO(LOG_DEBUG));    if (new_style_driver) {	ppp_dev_fd = open("/dev/ppp", O_RDWR);	if (ppp_dev_fd < 0)	    fatal("Couldn't open /dev/ppp: %m");	flags = fcntl(ppp_dev_fd, F_GETFL);	if (flags == -1	    || fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1)	    warn("Couldn't set /dev/ppp to nonblock: %m");    }    /* 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)	fatal("Couldn't create IPv6 socket: %m(%d)", errno);#endif    FD_ZERO(&in_fds);    max_in_fd = 0;}/******************************************************************** * * sys_cleanup - restore any system state we modified before exiting: * mark the interface down, delete default route and/or proxy arp entry. * This shouldn't call die() because it's called from die(). */void sys_cleanup(void){/* * Take down the device */    if (if_is_up) {	if_is_up = 0;	sifdown(0);    }/* * Delete any routes through the device. */    if (default_route_gateway != 0)	cifdefaultroute(0, 0, default_route_gateway);    if (has_proxy_arp)	cifproxyarp(0, proxy_arp_addr);}/******************************************************************** * * sys_close - Clean up in a child process before execing. */voidsys_close(void){    if (new_style_driver)	close(ppp_dev_fd);    if (sock_fd >= 0)	close(sock_fd);    if (slave_fd >= 0)	close(slave_fd);    if (master_fd >= 0)	close(master_fd);    closelog();}/******************************************************************** * * set_kdebugflag - Define the debugging level for the kernel */static int set_kdebugflag (int requested_level){    if (ioctl(ppp_dev_fd, PPPIOCSDEBUG, &requested_level) < 0) {	if ( ! ok_error (errno) )	    error("ioctl(PPPIOCSDEBUG): %m");	return (0);    }    SYSDEBUG ((LOG_INFO, "set kernel debugging level to %d",		requested_level));    return (1);}/******************************************************************** * * establish_ppp - Turn the serial port into a ppp interface. */int establish_ppp (int tty_fd){    int x;/* * The current PPP device will be the tty file. */    set_ppp_fd (tty_fd);    if (new_style_driver)	add_fd(tty_fd);/* * Ensure that the tty device is in exclusive mode. */    if (ioctl(tty_fd, TIOCEXCL, 0) < 0) {	if ( ! ok_error ( errno ))	    warn("ioctl(TIOCEXCL): %m");    }/* * Demand mode - prime the old ppp device to relinquish the unit. */    if (!new_style_driver && looped	&& ioctl(slave_fd, PPPIOCXFERUNIT, 0) < 0)	fatal("ioctl(transfer ppp unit): %m(%d)", errno);/* * Set the current tty to the PPP discpline */#ifndef N_SYNC_PPP#define N_SYNC_PPP 14#endif    if (new_style_driver)	    ppp_disc = sync_serial ? N_SYNC_PPP:N_PPP;    if (ioctl(tty_fd, TIOCSETD, &ppp_disc) < 0) {	if ( ! ok_error (errno) )	    fatal("ioctl(TIOCSETD): %m(%d)", errno);    }/* * Find out which interface we were given. */    if (new_style_driver) {	if (!looped) {	    /* allocate ourselves a ppp unit */	    ifunit = -1;	    if (ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit) < 0)		fatal("Couldn't create new ppp unit: %m");	    set_kdebugflag(kdebugflag);	} else {	    set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) & ~SC_LOOP_TRAFFIC);	}	if (ioctl(tty_fd, PPPIOCATTACH, &ifunit) < 0) {	    if (errno == EIO)		return -1;	    fatal("Couldn't attach tty to PPP unit %d: %m", ifunit);	}    } else {	if (ioctl(tty_fd, PPPIOCGUNIT, &x) < 0) {		    if ( ! ok_error (errno))		fatal("ioctl(PPPIOCGUNIT): %m(%d)", errno);	}	/* Check that we got the same unit again. */	if (looped && x != ifunit)	    fatal("transfer_ppp failed: wanted unit %d, got %d", ifunit, x);	ifunit = x;    }/* * Enable debug in the driver if requested. */    if (!looped)	set_kdebugflag (kdebugflag);    looped = 0;    set_flags(tty_fd, get_flags(tty_fd) & ~(SC_RCV_B7_0 | SC_RCV_B7_1 |					    SC_RCV_EVNP | SC_RCV_ODDP));    SYSDEBUG ((LOG_NOTICE, "Using version %d.%d.%d of PPP driver",	    driver_version, driver_modification, driver_patch));/* * Fetch the initial file flags and reset blocking mode on the file. */    initfdflags = fcntl(tty_fd, F_GETFL);    if (initfdflags == -1 ||	fcntl(tty_fd, F_SETFL, initfdflags | O_NONBLOCK) == -1) {	if ( ! ok_error (errno))	    warn("Couldn't set device to non-blocking mode: %m");    }    return ppp_dev_fd;}/******************************************************************** * * disestablish_ppp - Restore the serial port to normal operation. * This shouldn't call die() because it's called from die(). */void disestablish_ppp(int tty_fd){    if (new_style_driver)	remove_fd(tty_fd);    if (!hungup) {/* * Flush the tty output buffer so that the TIOCSETD doesn't hang. */	if (tcflush(tty_fd, TCIOFLUSH) < 0)	    warn("tcflush failed: %m");/* * Restore the previous line discipline */	if (ioctl(tty_fd, TIOCSETD, &tty_disc) < 0) {	    if ( ! ok_error (errno))		error("ioctl(TIOCSETD, N_TTY): %m");	}		if (ioctl(tty_fd, TIOCNXCL, 0) < 0) {	    if ( ! ok_error (errno))		warn("ioctl(TIOCNXCL): %m(%d)", errno);	}	/* Reset non-blocking mode on fd. */	if (initfdflags != -1 && fcntl(tty_fd, F_SETFL, initfdflags) < 0) {	    if ( ! ok_error (errno))		warn("Couldn't restore device fd flags: %m");	}    }    initfdflags = -1;    if (new_style_driver && !looped) {	if (ioctl(ppp_dev_fd, PPPIOCDETACH) < 0) {	    if (errno == ENOTTY) {		/* first version of new driver didn't have PPPIOCDETACH */		int flags;		close(ppp_dev_fd);		ppp_dev_fd = open("/dev/ppp", O_RDWR);		if (ppp_dev_fd < 0)		    fatal("Couldn't reopen /dev/ppp: %m");		flags = fcntl(ppp_dev_fd, F_GETFL);		if (flags == -1		    || fcntl(ppp_dev_fd, F_SETFL, flags | O_NONBLOCK) == -1)		    warn("Couldn't set /dev/ppp to nonblock: %m");	    } else		error("Couldn't release PPP unit: %m");	}	set_ppp_fd(-1);    }}/********************************************************************

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩亚洲电影在线| 亚洲午夜免费电影| 欧美成人精品1314www| 欧美中文字幕一区| 99精品久久免费看蜜臀剧情介绍| 久久精品国产一区二区三| 亚洲一区二区三区不卡国产欧美 | 久久综合av免费| 欧美精品一级二级| 国产成都精品91一区二区三| 国产高清久久久久| 国产精品18久久久久久久久| 久久成人羞羞网站| 美女www一区二区| 日韩电影在线看| 午夜久久久久久久久| 久久综合狠狠综合久久激情| 久久亚洲一级片| 久久综合久久综合久久综合| 久久亚洲精品国产精品紫薇| 精品处破学生在线二十三| 日韩网站在线看片你懂的| 欧美一区二区三区四区久久| 日韩欧美的一区二区| 精品国产sm最大网站免费看| 欧美大胆一级视频| 精品国产乱码久久久久久免费| 日韩欧美在线123| 2020国产成人综合网| 久久日韩精品一区二区五区| 欧美一区二区三区四区久久| 日韩欧美高清dvd碟片| 欧美一区二区在线视频| 中文字幕在线一区二区三区| 中文字幕二三区不卡| 制服丝袜一区二区三区| 91浏览器打开| 6080午夜不卡| 国产偷国产偷亚洲高清人白洁| 国产精品久久久久久久久果冻传媒| 伊人色综合久久天天| 亚洲成人久久影院| 国产一区二区三区香蕉| 97成人超碰视| 8x8x8国产精品| 欧美经典一区二区三区| 亚洲午夜久久久久久久久电影网| 日本vs亚洲vs韩国一区三区二区| 成人爽a毛片一区二区免费| 欧美在线free| 久久久久久久久岛国免费| 亚洲人成网站色在线观看| 美国精品在线观看| 色悠久久久久综合欧美99| 精品国产一区二区三区av性色| 亚洲欧美在线另类| 久久精品国产第一区二区三区| 99久久精品一区| 日韩一区二区电影在线| 亚洲四区在线观看| 久久99精品久久久久久动态图| 91免费视频网址| 精品久久久久久久久久久久久久久| 亚洲素人一区二区| 韩国成人在线视频| 欧美精品在线一区二区| 亚洲女子a中天字幕| 国产一区二区在线视频| 欧美精品一二三四| 一区二区三区不卡视频在线观看| 国产黄色成人av| 日韩视频在线你懂得| 伊人婷婷欧美激情| 不卡的av在线播放| 久久久久久久久久久电影| 日韩激情在线观看| 欧美在线free| 亚洲天堂2014| av在线播放成人| 国产婷婷色一区二区三区四区 | 亚洲成精国产精品女| 成人免费毛片aaaaa**| 欧美大片一区二区| 日产国产欧美视频一区精品| 欧美在线观看18| 亚洲免费资源在线播放| av激情综合网| 国产欧美日韩在线视频| 激情六月婷婷综合| 欧美不卡一二三| 日本伊人午夜精品| 欧美精品九九99久久| 午夜不卡在线视频| 欧美区一区二区三区| 亚洲一区二区三区国产| 欧美视频在线一区二区三区| 亚洲美女一区二区三区| 色偷偷一区二区三区| 亚洲视频一区二区在线| 国产成人午夜精品影院观看视频| 精品国产乱码久久久久久久| 看片的网站亚洲| 2024国产精品| 国产一区二区三区免费在线观看| 欧美一二三四区在线| 伦理电影国产精品| 精品91自产拍在线观看一区| 精品一区二区三区欧美| 26uuu国产日韩综合| 久久99精品久久久| 久久综合国产精品| 丁香天五香天堂综合| 国产精品国产三级国产普通话三级| 成年人网站91| 日韩码欧中文字| 欧美三级电影一区| 日韩成人一区二区三区在线观看| 91精品欧美一区二区三区综合在| 男女男精品视频网| 精品成人一区二区三区四区| 国产.精品.日韩.另类.中文.在线.播放| 国产日韩v精品一区二区| www.欧美色图| 亚洲午夜羞羞片| 4438成人网| 国产在线精品不卡| 中文字幕亚洲一区二区va在线| 99麻豆久久久国产精品免费| 一区二区三区在线视频免费| 欧美高清一级片在线| 久久国产生活片100| 国产色爱av资源综合区| 91视频免费看| 日韩电影在线免费看| 国产日韩欧美不卡| 欧美自拍偷拍午夜视频| 久久99久久精品欧美| 国产精品国产馆在线真实露脸| 欧洲一区在线电影| 久久av资源网| 亚洲女同ⅹxx女同tv| 91麻豆精品国产91久久久久久久久 | 一区二区三区成人在线视频| 欧美一区二区三区婷婷月色| 国产98色在线|日韩| 亚洲在线观看免费| 精品国产一二三区| 一本色道久久综合精品竹菊| 免费高清成人在线| 国产精品久久久一本精品| 欧美日韩高清在线播放| 国产美女视频一区| 亚洲一二三四区| 久久久精品综合| 欧美高清视频一二三区 | 不卡欧美aaaaa| 日本成人在线电影网| 国产精品少妇自拍| 日韩一卡二卡三卡四卡| 波多野结衣欧美| 久久97超碰国产精品超碰| 亚洲视频香蕉人妖| 精品国产一区二区三区四区四| 91麻豆自制传媒国产之光| 久99久精品视频免费观看| 亚洲精品国产第一综合99久久| 久久免费精品国产久精品久久久久| 色欧美日韩亚洲| 国产精品一区免费视频| 天天影视网天天综合色在线播放| 亚洲国产精品黑人久久久| 6080yy午夜一二三区久久| 91天堂素人约啪| 国内欧美视频一区二区| 亚洲高清久久久| 亚洲欧美日韩精品久久久久| 2020国产精品| 日韩欧美一区二区免费| 91激情五月电影| 国产成人小视频| 国产一区视频导航| 日韩国产欧美三级| 一区二区三区四区乱视频| 国产精品色哟哟网站| 久久一区二区视频| 日韩精品一区二区三区在线观看| 欧美日韩在线免费视频| 色综合天天在线| 成人性色生活片免费看爆迷你毛片| 久久精品99国产国产精| 日本美女一区二区三区视频| 亚洲一级片在线观看| 亚洲综合自拍偷拍| 亚洲视频中文字幕| 国产精品久99| 中文字幕一区二区三区色视频| 国产日韩欧美精品在线| 国产三级欧美三级日产三级99 | 一区二区三区加勒比av| 国产精品美女视频|