📄 arp_send.c
字号:
/* * Roadrunner/pk * Copyright (C) 1989-2002 Cornfed Systems, Inc. * * The Roadrunner/pk operating system is free software; you can * redistribute and/or modify it under the terms of the GNU General * Public License, version 2, as published by the Free Software * Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * More information about the Roadrunner/pk operating system of * which this file is a part is available on the World-Wide Web * at: http://www.cornfed.com. * */#include <net/arp.h>#include <net/netif.h>#include <stdlib.h>#include <string.h>voidarp_send(ipaddr dst){ buf_t b; etherhdr_t eh; arphdr_t ah; b = _bget(ETHER_PKT_LEN); if (b == NULL) return; blen(b) = ETHER_HDR_LEN + sizeof(struct arphdr); eh = (etherhdr_t) bstart(b); ah = (arphdr_t) eh->data; /* Format ARP request */ ah->hwtype = ARP_HW_ETHERNET; ah->prtype = ETHER_TYPE_IP; ah->hwlen = ETHER_ADDR_LEN; ah->prlen = sizeof(ipaddr); ah->op = ARP_OP_REQUEST; bcopy(netif_primary.hwaddr, ah->sha, ETHER_ADDR_LEN); ah->spa = netif_primary.ip; bzero(ah->tha, ETHER_ADDR_LEN); ah->tpa = dst; /* Convert to network order */ ah->hwtype = HS2NET(ah->hwtype); ah->prtype = HS2NET(ah->prtype); ah->op = HS2NET(ah->op); ah->spa = HL2NET(ah->spa); ah->tpa = HL2NET(ah->tpa); /* Send ARP request */ memset(eh->dst, 0xff, ETHER_ADDR_LEN); eh->type = HS2NET(ETHER_TYPE_ARP); netif_send(b);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -