[Dhcp-agent-commits] CVS: dhcp-agent dhcp-route.c,NONE,1.1
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-05-19 18:47:26
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv24213 Added Files: dhcp-route.c Log Message: forgot to add the new route code --- NEW FILE: dhcp-route.c --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/dhcp-route.c,v 1.1 2002/05/19 18:47:23 actmodern Exp $ * * Copyright 2001 Thamer Alharbash <tm...@wh...> * * 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. * */ #include <dhcp-agent.h> int route_find(rawnet_t *net, ip_addr_t addr, eth_addr_t *dest_mac) { route_t *rt; struct route_entry entry; rt = route_open(); if(rt == NULL) { fatal_error("could not open routing table: %s", strerror(errno)); exit(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, 3, entry.route_dst.addr_ip, dest_mac)); } route_close(rt); /* arp for gateway address. */ return(arp_discover_hardware_address(net, 3, entry.route_gw.addr_ip, dest_mac)); } |