[Dhcp-agent-commits] CVS: dhcp-agent dhcp-icmp-discovery.c,NONE,1.1 Makefile.am,1.11,1.12 Makefile.i
Status: Alpha
Brought to you by:
actmodern
From: Thamer Al-H. <act...@us...> - 2002-02-17 04:37:38
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv17426 Modified Files: Makefile.am Makefile.in dhcp-agent.h dhcp-icmp.c Added Files: dhcp-icmp-discovery.c Log Message: added icmp subnet discovery; not tested yet; --- NEW FILE: dhcp-icmp-discovery.c --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/dhcp-icmp-discovery.c,v 1.1 2002/02/17 04:37:35 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. * * ICMP discovery routines: * * We currently have code for subnet mask discovery, and * discovery of host with least latency. * */ #include <dhcp-agent.h> /* Check for icmp mask response. */ static int icmp_check_mask_reply(void *arg) { rawnet_t *net = arg; if((net->type = RAWNET_ICMP) && (icmp_get_type(net->icmp_p) == ICMP_MASKREPLY)) return 1; else return 0; } /* Discover subnet mask: * If discovered fill in subnet_mask and return 0. * Otherwise return 1 */ int icmp_subnet_mask_discovery(rawnet_t *net, uint32_t *subnet_mask) { uint32_t reply_mask; /* Build ICMP mask request packet. We don't actually care * about sequence or IDs since we'll accept the first * response on our subnet regardless. Still let's be nice to * the mask repliers and set them up anyway. */ build_icmp_mask_request(net, 0, 0); if(rawnet_packet_transact(net, net, NULL, icmp_check_mask_reply)) { error_message("icmp mask discovery: timeout on discovery"); return -1; } /* A reply should contain the subnet mask. If we're actually * doing subnet mask discovery we assume any subnet mask * returned is valid. */ reply_mask = icmp_mask_get_mask(net->icmp_p); memcpy(subnet_mask, &reply_mask, IP_ADDR_LEN); return 0; } Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.am 16 Feb 2002 17:54:33 -0000 1.11 --- Makefile.am 17 Feb 2002 04:37:35 -0000 1.12 *************** *** 20,24 **** dhcp-interface.c dhcp-client-conf.c @DHCP_SNPRINTF@ dhcp-files.c \ dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c \ ! dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence --- 20,24 ---- dhcp-interface.c dhcp-client-conf.c @DHCP_SNPRINTF@ dhcp-files.c \ dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c \ ! dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence Index: Makefile.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.in 16 Feb 2002 17:54:33 -0000 1.11 --- Makefile.in 17 Feb 2002 04:37:35 -0000 1.12 *************** *** 83,87 **** dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ ! dhcpclient_SOURCES = dhcp-client.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c dhcp-interface.c dhcp-client-conf.c @DHCP_SNPRINTF@ dhcp-files.c dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c --- 83,87 ---- dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ ! dhcpclient_SOURCES = dhcp-client.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c dhcp-interface.c dhcp-client-conf.c @DHCP_SNPRINTF@ dhcp-files.c dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c *************** *** 115,119 **** dhcp-client-conf.o dhcp-files.o dhcp-client-states.o \ dhcp-options-strings.o dhcp-convert.o dhcp-sysconf.o dhcp-rtt.o \ ! dhcp-packet-build.o dhcpclient_DEPENDENCIES = dhcpclient_LDFLAGS = --- 115,119 ---- dhcp-client-conf.o dhcp-files.o dhcp-client-states.o \ dhcp-options-strings.o dhcp-convert.o dhcp-sysconf.o dhcp-rtt.o \ ! dhcp-packet-build.o dhcp-icmp-discovery.o dhcpclient_DEPENDENCIES = dhcpclient_LDFLAGS = *************** *** 141,150 **** .deps/dhcp-client-states.P .deps/dhcp-client.P .deps/dhcp-com.P \ .deps/dhcp-convert.P .deps/dhcp-daemon.P .deps/dhcp-eth.P \ ! .deps/dhcp-files.P .deps/dhcp-icmp.P .deps/dhcp-interface.P \ ! .deps/dhcp-ip.P .deps/dhcp-list.P .deps/dhcp-log.P .deps/dhcp-net.P \ ! .deps/dhcp-options-strings.P .deps/dhcp-packet-build.P \ ! .deps/dhcp-print.P .deps/dhcp-rtt.P .deps/dhcp-sniff.P \ ! .deps/dhcp-sniffer-ohandlers.P .deps/dhcp-sysconf.P .deps/dhcp-udp.P \ ! .deps/dhcp-util.P SOURCES = $(dhcpsniff_SOURCES) $(dhcpclient_SOURCES) OBJECTS = $(dhcpsniff_OBJECTS) $(dhcpclient_OBJECTS) --- 141,150 ---- .deps/dhcp-client-states.P .deps/dhcp-client.P .deps/dhcp-com.P \ .deps/dhcp-convert.P .deps/dhcp-daemon.P .deps/dhcp-eth.P \ ! .deps/dhcp-files.P .deps/dhcp-icmp-discovery.P .deps/dhcp-icmp.P \ ! .deps/dhcp-interface.P .deps/dhcp-ip.P .deps/dhcp-list.P \ ! .deps/dhcp-log.P .deps/dhcp-net.P .deps/dhcp-options-strings.P \ ! .deps/dhcp-packet-build.P .deps/dhcp-print.P .deps/dhcp-rtt.P \ ! .deps/dhcp-sniff.P .deps/dhcp-sniffer-ohandlers.P .deps/dhcp-sysconf.P \ ! .deps/dhcp-udp.P .deps/dhcp-util.P SOURCES = $(dhcpsniff_SOURCES) $(dhcpclient_SOURCES) OBJECTS = $(dhcpsniff_OBJECTS) $(dhcpclient_OBJECTS) Index: dhcp-agent.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-agent.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** dhcp-agent.h 16 Feb 2002 17:54:33 -0000 1.29 --- dhcp-agent.h 17 Feb 2002 04:37:35 -0000 1.30 *************** *** 749,753 **** extern uint8_t icmp_get_type(icmp_obj *icmp); ! extern void icmp_write_packet_image(icmp_obj *icmp, unsigned char *packet); --- 749,753 ---- extern uint8_t icmp_get_type(icmp_obj *icmp); ! extern uint32_t icmp_mask_get_mask(icmp_obj *icmp_p); extern void icmp_write_packet_image(icmp_obj *icmp, unsigned char *packet); Index: dhcp-icmp.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-icmp.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-icmp.c 14 Feb 2002 10:06:53 -0000 1.4 --- dhcp-icmp.c 17 Feb 2002 04:37:35 -0000 1.5 *************** *** 45,48 **** --- 45,53 ---- } + uint32_t icmp_mask_get_mask(icmp_obj *icmp) + { + return(icmp->icmp_msg.mask.icmp_mask); + } + /* set routines. */ void icmp_set_type(icmp_obj *icmp, uint8_t type) *************** *** 73,77 **** void icmp_mask_set_mask(icmp_obj *icmp, uint32_t mask) { ! icmp->icmp_msg.mask.icmp_mask = htonl(mask); } --- 78,82 ---- void icmp_mask_set_mask(icmp_obj *icmp, uint32_t mask) { ! icmp->icmp_msg.mask.icmp_mask = mask; } |