📄 dhcp-route.c
字号:
/* $Header: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-route.c,v 1.4 2003/06/08 22:14:16 actmodern Exp $ * * Copyright 2002 Thamer Alharbash <tmh@whitefang.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Routing manipulation: * * Here we can add/delete routes, and lookup routes. We return * mac addresses so packets can be sent out to the right MAC * address. * */#define MODULE_NAME "dhcp-route"#include "dhcp-local.h"#include "dhcp-libutil.h"#include "dhcp-librawnet.h"int route_find(rawnet_t *net, int retries, int timeout, ip_addr_t addr, eth_addr_t *dest_mac){ route_t *rt; struct route_entry entry; rt = route_open(); if(rt == NULL) { ERROR_MESSAGE("could not get route handler."); return -1; } memset(&entry.route_dst, 0, sizeof(entry.route_dst)); memset(&entry.route_gw, 0, sizeof(entry.route_gw)); entry.route_dst.addr_type = ADDR_TYPE_IP; entry.route_dst.addr_bits = 0; entry.route_dst.addr_ip = addr; if(route_get(rt, &entry)) { /* not in routing table. do an arp for it then. */ return (arp_discover_hardware_address(net, retries, timeout, entry.route_dst.addr_ip, dest_mac)); } route_close(rt); /* arp for gateway address. */ return (arp_discover_hardware_address(net, retries, timeout, entry.route_gw.addr_ip, dest_mac));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -