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

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

?? dlpi.c

?? wm PNE 3.3 source code, running at more than vxworks6.x version.
?? C
字號:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/dlpi.c,v 1.2 2001/11/08 15:56:21 tneale Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: dlpi.c,v $ * Revision 1.2  2001/11/08 15:56:21  tneale * Updated for newest file layout * * Revision 1.1.1.1  2001/11/05 17:48:41  tneale * Tornado shuffle * * Revision 2.3  2001/01/19 22:23:40  paul * Update copyright. * * Revision 2.2  2000/03/17 00:12:37  meister * Update copyright message * * Revision 2.1  1998/07/29 20:54:51  wes * First cut of the Solaris port. * (DLPI support, termios, minor tweaks to libraries and port header files) * * Revision 1.1.2.1  1998/07/24 21:45:41  wes * Initial implementation * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*//* * DLPI interface to ethernet for Attache testing under Solaris 2.x * * All access to DLPI should be through this module, the only thing we * expect our caller to do with our file descriptor is use it in * select() calls.  There are enough name conflicts between the unix * networking code and the Attache networking code that it's probably * hopeless to have the two mingled in the same file. * * This was brutally converted from nit.c in a fit of madness. * * References: NIT manual pages *	       tcpdump source *	       CAP ethertalk source *	       netintro(4) manual page *	       NET-2 routed source *	       "How to use DLPI" document from Sun Internet Engineering, dated 30 Jun 1992 *		DLPI specification. */#include <stdio.h>#include <errno.h>#include <string.h>#include <unistd.h>#include <stdlib.h>#include <ctype.h>#include <fcntl.h>#include <sys/param.h>#include <sys/types.h>#include <sys/time.h>#include <sys/timeb.h>#include <sys/socket.h>#include <sys/file.h>#include <sys/ioctl.h>#include <stropts.h>#include <sys/dlpi.h>#include <sys/pfmod.h>#include <sys/sockio.h>#include <netinet/in.h>#include <net/if.h>#define __(x) x#include <wrn/wm/demo/dlpi.h>#ifdef __GNUC__#define	alloca	__builtin_alloca#endif#define MAXDLBUF	8192#define		OFFADDR(s, n)	(u_char*)((char*)(s) + (int)(n))/* * DLPI client stubs. */int dlreqspew (int fd, void *buf, size_t size){  struct strbuf ctl;  ctl.maxlen = 0;  ctl.len = size;  ctl.buf = buf;  return putmsg(fd, &ctl, NULL, 0);}int dlgetack (int fd, int exp_prim, int exp_flags, char *respbuf, int exp_size){  union DL_primitives *dlp;  struct strbuf ctl;  char tmpbuf[MAXDLBUF];  int flags = 0;  if (!respbuf)    respbuf = tmpbuf;    /* XXX do a poll() here to wait for the response.. */  ctl.maxlen = exp_size;  ctl.len = 0;  ctl.buf = respbuf;  if (getmsg(fd, &ctl, NULL, &flags) < 0)    return -4;  dlp = (union DL_primitives *)ctl.buf;  if (dlp->dl_primitive != exp_prim)    return -1;  if (flags != exp_flags)    return -2;  if (ctl.len < exp_size)    return -3;  return 0;}int dlsar (int fd, void *reqbuf, size_t size,	   int exp_prim, int exp_flags, void *respbuf, int exp_size){  /* Flush the read queue, don't worry about it if we can't. */  (void) ioctl(fd, I_FLUSH, (char *) FLUSHR);  if (dlreqspew(fd, reqbuf, size) < 0)    return -1;  return dlgetack(fd, exp_prim, exp_flags, respbuf, exp_size);}int dlattach(int fd, u_long ppa){  dl_attach_req_t	attach_req;  attach_req.dl_primitive = DL_ATTACH_REQ;  attach_req.dl_ppa = ppa;  return dlsar(fd, &attach_req, sizeof(attach_req),	       DL_OK_ACK, RS_HIPRI, NULL, sizeof(dl_ok_ack_t));}int dlbind(int fd, u_long sap, u_long max_conind, u_long service_mode, u_long conn_mgmt, u_long xidtest){  dl_bind_req_t	bind_req;  bind_req.dl_primitive = DL_BIND_REQ;  bind_req.dl_sap = sap;  bind_req.dl_max_conind = max_conind;  bind_req.dl_service_mode = service_mode;  bind_req.dl_conn_mgmt = conn_mgmt;  bind_req.dl_xidtest_flg = xidtest;    return dlsar(fd, &bind_req, sizeof(bind_req),	       DL_BIND_ACK, RS_HIPRI, NULL, sizeof(dl_bind_ack_t));}int dlpromiscon(int fd, int level) {  dl_promiscon_req_t promiscon_req;  promiscon_req.dl_primitive = DL_PROMISCON_REQ;  promiscon_req.dl_level = level;  return dlsar (fd, &promiscon_req, sizeof(promiscon_req),		DL_OK_ACK, RS_HIPRI, NULL, sizeof(dl_ok_ack_t));}int dlphysaddr(int fd, int which, char *phy, int len){  dl_phys_addr_req_t phys_addr_req;  dl_phys_addr_ack_t phys_addr_ack;  int tmp;  union DL_primitives *dlp;    phys_addr_req.dl_primitive = DL_PHYS_ADDR_REQ;  phys_addr_req.dl_addr_type = which;  tmp = dlsar (fd, &phys_addr_req, sizeof(phys_addr_req),	       DL_PHYS_ADDR_ACK, RS_HIPRI, &phys_addr_ack, sizeof(phys_addr_ack));  if (tmp < 0)    return tmp;  dlp=(union DL_primitives *)&phys_addr_ack;  memcpy(phy, OFFADDR(dlp, dlp->physaddr_ack.dl_addr_offset), len);  return 0;  }/* * Open a STREAMS driver for the interface and attach it to the interface named 'device'. * Returns DLPI file descriptor, or -1 if an error occurs. * * Since this implementation uses the same ethernet address as the host * on which it's running, fill in Attache's idea of the MAC address. * * N.B.  the order of calls of the STREAMS primitives here is * evidently fairly subtle and is not covered by existing documentation. * * Looking at known working code (e.g., LBL libpcap) finally allowed * me to get things to work right; based on reading that other code, * it appears that this will require some work on systems other than * Solaris. */int dlpi_open(char *ifname, unsigned mtu, unsigned char *mac){  struct strioctl sioc;    char driver[16];  int fd;  u_long unit;  char *cp;  /*   * parse the unit number out of the ifname..   */  sprintf(driver, "/dev/%s", ifname);  cp = &driver[strlen(driver)];  while(isdigit((int)cp[-1]))	/* XXX int cast to quiet gcc  */    --cp;  unit = atoi(cp);  *cp = '\0';    /*   * Look for cloned link-layer driver..   */  if ((fd = open(driver, O_RDWR)) < 0) {    perror("couldn't clone DLPI device");    return -1;  }  if (dlattach(fd, unit) < 0) {    perror("couldn't attach dlpi unit\n");    return -1;  }  /*   * Enable discrete messages.   */  if (ioctl(fd, I_SRDOPT, (char *) RMSGD) < 0) {    perror("couldn't enable discrete DLPI messages");    return -1;  }  /*   * Don't bother with buffering, or truncation for now.   */  /*   * Put the interface into promiscuous mode so that we'll see packets   * to our faked MAC address..   */  if (dlpromiscon(fd, DL_PROMISC_PHYS) < 0) {    perror("dlpi: failed to set promisc PHYS mode\n");  }    /*   * Get all SAP's (this apparently needs to happen *after* setting   * the lower-level promiscuous mode   */  if (dlpromiscon(fd, DL_PROMISC_SAP) < 0)    perror("dlpi: failed to set promisc SAP mode");  /*   * We bind last since comments in libpcap suggest that this is most portable.   */  if (dlbind(fd, 0, 0, DL_CLDLS, 0, 0) < 0) {    perror("couldn't dlbind\n");  }  /* Set raw mode.  if this fails, we *should* blow up since the protocol's different.. */  sioc.ic_cmd = DLIOCRAW;  sioc.ic_timout = -1;  sioc.ic_len = 0;  sioc.ic_dp = 0;  if (ioctl(fd, I_STR, &sioc) < 0) {    perror("couldn't set RAW mode, continuing..\n");  }  /*   * Push packet filter module.   */  if (ioctl(fd, I_PUSH, "pfmod") < 0) {    perror("couldn't push packet filter STREAMS module, continuing..");  } else {    struct packetfilt pfil;    u_short *pfp = &pfil.Pf_Filter[0];    /*     * Yum. Interpreted LIW code, the result of several hours of mental pain.     * This *might* be an optimal instruction schedule.     *     * Whoever named the ENF_C{N,}{AND,OR} ops was.. confused...     * But, well...     */        *pfp++ = ENF_PUSHLIT;					        *pfp++ = 0x0100;				/* multicast bit */    *pfp++ = (ENF_PUSHWORD+0) | ENF_AND;	/* mask with first word of mac */    *pfp++ = ENF_PUSHZERO | ENF_CNAND;		/* succeed if nonzero */        *pfp++ = ENF_PUSHLIT;    *pfp++ = ntohs(*(u_short *)mac);		/* first word of mac */    *pfp++ = (ENF_PUSHWORD+0) | ENF_CAND;	/* fail if not equal */    *pfp++ = ENF_PUSHLIT;    *pfp++ = ntohs(*(u_short *)(mac+2));	/* second word of mac */    *pfp++ = (ENF_PUSHWORD+1) | ENF_CAND;       /* fail if not equal */    *pfp++ = ENF_PUSHLIT;    *pfp++ = ntohs(*(u_short *)(mac+4));	/* third word  of mac */    *pfp++ = (ENF_PUSHWORD+2) | ENF_EQ;		/* succeed if equal.. */        pfil.Pf_Priority = 0;    pfil.Pf_FilterLen = pfp - &pfil.Pf_Filter[0];    sioc.ic_cmd = PFIOCSETF;    sioc.ic_timout = -1;    sioc.ic_len = sizeof(pfil);    sioc.ic_dp = (void *)&pfil;    if (ioctl(fd, I_STR, &sioc) < 0) {      perror("couldn't set packet filter, continuing..");    }  }  /* As last action, flush the read queue.. */  (void) ioctl(fd, I_FLUSH, (char *) FLUSHR);    return fd;}/* * Read a DLPI buffer and hand its contents off to Attache as packets. * This is based on the readloop() function in tcpdump's BPF code and * on the dlpi(4) manual page. * * The handler routine supplied by the Attache-side code gets three * arguments: a pointer to the packet data, the length of the packet * data, and the length that the real packet was on the wire. * * There's probably nothing useful that Attache can do with a truncated * packet, but the info is there, so we may as well pass it along. */int dlpi_read  (int fd,   unsigned mtu,   void (*handler)(unsigned char *, unsigned, unsigned, void *),   void *cookie){  unsigned char *buf;  int i, flags;  struct strbuf data;    if ((buf = (unsigned char *) alloca(mtu)) == 0) {    fprintf(stderr, "alloca(%d) failed\n", mtu);    return -1;  }  data.buf = buf;  data.maxlen = mtu;  data.len = 0;  /*   * Try to read a packet, restart if we get screwed by the debugger.   * Return on other error or on EOF.   */  flags = 0;  do {    i = getmsg(fd, NULL, &data, &flags);  } while (i < 0 && errno == EINTR);  if (i>=0)    i=data.len;    if (i <= 0)    return i;  /*   * In theory, since we've got the stream in discrete message mode,   * we can just assume that we got one packet.   */  handler(buf, i, i, cookie);  return 1;}/* * Write a packet to the DLPI stream. */int dlpi_write(int fd, unsigned char *data, unsigned datalen){  struct strbuf dbuf;  dbuf.buf = data;  dbuf.len = datalen;  dbuf.maxlen = 0;  return putmsg(fd, 0, &dbuf, 0) < 0 ? -1 : datalen;}/* * Close a DLPI interface. */void dlpi_close(int fd){  (void) close(fd);}#if defined(SIOCGIFCONF)/* * Find all ethernet interfaces.  This is a simplified version of the * code that works on NetBSD, I dunno yet whether this will work on SunOS. */void dlpi_find(void (*handler)(char *, void *), void *cookie){  char buffer[5000];  struct ifconf ifc;  struct ifreq *ifr;  int s;  if (!handler)    return;  if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {    perror("socket");    return;  }  /* shut up purify whining about uninit memory.. */  memset(buffer, 0, sizeof(buffer));  ifc.ifc_len = sizeof(buffer);  ifc.ifc_buf = buffer;  if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {    perror("ioctl");    (void) close(s);    return;  }  for (ifr = ifc.ifc_req; ((char *) ifr) < ifc.ifc_buf + ifc.ifc_len; ++ifr) {    handler(ifr->ifr_name, cookie);  }    (void) close(s);}#endif /* defined(SIOCGIFCONF) */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情一区二区三区不卡| 欧美日韩国产精品自在自线| 久久影院午夜论| 裸体健美xxxx欧美裸体表演| 91精品国产综合久久久蜜臀粉嫩 | 91精品国产福利在线观看| 亚洲一区二区三区在线| 欧美日韩在线观看一区二区| 日韩精品一区第一页| 日韩西西人体444www| 极品美女销魂一区二区三区免费| 久久免费午夜影院| 成人av网站在线观看免费| 亚洲欧美二区三区| 欧美日韩国产综合久久 | 欧美日韩另类一区| 美腿丝袜亚洲色图| 国产欧美一区二区精品久导航 | 亚洲欧美日韩久久| 欧美日韩国产高清一区| 麻豆成人免费电影| 中文字幕不卡的av| 色哟哟在线观看一区二区三区| 亚洲电影激情视频网站| 日韩精品中文字幕在线不卡尤物| 国产夫妻精品视频| 亚洲午夜三级在线| 久久久精品免费免费| 欧美亚洲一区三区| 麻豆91在线播放免费| 日韩美女精品在线| 欧美成人一区二区三区| jizzjizzjizz欧美| 免费看精品久久片| 亚洲婷婷综合久久一本伊一区| 在线播放视频一区| 成人高清免费观看| 蜜桃视频第一区免费观看| 国产精品免费免费| 日韩欧美一区在线| 色av一区二区| 国产美女在线精品| 午夜伦欧美伦电影理论片| 中文字幕不卡在线播放| 日韩欧美国产综合| 在线精品视频免费观看| 国产成人三级在线观看| 日韩av不卡一区二区| 中文字幕在线观看不卡| 精品久久免费看| 欧美精三区欧美精三区| 91视视频在线观看入口直接观看www | 亚洲成年人影院| 国产精品久久福利| 2020国产精品自拍| 7777精品伊人久久久大香线蕉的 | 中文字幕亚洲区| 久久久久久久久久久久久久久99 | 天堂久久久久va久久久久| 国产欧美日韩精品一区| 精品成人在线观看| 欧美日韩国产影片| 色天天综合色天天久久| 成人综合激情网| 国产精品一二三区在线| 五月天激情综合网| 亚洲尤物在线视频观看| 亚洲特级片在线| 国产精品久久免费看| 国产亚洲综合色| 久久久亚洲午夜电影| 精品免费日韩av| 日韩一区二区三区电影在线观看| 欧美日韩午夜在线视频| 在线观看不卡视频| 91久久线看在观草草青青| 99久久伊人网影院| www.视频一区| 99精品国产视频| 99国产精品久| 色999日韩国产欧美一区二区| www.在线成人| zzijzzij亚洲日本少妇熟睡| 成人久久视频在线观看| 成人黄页在线观看| 99精品在线免费| 色欧美日韩亚洲| 欧美专区在线观看一区| 欧美日韩精品一区二区天天拍小说 | 国产目拍亚洲精品99久久精品| 久久毛片高清国产| 国产喷白浆一区二区三区| 日本一区二区动态图| 国产精品国产三级国产普通话99| 国产精品久线在线观看| 亚洲精品伦理在线| 亚洲va中文字幕| 蜜桃av一区二区| 国产成人免费视频| 99riav一区二区三区| 欧美在线影院一区二区| 91精品国产一区二区人妖| 精品粉嫩aⅴ一区二区三区四区| 国产亚洲成aⅴ人片在线观看 | 欧美一区二区三区影视| www精品美女久久久tv| 中文一区一区三区高中清不卡| 国产精品夫妻自拍| 午夜精品久久久久久久| 国内精品国产成人国产三级粉色 | av在线这里只有精品| 欧美图区在线视频| 88在线观看91蜜桃国自产| 久久美女高清视频| 一区二区三区精品视频| 激情综合亚洲精品| 色婷婷国产精品久久包臀| 欧美精品tushy高清| 久久精品在线免费观看| 亚洲伊人色欲综合网| 久久国产视频网| 色爱区综合激月婷婷| 精品久久久久99| 亚洲伊人伊色伊影伊综合网| 久久精品99久久久| 色综合久久综合| 欧美mv日韩mv亚洲| 亚洲最大成人网4388xx| 韩日av一区二区| 欧美日韩专区在线| 欧美激情综合五月色丁香小说| 亚洲国产成人av| av电影在线观看一区| 欧美一区二区三区成人| 亚洲精选一二三| 国产精品一二一区| 欧美精品123区| 亚洲精品国产a久久久久久| 国产一区二区在线视频| 欧美精品久久久久久久多人混战 | 欧美久久一区二区| 国产精品美女www爽爽爽| 日本在线播放一区二区三区| 91在线精品秘密一区二区| 久久蜜桃一区二区| 日本美女一区二区三区| 欧美色图一区二区三区| 国产精品入口麻豆原神| 精品一区二区三区在线播放视频| 欧美精品久久天天躁| 亚洲日本韩国一区| 国产乱人伦精品一区二区在线观看 | 久久99精品网久久| 欧美视频一区二区三区| 亚洲另类在线一区| 丁香激情综合五月| 精品第一国产综合精品aⅴ| 日本视频一区二区| 欧美精品一卡两卡| 五月激情六月综合| 91传媒视频在线播放| 亚洲免费在线观看| 99久久精品国产一区二区三区| 国产色一区二区| 国产91对白在线观看九色| 久久久国产午夜精品| 国产一区不卡在线| 久久九九99视频| 国产成人在线网站| 国产欧美一区在线| 国产 欧美在线| 欧美国产一区视频在线观看| 高清不卡一区二区在线| 国产精品色在线观看| 国产成人精品亚洲777人妖| 国产亚洲欧美日韩日本| 成人午夜av影视| 亚洲天堂成人网| 色视频欧美一区二区三区| 一区二区三区在线视频免费观看| 一本到不卡精品视频在线观看| 亚洲一区二区三区四区在线| 欧美日韩一区不卡| 蜜桃av一区二区在线观看| 久久久影视传媒| 99久久精品免费看国产免费软件| 亚洲伦理在线免费看| 精品视频全国免费看| 蜜臀精品一区二区三区在线观看| 日韩精品一区二区三区在线| 国产综合久久久久影院| 欧美国产激情二区三区| 色噜噜狠狠色综合欧洲selulu| 亚洲bt欧美bt精品777| 日韩一级片在线播放| 国产精品888| 一区二区三区欧美亚洲| 日韩一区二区三| 国产91对白在线观看九色| 亚洲国产精品一区二区www在线|