⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 339.htm

📁 unix高级编程原吗
💻 HTM
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://apue.dhs.org"><font face="黑体"><big><big>apue</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center">               ● UNIX网络编程                       (BM: clown)                </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p   align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="100" align="center" valign="top"><br><p align="center">[<a href="index.htm">回到开始</a>][<a href="308.htm">上一层</a>][<a href="340.htm">下一篇</a>]
<hr><p align="left"><small>发信人: cloudsky (小四), 信区: Security <br>

标  题: winarp.c <br>

发信站: 武汉白云黄鹤站 (Mon Apr 10 11:56:03 2000), 站内信件 <br>

  <br>

/* <br>

 *  Copyright (c) 1998, 1999 route|daemon9 <route@infonexus.com> <br>

 *  All rights reserved. <br>

 * <br>

 *  Modified to winarps.c 1999 by kay <kay@phreedom.org> <br>

 * <br>

 * Redistribution and use in source and binary forms, with or without <br>

 * modification, are permitted provided that the following conditions <br>

 * are met: <br>

 * 1. Redistributions of source code must retain the above copyright <br>

 *    notice, this list of conditions and the following disclaimer. <br>

 * 2. Redistributions in binary form must reproduce the above copyright <br>

 *    notice, this list of conditions and the following disclaimer in the <br>

 *    documentation and/or other materials provided with the distribution. <br>

 * <br>

 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND <br>

 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE <br>

 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE <br>

 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE <br>



 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL <br>

 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS <br>

 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) <br>

 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT <br>

 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY <br>

 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF <br>

 * SUCH DAMAGE. <br>

 * <br>

 */ <br>

  <br>

#include <libnet.h> <br>

  <br>

u_char enet_src[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; <br>

u_char enet_dst[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; <br>

u_long ip_dst = 0; <br>

  <br>

void send_arp(struct link_int *, u_char *); <br>

  <br>

#if (__linux__) <br>

#define  IPOPT_SECURITY  130 <br>

#endif <br>

  <br>

  <br>

int main(int argc, char *argv[]) <br>

{ <br>

   int c, count = 1; <br>

   char errbuf[256]; <br>

   char *device = NULL; <br>

   char *address = NULL; <br>

   struct link_int *l; <br>

  <br>

   while ((c = getopt(argc, argv, "i:d:c:")) != EOF) { <br>

      switch (c) { <br>

      case 'i': <br>

         device = optarg; <br>

         break; <br>

      case 'd': <br>

         address = optarg; <br>

         ip_dst = name_resolve(address, 0); <br>

         break; <br>

      case 'c': <br>

         count = atoi(optarg); <br>

         break; <br>

      default: <br>

         exit(EXIT_FAILURE); <br>



      } <br>

   } <br>

  <br>

   if (!device) { <br>

      fprintf(stderr, "Specify a device\n"); <br>

      exit(EXIT_FAILURE); <br>

   } <br>

   if (!ip_dst) { <br>

      fprintf(stderr, "Specify destination\n"); <br>

      exit(EXIT_FAILURE); <br>

   } <br>

   if ((l = open_link_interface(device, errbuf)) == NULL) { <br>

      fprintf(stderr, "open_link_interface: %s\n", errbuf); <br>

      exit(EXIT_FAILURE); <br>

   } <br>

   send_arp(l, device); <br>

   exit(EXIT_SUCCESS); <br>

} <br>

  <br>

  <br>

void send_arp(struct link_int *l, u_char * device) <br>

{ <br>

{ <br>

   int n; <br>

   u_char *buf; <br>

  <br>

   buf = (u_char *) malloc(ARP_H + ETH_H); <br>

   if (!buf) { <br>

      perror("no packet memory"); <br>

      exit(EXIT_FAILURE); <br>

   } <br>

   memset(buf, 0, ARP_H + ETH_H); <br>

  <br>

   build_ethernet(enet_dst, enet_src, ETHERTYPE_ARP, NULL, 0, buf); <br>

   build_arp(ARPHRD_ETHER, ETHERTYPE_IP, 6, 4, ARPOP_REQUEST, enet_src, <br>

             (void *)&ip_dst, enet_dst, (void *)&ip_dst, NULL, 0, buf + ETH_H); <br>

   n = write_link_layer(l, device, buf, ARP_H + ETH_H); <br>

  <br>

   printf("Wrote %d byte ARP packet through linktype %d\n", n, l->linktype); <br>

} <br>

-- <br>

            我问飘逝的风:来迟了? <br>

            风感慨:是的,他们已经宣战。 <br>

            我问苏醒的大地:还有希望么? <br>

            大地揉了揉眼睛:还有,还有无数代的少年。 <br>



            我问长空中的英魂:你们相信? <br>

            英魂带着笑意离去:相信,希望还在。 <br>

</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="308.htm">上一层</a>][<a href="340.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -