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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sys-linux.c

?? 經典的ppp程序
?? 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"#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 PPP_FILTER#include <net/bpf.h>#include <linux/filter.h>#endif /* PPP_FILTER */#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 int chindex;		/* channel index (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 int	link_mtu;		/* mtu for the link (not bundle) */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);static int make_ppp_unit(void);static void restore_loop(void);	/* Transfer ppp unit back to loopback */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;    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)	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: * 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 (new_style_driver && ifunit < 0)	return 1;    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);}/******************************************************************** * * tty_establish_ppp - Turn the serial port into a ppp interface. */int tty_establish_ppp (int tty_fd){    int x;    int fd = -1;/* * Ensure that the tty device is in exclusive mode. */    if (ioctl(tty_fd, TIOCEXCL, 0) < 0) {	if ( ! ok_error ( errno ))	    warn("Couldn't make tty exclusive: %m");    }/* * Demand mode - prime the old ppp device to relinquish the unit. */    if (!new_style_driver && looped	&& ioctl(slave_fd, PPPIOCXFERUNIT, 0) < 0) {	error("ioctl(transfer ppp unit): %m");	return -1;    }/* * Set the current tty to the PPP discpline */#ifndef N_SYNC_PPP#define N_SYNC_PPP 14#endif    ppp_disc = (new_style_driver && sync_serial)? N_SYNC_PPP: N_PPP;    if (ioctl(tty_fd, TIOCSETD, &ppp_disc) < 0) {	if ( ! ok_error (errno) ) {	    error("Couldn't set tty to PPP discipline: %m");	    return -1;	}    }    if (new_style_driver) {	/* Open another instance of /dev/ppp and connect the channel to it */	int flags;	if (ioctl(tty_fd, PPPIOCGCHAN, &chindex) == -1) {	    error("Couldn't get channel number: %m");	    goto err;	}	dbglog("using channel %d", chindex);	fd = open("/dev/ppp", O_RDWR);	if (fd < 0) {	    error("Couldn't reopen /dev/ppp: %m");	    goto err;	}	if (ioctl(fd, PPPIOCATTCHAN, &chindex) < 0) {	    error("Couldn't attach to channel %d: %m", chindex);	    goto err_close;	}	flags = fcntl(fd, F_GETFL);	if (flags == -1 || fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)	    warn("Couldn't set /dev/ppp (channel) to nonblock: %m");	set_ppp_fd(fd);	if (!looped)	    ifunit = -1;	if (!looped && !multilink) {	    /*	     * Create a new PPP unit.	     */	    if (make_ppp_unit() < 0)		goto err_close;	}	if (looped)	    set_flags(ppp_dev_fd, get_flags(ppp_dev_fd) & ~SC_LOOP_TRAFFIC);	if (!multilink) {	    add_fd(ppp_dev_fd);	    if (ioctl(fd, PPPIOCCONNECT, &ifunit) < 0) {		error("Couldn't attach to PPP unit %d: %m", ifunit);		goto err_close;	    }	}    } else {	/*	 * Old-style driver: find out which interface we were given.	 */	set_ppp_fd (tty_fd);	if (ioctl(tty_fd, PPPIOCGUNIT, &x) < 0) {		    if (ok_error (errno))		goto err;	    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;	/*	 * 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");	}    }    looped = 0;    /*     * Enable debug in the driver if requested.     */    if (!looped)	set_kdebugflag (kdebugflag);#define SC_RCVB	(SC_RCV_B7_0 | SC_RCV_B7_1 | SC_RCV_EVNP | SC_RCV_ODDP)#define SC_LOGB	(SC_DEBUG | SC_LOG_INPKT | SC_LOG_OUTPKT | SC_LOG_RAWIN \		 | SC_LOG_FLUSH)    set_flags(ppp_fd, ((get_flags(ppp_fd) & ~(SC_RCVB | SC_LOGB))		       | ((kdebugflag * SC_DEBUG) & SC_LOGB)));    SYSDEBUG ((LOG_NOTICE, "Using version %d.%d.%d of PPP driver",	    driver_version, driver_modification, driver_patch));    return ppp_fd; err_close:    close(fd); err:    if (ioctl(tty_fd, TIOCSETD, &tty_disc) < 0 && !ok_error(errno))	warn("Couldn't reset tty to normal line discipline: %m");    return -1;}/******************************************************************** * * tty_disestablish_ppp - Restore the serial port to normal operation, * and reconnect the ppp unit to the loopback if in demand mode. * This shouldn't call die() because it's called from die(). */void tty_disestablish_ppp(int tty_fd){    if (demand)	restore_loop();    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");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产99久久6| 一本到三区不卡视频| caoporen国产精品视频| 欧美日韩免费观看一区三区| 欧美激情一区二区三区四区| 麻豆高清免费国产一区| 91福利在线免费观看| 国产精品午夜在线| 激情综合色播激情啊| 欧美日韩国产美女| 专区另类欧美日韩| 国产成人在线网站| 精品噜噜噜噜久久久久久久久试看 | 一本高清dvd不卡在线观看| 久久久久久一级片| 韩国精品免费视频| 欧美一区二区三区在线观看| 一区二区不卡在线播放| 成人黄色网址在线观看| 久久久美女毛片| 久久99精品一区二区三区三区| 欧美日韩一区在线观看| 一区二区三区在线免费视频| 一本大道久久a久久综合婷婷| 中文字幕国产一区| 国产91在线看| 亚洲图片另类小说| 97久久精品人人做人人爽50路 | 欧美一区二区精品在线| 亚洲成av人片观看| 在线观看91精品国产麻豆| 丝袜亚洲另类丝袜在线| 91精品国产综合久久香蕉麻豆| 日本va欧美va欧美va精品| 日韩午夜在线观看视频| 美腿丝袜亚洲综合| 久久综合精品国产一区二区三区| 精久久久久久久久久久| 国产欧美一区二区在线| bt欧美亚洲午夜电影天堂| 玉足女爽爽91| 欧美日韩精品是欧美日韩精品| 五月天丁香久久| 日韩欧美视频一区| 国产酒店精品激情| 亚洲人123区| 欧美日韩不卡一区| 黄色成人免费在线| 成人免费在线视频| 欧美日免费三级在线| 奇米综合一区二区三区精品视频| 亚洲精品在线观看网站| 99久久777色| 丝袜美腿亚洲一区二区图片| 精品美女在线播放| 91丨九色丨尤物| 奇米一区二区三区av| 国产精品人妖ts系列视频| 欧洲精品在线观看| 老司机精品视频在线| 国产精品高潮呻吟久久| 欧美日韩不卡在线| 成人免费福利片| 午夜亚洲国产au精品一区二区| 日韩欧美一区在线观看| 99re热这里只有精品视频| 天堂一区二区在线| 欧美国产在线观看| 欧美日本高清视频在线观看| 国产黑丝在线一区二区三区| 亚洲图片欧美一区| 亚洲国产精品成人久久综合一区| 欧美日韩精品免费观看视频| 国产激情91久久精品导航| 亚洲韩国精品一区| 国产精品久久久久久久久免费相片 | 亚洲国产精品ⅴa在线观看| 欧美日韩黄色影视| 成人免费看视频| 免费成人在线播放| 亚洲精品一二三区| 精品国产制服丝袜高跟| 欧美中文字幕不卡| 成人av在线一区二区| 免费三级欧美电影| 一区二区三区电影在线播| 精品国产成人在线影院| 欧美日韩免费不卡视频一区二区三区| 国产毛片一区二区| 日本在线不卡视频一二三区| 亚洲美女电影在线| 国产女人aaa级久久久级| 欧美精品 日韩| 91国偷自产一区二区使用方法| 国产伦精品一区二区三区免费| 亚洲va国产va欧美va观看| 国产精品成人免费在线| 久久嫩草精品久久久久| 精品美女一区二区三区| 日韩欧美国产麻豆| 67194成人在线观看| 欧美日韩国产一级二级| 欧美性videosxxxxx| 色妞www精品视频| 91最新地址在线播放| 国产不卡视频一区| 国产91富婆露脸刺激对白| 久久国产精品色婷婷| 免费看精品久久片| 美腿丝袜在线亚洲一区| 日韩国产成人精品| 日韩高清在线电影| 美女国产一区二区| 琪琪一区二区三区| 精品中文字幕一区二区| 免费久久99精品国产| 免费成人av在线| 美日韩一区二区| 极品少妇xxxx偷拍精品少妇| 精品一区精品二区高清| 国产在线精品视频| 福利一区二区在线观看| a级高清视频欧美日韩| 99国产欧美另类久久久精品| 91视视频在线直接观看在线看网页在线看| 成人高清视频在线| 一本久久a久久精品亚洲| 色菇凉天天综合网| 91精品国产综合久久国产大片| 日韩亚洲欧美一区二区三区| 精品播放一区二区| 国产精品麻豆一区二区| 一区二区三区 在线观看视频| 亚洲电影一级黄| 极品尤物av久久免费看| 粉嫩13p一区二区三区| 91福利在线看| 欧美v国产在线一区二区三区| 国产人成一区二区三区影院| 亚洲欧美日韩人成在线播放| 日韩精品国产精品| 国产成都精品91一区二区三| 在线观看国产日韩| 精品剧情在线观看| 亚洲免费观看视频| 久久不见久久见免费视频1| 福利91精品一区二区三区| 欧美在线观看一区| www久久精品| 亚洲一区二区不卡免费| 国产精一区二区三区| 欧美在线小视频| 久久综合九色欧美综合狠狠 | 国产精品色在线| 午夜久久久久久久久| 成人精品国产免费网站| 欧美精品v日韩精品v韩国精品v| 久久蜜桃香蕉精品一区二区三区| 一区二区三区四区不卡视频| 久久国产精品99精品国产| 一本到高清视频免费精品| 久久综合久色欧美综合狠狠| 一区二区三区成人| 粉嫩av亚洲一区二区图片| 欧美一区二区三区在线| 亚洲欧美日韩电影| 国产在线精品一区在线观看麻豆| 欧美伊人久久大香线蕉综合69 | 2020国产精品| 亚洲大片精品永久免费| 99久久精品国产导航| 精品美女一区二区| 同产精品九九九| 91老司机福利 在线| 国产精品视频你懂的| 久久国产麻豆精品| 欧美一区二区三区人| 亚洲国产综合色| 色婷婷av一区二区三区软件 | 天堂午夜影视日韩欧美一区二区| 91在线观看视频| 欧美激情综合五月色丁香小说| 蜜桃一区二区三区在线| 欧美精品一二三四| 亚洲成人动漫一区| 在线看日本不卡| 怡红院av一区二区三区| 99久久精品一区二区| 国产精品二三区| 日本大香伊一区二区三区| 美女www一区二区| 欧美久久一二区| 亚洲高清三级视频| 欧美优质美女网站| 亚洲午夜精品在线| 91高清视频免费看| 亚洲精品国产精品乱码不99| 91福利社在线观看| 一区二区视频免费在线观看| 日本伦理一区二区|