dhcp-agent-commits Mailing List for dhcp-agent (Page 12)
Status: Alpha
Brought to you by:
actmodern
You can subscribe to this list here.
2002 |
Jan
|
Feb
(33) |
Mar
|
Apr
|
May
(19) |
Jun
(61) |
Jul
(12) |
Aug
|
Sep
(5) |
Oct
(31) |
Nov
(24) |
Dec
(56) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(9) |
Feb
|
Mar
(16) |
Apr
(4) |
May
(68) |
Jun
(70) |
Jul
(100) |
Aug
(54) |
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(7) |
Jun
(12) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(4) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(8) |
Oct
(5) |
Nov
(6) |
Dec
(4) |
2008 |
Jan
(9) |
Feb
(20) |
Mar
(32) |
Apr
(18) |
May
(19) |
Jun
(12) |
Jul
(23) |
Aug
(7) |
Sep
(15) |
Oct
(22) |
Nov
(50) |
Dec
(68) |
2009 |
Jan
(63) |
Feb
(23) |
Mar
(43) |
Apr
(50) |
May
(110) |
Jun
(103) |
Jul
(71) |
Aug
(26) |
Sep
(16) |
Oct
(31) |
Nov
(8) |
Dec
(13) |
2010 |
Jan
(6) |
Feb
(6) |
Mar
(36) |
Apr
(57) |
May
(67) |
Jun
(70) |
Jul
(44) |
Aug
(46) |
Sep
(27) |
Oct
(2) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: <act...@us...> - 2003-07-26 23:46:19
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv4917/src Modified Files: dhcp-net.c dhcp-libutil.h Log Message: fixed up socket level udp networking Index: dhcp-net.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-net.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-net.c 20 Jul 2003 05:49:49 -0000 1.5 --- dhcp-net.c 26 Jul 2003 23:46:16 -0000 1.6 *************** *** 28,32 **** #include "dhcp-limits.h" #include "dhcp-libutil.h" - #include "dhcp-librawnet.h" /* * * * * * * * * * * * * --- 28,31 ---- *************** *** 82,92 **** } ! size_t udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr) { ! size_t retval; struct sockaddr_in in; socklen_t len = sizeof(struct sockaddr_in); retval = recvfrom(sd, buff, buffsize, 0, (struct sockaddr *)&in, &len); *src_addr = in.sin_addr.s_addr; --- 81,94 ---- } ! int udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr) { ! int retval; struct sockaddr_in in; socklen_t len = sizeof(struct sockaddr_in); retval = recvfrom(sd, buff, buffsize, 0, (struct sockaddr *)&in, &len); + + if(retval < 0) + return -1; *src_addr = in.sin_addr.s_addr; Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** dhcp-libutil.h 20 Jul 2003 05:49:49 -0000 1.32 --- dhcp-libutil.h 26 Jul 2003 23:46:16 -0000 1.33 *************** *** 318,322 **** extern int udp_sock_create(uint16_t source_port, ip_addr_t local_addr); extern void udp_sock_destroy(int sd); ! extern size_t udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr); extern int udp_sock_send(int udp_sock, uint8_t *msg, size_t size, ip_addr_t dst_addr, uint16_t dest_port); --- 318,322 ---- extern int udp_sock_create(uint16_t source_port, ip_addr_t local_addr); extern void udp_sock_destroy(int sd); ! extern int udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr); extern int udp_sock_send(int udp_sock, uint8_t *msg, size_t size, ip_addr_t dst_addr, uint16_t dest_port); |
From: <act...@us...> - 2003-07-25 02:38:05
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23410/src Modified Files: dhcp-server-control.c Log Message: now using new rawnet interface Index: dhcp-server-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-control.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-server-control.c 20 Jul 2003 05:52:31 -0000 1.4 --- dhcp-server-control.c 25 Jul 2003 02:38:02 -0000 1.5 *************** *** 35,39 **** dhcp_server_control_t *dhcp_server_control_create(const char *interface) { ! int port; stringbuffer_t *filter; dhcp_server_control_t *dhcp_server_control; --- 35,39 ---- dhcp_server_control_t *dhcp_server_control_create(const char *interface) { ! int dport, sport; stringbuffer_t *filter; dhcp_server_control_t *dhcp_server_control; *************** *** 47,62 **** } ! /* get the source port for BOOTP. */ ! port = rawnet_port_for_service("bootpc", "udp"); ! if(port == -1) { WARN_MESSAGE ("could not lookup dhcp services in service db (%s) will use reasonable defaults."); ! port = BOOTP_SERVER; } ! port = ntohs(port); /* Create filter. */ --- 47,64 ---- } ! sport = rawnet_port_for_service("bootpc", "udp"); ! dport = rawnet_port_for_service("bootps", "udp"); ! if(dport == -1 || sport == -1) { WARN_MESSAGE ("could not lookup dhcp services in service db (%s) will use reasonable defaults."); ! sport = BOOTP_CLIENT; ! dport = BOOTP_SERVER; } ! dport = ntohs(dport); ! sport = ntohs(sport); /* Create filter. */ *************** *** 66,76 **** /* create rawnet handler: we pass sport/dport as 0 because we * won't be doing any DHCP handling rawly for the server. */ ! if((dhcp_server_control->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), -1, 0, ! 0, 0, 0)) == NULL) { FATAL_MESSAGE("could not create raw network handler."); } if((dhcp_server_control->udp_sock = ! udp_sock_create(port, rawnet_get_ip_addr(dhcp_server_control->rawnet))) < 0) { FATAL_MESSAGE("unable to open udp socket"); --- 68,77 ---- /* create rawnet handler: we pass sport/dport as 0 because we * won't be doing any DHCP handling rawly for the server. */ ! if((dhcp_server_control->rawnet = rawnet_create_open(interface, stringbuffer_getstring(filter), dport, sport, 0)) == NULL) { FATAL_MESSAGE("could not create raw network handler."); } if((dhcp_server_control->udp_sock = ! udp_sock_create(dport, rawnet_get_ip_addr(dhcp_server_control->rawnet))) < 0) { FATAL_MESSAGE("unable to open udp socket"); |
From: <act...@us...> - 2003-07-25 02:37:34
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23344/src Modified Files: dhcp-packet-build.c Log Message: brought up to new rawnet interface Index: dhcp-packet-build.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-packet-build.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-packet-build.c 26 Jun 2003 23:56:42 -0000 1.9 --- dhcp-packet-build.c 25 Jul 2003 02:37:31 -0000 1.10 *************** *** 348,351 **** --- 348,352 ---- uint16_t ip_len, udp_len; int total_len; + eth_addr_t eth_addr; dhcp_purge(net->dhcp_p); /* clear up old options. */ *************** *** 378,393 **** ("Outgoing DHCP packet too large. I'm currently not implementing this properly so I'll have to exit!"); if(broadcast) ! build_eth_broadcast(net, net->chw_addr, ETH_TYPE_IP); else ! build_eth(net, net->chw_addr, server_hw_addr, ETH_TYPE_IP); if(broadcast) build_ip_broadcast(net, ip_len, IP_PROTO_UDP, 0); else ! build_ip(net, ip_len, IP_PROTO_UDP, net->cip_addr, server_ip_addr); build_udp(net, udp_len); ! build_dhcp_proc(net, xid, secs, net->chw_addr, ciaddr, yiaddr, siaddr, giaddr, options, broadcast, bootp_type); --- 379,396 ---- ("Outgoing DHCP packet too large. I'm currently not implementing this properly so I'll have to exit!"); + rawnet_get_hw_addr(net, ð_addr); + if(broadcast) ! build_eth_broadcast(net, eth_addr, ETH_TYPE_IP); else ! build_eth(net, eth_addr, server_hw_addr, ETH_TYPE_IP); if(broadcast) build_ip_broadcast(net, ip_len, IP_PROTO_UDP, 0); else ! build_ip(net, ip_len, IP_PROTO_UDP, rawnet_get_ip_addr(net), server_ip_addr); build_udp(net, udp_len); ! build_dhcp_proc(net, xid, secs, eth_addr, ciaddr, yiaddr, siaddr, giaddr, options, broadcast, bootp_type); *************** *** 468,473 **** { int ip_len = ICMP_HDR_LEN + 12 + IP_HDR_LEN; /* 12 bytes for the mask request. */ ! build_eth_broadcast(net, net->chw_addr, ETH_TYPE_IP); build_ip_broadcast(net, ip_len, IP_PROTO_ICMP, 0); build_icmp_mask_proc(net, ICMP_MASK, id, seq, 0); --- 471,478 ---- { int ip_len = ICMP_HDR_LEN + 12 + IP_HDR_LEN; /* 12 bytes for the mask request. */ + eth_addr_t eth_addr; ! rawnet_get_real_hw_addr(net, ð_addr); ! build_eth_broadcast(net, eth_addr, ETH_TYPE_IP); build_ip_broadcast(net, ip_len, IP_PROTO_ICMP, 0); build_icmp_mask_proc(net, ICMP_MASK, id, seq, 0); *************** *** 483,488 **** { int ip_len = IP_HDR_LEN + ICMP_HDR_LEN + 12; /* 12 bytes for the mask reply. */ ! build_eth_broadcast(net, net->chw_addr, ETH_TYPE_IP); build_ip_broadcast(net, ip_len, IP_PROTO_ICMP, 0); build_icmp_mask_proc(net, ICMP_MASK, id, seq, subnet_mask); --- 488,495 ---- { int ip_len = IP_HDR_LEN + ICMP_HDR_LEN + 12; /* 12 bytes for the mask reply. */ + eth_addr_t eth_addr; ! rawnet_get_real_hw_addr(net, ð_addr); ! build_eth_broadcast(net, eth_addr, ETH_TYPE_IP); build_ip_broadcast(net, ip_len, IP_PROTO_ICMP, 0); build_icmp_mask_proc(net, ICMP_MASK, id, seq, subnet_mask); |
From: <act...@us...> - 2003-07-25 02:36:42
|
Update of /cvsroot/dhcp-agent/dhcp-agent/doc In directory sc8-pr-cvs1:/tmp/cvs-serv23225/doc Modified Files: Makefile.am Log Message: added *.info to cleanup Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/doc/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 6 Jul 2003 17:49:56 -0000 1.5 --- Makefile.am 25 Jul 2003 02:36:39 -0000 1.6 *************** *** 5,9 **** info_TEXINFOS = dhcp-agent.texi ! dhcp_agent_TEXINFOS = dhcp-client.texi dhcp-relay.texi dhcp-sniff.texi dhcp-server.texi introduction.texi if HTMLDOC --- 5,9 ---- info_TEXINFOS = dhcp-agent.texi ! dhcp_agent_TEXINFOS = part-1.texi part-2.texi part-3.texi part-4.texi if HTMLDOC *************** *** 18,20 **** endif ! CLEANFILES=*.html --- 18,20 ---- endif ! CLEANFILES=*.html *.info |
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23174/src Modified Files: dhcp-arp-discovery.c dhcp-client-control.c dhcp-icmp-discovery.c dhcp-interface.c dhcp-interface.h dhcp-librawnet.h dhcp-rawnet.c dhcp-sniff.c Log Message: revamped raw network; now two creation routines are used; less system calls used Index: dhcp-arp-discovery.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-arp-discovery.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-arp-discovery.c 8 Jun 2003 22:14:16 -0000 1.5 --- dhcp-arp-discovery.c 25 Jul 2003 02:36:21 -0000 1.6 *************** *** 74,77 **** --- 74,80 ---- unsigned char *sender_addr; int retval; + eth_addr_t eth_addr; + + rawnet_get_real_hw_addr(net, ð_addr); arg_list = list_create(); *************** *** 82,86 **** * hardware address so we get a reply back. */ ! build_arp_request(net, net->cip_addr, address, net->chw_addr); while(retries--) { --- 85,89 ---- * hardware address so we get a reply back. */ ! build_arp_request(net, rawnet_get_ip_addr(net), address, eth_addr); while(retries--) { Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** dhcp-client-control.c 17 Jul 2003 00:35:52 -0000 1.20 --- dhcp-client-control.c 25 Jul 2003 02:36:21 -0000 1.21 *************** *** 166,171 **** if((dc->rawnet = ! rawnet_create(interface, stringbuffer_getstring(filter), client_conf_get_default_mtu(dc->conf), sport, dport, ! promiscuous, clear_interface)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); dhcp_client_control_destroy(dc); --- 166,170 ---- if((dc->rawnet = ! rawnet_create_initialize(interface, stringbuffer_getstring(filter), client_conf_get_default_mtu(dc->conf), sport, dport, 1)) == NULL) { ERROR_MESSAGE("could not acquire rawnet handler."); dhcp_client_control_destroy(dc); Index: dhcp-icmp-discovery.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-icmp-discovery.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-icmp-discovery.c 8 Jun 2003 22:14:16 -0000 1.5 --- dhcp-icmp-discovery.c 25 Jul 2003 02:36:21 -0000 1.6 *************** *** 123,131 **** struct timeval before, after, difference; int latency; id = get_random_uint16(); seq = 1; ! build_icmp_echo_request(net, net->cip_addr, dest_addr, net->chw_addr, dest_mac, id, seq); gettimeofday(&before, NULL); --- 123,134 ---- struct timeval before, after, difference; int latency; + eth_addr_t eth_addr; + + rawnet_get_real_hw_addr(net, ð_addr); id = get_random_uint16(); seq = 1; ! build_icmp_echo_request(net, rawnet_get_ip_addr(net), dest_addr, eth_addr, dest_mac, id, seq); gettimeofday(&before, NULL); Index: dhcp-interface.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-interface.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dhcp-interface.c 5 Jul 2003 19:18:18 -0000 1.9 --- dhcp-interface.c 25 Jul 2003 02:36:21 -0000 1.10 *************** *** 59,63 **** /* Initialize interface handle. */ ! interface_control_t *create_interface_control(char *name) { interface_control_t *ic; --- 59,63 ---- /* Initialize interface handle. */ ! interface_control_t *create_interface_control(const char *name) { interface_control_t *ic; *************** *** 278,281 **** } ! return ic->interface_entry->intf_type; } --- 278,281 ---- } ! return ic->interface_entry->intf_mtu; } Index: dhcp-interface.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-interface.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-interface.h 5 Jul 2003 19:18:18 -0000 1.5 --- dhcp-interface.h 25 Jul 2003 02:36:21 -0000 1.6 *************** *** 26,30 **** #define DHCP_INTERFACE_H ! extern interface_control_t *create_interface_control(char *name); extern void destroy_interface_control(interface_control_t *ic); extern int interface_up(interface_control_t *ic, ip_addr_t addr, uint32_t netmask, int mtu, uint8_t set_addr); --- 26,30 ---- #define DHCP_INTERFACE_H ! extern interface_control_t *create_interface_control(const char *name); extern void destroy_interface_control(interface_control_t *ic); extern int interface_up(interface_control_t *ic, ip_addr_t addr, uint32_t netmask, int mtu, uint8_t set_addr); Index: dhcp-librawnet.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** dhcp-librawnet.h 20 Jul 2003 05:50:56 -0000 1.22 --- dhcp-librawnet.h 25 Jul 2003 02:36:21 -0000 1.23 *************** *** 180,194 **** uint16_t src_port, dst_port; /* udp ports for writing packets. */ ! char *device; /* device name. */ char *packet_data; /* packet data. */ ! int packet_len; /* total length of packet. */ ! struct timeval tstamp; /* timestamp. */ ! eth_addr_t chw_addr; /* our hardware address. */ ! ip_addr_t cip_addr; /* our ip address. */ ! eth_addr_t *fake_hw_addr; /* our fake hardware address. */ int promiscuous; /* run in promiscuous mode flag. */ --- 180,194 ---- uint16_t src_port, dst_port; /* udp ports for writing packets. */ ! char *device; /* device name. */ char *packet_data; /* packet data. */ ! int packet_len; /* total length of packet that we read. */ ! struct timeval tstamp; /* timestamp of most recently read packet. */ ! eth_addr_t hw_addr; /* our hardware address. */ ! ip_addr_t ip_addr; /* our ip address. */ ! eth_addr_t *fake_hw_addr; /* our fake hardware address, if any. */ int promiscuous; /* run in promiscuous mode flag. */ *************** *** 363,395 **** /* rawnet routines. */ ! extern rawnet_t *rawnet_create(const char *device, const char *filter, int mtu, int sport, ! int dport, int promiscuous, int clear_address); ! extern void rawnet_destroy(rawnet_t *net); ! extern int rawnet_get_packet(rawnet_t *net, struct timeval *tm); extern int rawnet_get_hw_addr(rawnet_t *net, eth_addr_t *addr); extern int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr); ! extern ip_addr_t rawnet_get_ip_addr(rawnet_t *net); ! extern uint16_t rawnet_get_mtu(rawnet_t *net); ! extern int rawnet_send_packet(rawnet_t *net); ! extern int rawnet_use_fake_hw_addr(rawnet_t *raw, char *mac_string); ! extern void reinitialize_rawnet(rawnet_t *net, int promiscuous); ! ! extern int rawnet_up(rawnet_t *net); ! extern void rawnet_down(rawnet_t *net); ! ! extern int rawnet_packet_transact(rawnet_t *net, void *arg, ! void (*update) (void *arg), ! int (*check) (void *arg), time_t max_timeout); ! ! extern int rawnet_interface_up(rawnet_t *net, ip_addr_t addr, ip_addr_t netmask, int mtu, int clear_address); extern int rawnet_interface_down(rawnet_t *net); extern list_t *rawnet_list_active_interfaces(void); extern list_t *rawnet_list_inactive_interfaces(void); ! extern void rawnet_dhcp_update(rawnet_t *net, time_t seconds); - extern int rawnet_is_dhcp_offer(rawnet_t *net); extern int rawnet_is_valid(rawnet_t *net); ! extern const char *rawnet_get_device_name(rawnet_t *net); extern int rawnet_get_datalink_type(rawnet_t *net); /* packet building routines. */ --- 363,392 ---- /* rawnet routines. */ ! extern ip_addr_t rawnet_get_ip_addr(rawnet_t *net); ! extern int rawnet_port_for_service(const char *serv, const char *proto); ! extern char *rawnet_network_address_to_string_static(uint32_t addr); extern int rawnet_get_hw_addr(rawnet_t *net, eth_addr_t *addr); extern int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr); ! extern int rawnet_interface_up(rawnet_t *net, ip_addr_t addr, ip_addr_t netmask, int mtu, int set_address); extern int rawnet_interface_down(rawnet_t *net); + extern uint16_t rawnet_get_mtu(rawnet_t *net); extern list_t *rawnet_list_active_interfaces(void); extern list_t *rawnet_list_inactive_interfaces(void); ! extern rawnet_t *rawnet_create_initialize(const char *device, const char *filter, int mtu, ! int dhcp_src_port, int dhcp_dst_port, int promiscious); ! extern rawnet_t *rawnet_create_open(const char *device, const char *filter, int dhcp_src_port, ! int dhcp_dst_port, int promiscious); ! extern int rawnet_use_fake_hw_addr(rawnet_t *net, char *mac_string); ! extern void rawnet_destroy(rawnet_t *net); ! extern void rawnet_down(rawnet_t *net); ! extern int rawnet_up(rawnet_t *net); ! extern void reinitialize_rawnet(rawnet_t *net, int promiscuous); ! extern int rawnet_get_packet(rawnet_t *net, struct timeval *tm); extern void rawnet_dhcp_update(rawnet_t *net, time_t seconds); extern int rawnet_is_valid(rawnet_t *net); ! extern int rawnet_packet_transact(rawnet_t *net, void *arg, void (*update) (void *arg), ! int (*check) (void *arg), time_t max_timeout); extern int rawnet_get_datalink_type(rawnet_t *net); + extern int rawnet_send_packet(rawnet_t *net); /* packet building routines. */ Index: dhcp-rawnet.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-rawnet.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** dhcp-rawnet.c 16 Jul 2003 05:42:24 -0000 1.13 --- dhcp-rawnet.c 25 Jul 2003 02:36:21 -0000 1.14 *************** *** 23,26 **** --- 23,28 ---- * Raw network module. * + * All interface manipulation, raw packet I/O is done here. + * */ *************** *** 38,48 **** ************************/ ! /* get IP address. */ ip_addr_t rawnet_get_ip_addr(rawnet_t *net) { ! return net->cip_addr; } ! /* get port number for named service. */ int rawnet_port_for_service(const char *serv, const char *proto) { --- 40,50 ---- ************************/ ! /* get our ip address. */ ip_addr_t rawnet_get_ip_addr(rawnet_t *net) { ! return net->ip_addr; } ! /* get a port for a service. */ int rawnet_port_for_service(const char *serv, const char *proto) { *************** *** 59,67 **** } ! /* variation on network_addr_to_string in dhcp-convert.c we use ! * this when we don't want to run around freeing results up, and ! * know that it will be statically stored. Useful for insertion ! * in message log routines. */ ! char *rawnet_network_address_to_string_static(uint32_t addr) { --- 61,65 ---- } ! /* network address to a string: static version. */ char *rawnet_network_address_to_string_static(uint32_t addr) { *************** *** 84,88 **** return 0; } else { ! memcpy(addr, &net->chw_addr, ETH_ADDR_LEN); return 0; } --- 82,86 ---- return 0; } else { ! memcpy(addr, &net->hw_addr, ETH_ADDR_LEN); return 0; } *************** *** 92,96 **** int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr) { ! return (eth_get(net->eth, addr)); } --- 90,95 ---- int rawnet_get_real_hw_addr(rawnet_t *net, eth_addr_t *addr) { ! memcpy(addr, &net->hw_addr, ETH_ADDR_LEN); ! return 0; } *************** *** 98,102 **** int rawnet_interface_up(rawnet_t *net, ip_addr_t addr, ip_addr_t netmask, int mtu, int set_address) { - if(interface_up(net->intf_handle, addr, netmask, mtu, set_address)) { ERROR_MESSAGE("could not bring interface up."); --- 97,100 ---- *************** *** 104,111 **** } ! interface_get_ip_addr(net->intf_handle, &net->cip_addr); xfree(net->packet_data); ! net->packet_data = xmalloc(mtu); return 0; --- 102,112 ---- } ! /* set our new vales from the interface. */ + eth_get(net->eth, &net->hw_addr); + interface_get_ip_addr(net->intf_handle, &net->ip_addr); + net->mtu = interface_get_mtu(net->intf_handle); xfree(net->packet_data); ! net->packet_data = xcalloc(net->mtu); return 0; *************** *** 120,132 **** } ! memset(&net->cip_addr, 0, IP_ADDR_LEN); /* clear our IP address -- this isn't very useful though. */ return 0; } uint16_t rawnet_get_mtu(rawnet_t *net) { ! return interface_get_mtu(net->intf_handle); } list_t *rawnet_list_active_interfaces(void) { --- 121,135 ---- } ! memset(&net->ip_addr, 0, IP_ADDR_LEN); /* clear our IP address -- this isn't very useful though. */ return 0; } + /* get the interface mtu. */ uint16_t rawnet_get_mtu(rawnet_t *net) { ! return net->mtu; } + /* get list of active interfaces. */ list_t *rawnet_list_active_interfaces(void) { *************** *** 134,138 **** } ! list_t *rawnet_list_inactive_interfaces(void) { --- 137,141 ---- } ! /* get list of inactive interfaces. */ list_t *rawnet_list_inactive_interfaces(void) { *************** *** 216,285 **** } ! /* Create the workhorse raw network module. */ ! ! rawnet_t *rawnet_create(const char *device, const char *filter, int mtu, ! int dhcp_src_port, int dhcp_dst_port, int promiscuous, int clear_address) { rawnet_t *net; int retval; - net = xcalloc(sizeof(rawnet_t)); - net->src_port = dhcp_src_port; - net->dst_port = dhcp_dst_port; - net->device = xstrdup(device); - net->pcap_filter = xstrdup(filter); - net->promiscuous = promiscuous; - net->mtu = mtu; - - /* get the interface handle for bringing it up or down and querying it. */ - net->intf_handle = create_interface_control(net->device); - if(net->intf_handle == NULL) { - ERROR_MESSAGE("could not acquire interface handle"); - rawnet_destroy(net); - return NULL; - } - /* Is the interface up? */ ! retval = interface_is_up(net->intf_handle); if(retval == -1) { /* error on interface detection */ ERROR_MESSAGE("error on interface detection for device: %s", device); - rawnet_destroy(net); return NULL; } if(retval == 0) { ! /* interface down */ ! /* bring it up with dum values. */ ! if(rawnet_interface_up(net, 0, 0, net->mtu, clear_address)) { ! ERROR_MESSAGE("error trying to bring device up: %s", device); ! rawnet_destroy(net); ! return NULL; ! } ! } else if(clear_address) { ! ! /* interface down but we've been told to clear its address, ! * so our caller wants us to initialize it either way. */ ! ! if(rawnet_interface_up(net, 0, 0, net->mtu, clear_address)) { ! ERROR_MESSAGE("error trying to bring device up: %s", device); ! rawnet_destroy(net); ! return NULL; ! } } ! if(net->mtu == -1) { /* were we passed an mtu? */ ! /* if not get it from the interface that was just brought up. */ ! net->mtu = rawnet_get_mtu(net); ! } ! /* now allocate packet data since we know the mtu. */ ! net->packet_data = xcalloc(net->mtu); ! /* any other value of retval and the interface is already up. */ ! /* Get the interface and make sure its an ethernet interface or ! * else we're hosed. */ net->eth = eth_open(device); --- 219,261 ---- } ! /* create the raw network module. */ ! static rawnet_t *rawnet_create_proc(const char *device, interface_control_t *intf_handle, const char *filter, ! int dhcp_src_port, int dhcp_dst_port, int promiscuous) { rawnet_t *net; int retval; /* Is the interface up? */ ! retval = interface_is_up(intf_handle); if(retval == -1) { /* error on interface detection */ + destroy_interface_control(intf_handle); ERROR_MESSAGE("error on interface detection for device: %s", device); return NULL; } if(retval == 0) { ! destroy_interface_control(intf_handle); ! ERROR_MESSAGE("attempt to create raw network handler on downed interface: %s", device); ! return NULL; } ! /* setup values. */ ! /* base values we already know about. */ ! net = xcalloc(sizeof(rawnet_t)); ! net->src_port = dhcp_src_port; ! net->dst_port = dhcp_dst_port; ! net->device = xstrdup(device); ! net->pcap_filter = xstrdup(filter); ! net->promiscuous = promiscuous; ! net->intf_handle = intf_handle; ! /* other values and handler we setup here. ! * begin by setting up our ethernet writing handler. */ ! /* Get the libdnet ethernet handler and make sure the device ! * is an ethernet interface or else we're hosed. */ net->eth = eth_open(device); *************** *** 290,297 **** --- 266,282 ---- } + /* we can go ahead and get mtu, along with addresses. */ + eth_get(net->eth, &net->hw_addr); + interface_get_ip_addr(net->intf_handle, &net->ip_addr); + net->mtu = interface_get_mtu(intf_handle); + + /* allocate our packet data buffer based on our mtu. */ + net->packet_data = xcalloc(net->mtu); + /* get pcap handler */ net->pcap = initialize_pcap_device(net->device, net->mtu, net->pcap_filter, promiscuous); if(net->pcap == NULL) { ERROR_MESSAGE("could not initialize pcap device for: %s", device); + rawnet_destroy(net); return NULL; } *************** *** 304,312 **** } - /* store a copy of our hardware and ip address. */ - - eth_get(net->eth, &net->chw_addr); - interface_get_ip_addr(net->intf_handle, &net->cip_addr); - /* Packet handler objects. * --- 289,292 ---- *************** *** 322,328 **** --- 302,351 ---- net->dhcp_p = dhcp_create(); + /* dont. */ return net; } + /* initialize an interface, and bring it up if needed. we also clear the address. */ + rawnet_t *rawnet_create_initialize(const char *device, const char *filter, int mtu, + int dhcp_src_port, int dhcp_dst_port, int promiscious) + { + interface_control_t *intf_handle; + + /* get the interface handle for bringing it up or down and querying it. */ + intf_handle = create_interface_control(device); + if(intf_handle == NULL) { + ERROR_MESSAGE("could not acquire interface handle"); + return NULL; + } + + /* initialize the interface. */ + if(interface_up(intf_handle, 0, 0, mtu, 1) < 0) { + ERROR_MESSAGE("error trying to bring device up: %s", device); + destroy_interface_control(intf_handle); + return NULL; + } + + return rawnet_create_proc(device, intf_handle, filter, + dhcp_src_port, dhcp_dst_port, promiscious); + } + + /* open an existing interface. use current interface values. */ + rawnet_t *rawnet_create_open(const char *device, const char *filter, int dhcp_src_port, + int dhcp_dst_port, int promiscious) + { + interface_control_t *intf_handle; + + /* get the interface handle for bringing it up or down and querying it. */ + intf_handle = create_interface_control(device); + if(intf_handle == NULL) { + ERROR_MESSAGE("could not acquire interface handle"); + return NULL; + } + + return rawnet_create_proc(device, intf_handle, filter, + dhcp_src_port, dhcp_dst_port, promiscious); + } + + /* Use a fake hardware address (diagnostic purposes). We need to * reinitialize our rawnet to use promiscuous packet capturing *************** *** 342,346 **** } ! memcpy(net->chw_addr.data, mac_addr, ETH_ADDR_LEN); /* now reinitialize in promiscuous mode */ --- 365,369 ---- } ! memcpy(net->fake_hw_addr->data, mac_addr, ETH_ADDR_LEN); /* now reinitialize in promiscuous mode */ *************** *** 350,353 **** --- 373,377 ---- } + /* destroy the rawnetwork handler. */ void rawnet_destroy(rawnet_t *net) { *************** *** 397,400 **** --- 421,425 ---- * to fill up. */ + /* bring raw networking down. */ void rawnet_down(rawnet_t *net) { *************** *** 412,415 **** --- 437,441 ---- } + /* bring raw networking up. */ int rawnet_up(rawnet_t *net) { *************** *** 437,440 **** --- 463,467 ---- } + /* reinitialize the raw network handler. useful for bringing up and down. */ void reinitialize_rawnet(rawnet_t *net, int promiscuous) { *************** *** 456,459 **** --- 483,487 ---- */ + /* get the next packet waiting us. */ int rawnet_get_packet(rawnet_t *net, struct timeval *tm) { *************** *** 580,583 **** --- 608,612 ---- } + /* send a packet. */ int rawnet_send_packet(rawnet_t *net) { *************** *** 591,598 **** /* Just update the seconds field. ! * ! * FIXME: mod this so that it hooks ! * into the rest of the framework. ! * right now it's error prone. */ --- 620,624 ---- /* Just update the seconds field. ! * field in an existing dhcp packet. */ Index: dhcp-sniff.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-sniff.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-sniff.c 28 Jun 2003 16:30:01 -0000 1.8 --- dhcp-sniff.c 25 Jul 2003 02:36:21 -0000 1.9 *************** *** 119,123 **** /* It's ok not to set ports since we're not writing any packets. */ ! net = rawnet_create(interface_name, stringbuffer_getstring(filter), DEFAULT_SNIFF_SNAPLEN, 0, 0, 1, 0); if(net == NULL) { FATAL_MESSAGE("unable to access raw network"); --- 119,123 ---- /* It's ok not to set ports since we're not writing any packets. */ ! net = rawnet_create_open(interface_name, stringbuffer_getstring(filter), dport, sport, 1); if(net == NULL) { FATAL_MESSAGE("unable to access raw network"); |
From: <act...@us...> - 2003-07-22 20:18:56
|
Update of /cvsroot/dhcp-agent/dhcp-agent/doc In directory sc8-pr-cvs1:/tmp/cvs-serv30594 Modified Files: dhcp-agent.texi Added Files: part-1.texi part-3.texi part-2.texi part-5.texi part-4.texi Log Message: new docs with new layout --- NEW FILE: part-1.texi --- @node The dhcp-agent License @chapter The dhcp-agent License @cindex The dhcp-agent License dhcp-agent is distributed under a revised BSD-like license: @quotation Copyright 2002, 2003 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. @end quotation @node Manual Layout @chapter Manual Layout @cindex Manual Layout The dhcp-agent manual is divided into six parts: An introductory part consists of five chapters on: the licensing information, the layout of this manual, an overview of all the components, an primer on the Dynamic Host Configuration Protocol, and system specific notes. Part two is reference material on invoking the components. This is what you would typically expect from a man page. The dhcp-agent distribution comes with man pages which have the same invocation instructions in them. They are reproduced in this texinfo manual for completeness sake only. Part three discusses the configuration of the client and server. For most purposes, the casual user of the client will not need to do any configuration tweaking. The default configuration file for the client should do for most installations. Part four is for the advanced user who wants to take advantage of the embedded Scheme interpreter (guile). Documentation is provided on the hooks, files, and the API used to extend the components. Part five is an overview of troubleshooting with the suite, and in particular documents the output from the command line sniffer. Finally an index is provided. @node Components Overview @chapter Components Overview @cindex Components Overview dhcp-agent currently ships with only two components, a command line sniffer, and a DHCP client. In the future a server and relay agent will be provided as well. @node The Dynamic Host Configuration Protocol @chapter The Dynamic Host Configuration Protocol @cindex The Dynamic Host Configuration Protocol The following is an overview of the Dynamic Host Configuration Protocol (DHCP), and how dhcp-agent deals with some of the deficiences of the protocol. DHCP is based on the Bootstrap Protocol (BOOTP). It provides a mechanism whereby configuration parameters can be distributed from a central repository, a server or set of servers, to individual hosts, which are running a DHCP client. The protocol uses leases to pass configuration parameters between the server and client. The term ``lease'' is used because the parameters expire. Prior to lease expiration the client attempts to renew. A DHCP client and server communicate via a set of primitive messages which ideally allow the acquisition of leases to occur despite the fact that the client does not have an initialized IP stack. This is done by broadcasting IP datagrams, and later reverting to unicasting when the client has acquired an IP address. Additionally, the User Datagram Protocol (UDP) is used for DHCP which makes writing an ad-hoc IP stack in the client easier. The client begins by broadcasting a DHCP DISCOVER message to discover what leases are available to it. The client can send a parameter request list in its DHCP DISCOVER message which would request specific configuration parameters to be offered back to it. It may also send a message with no such list if it is not particular about the options it wants to receive. The DHCP servers which see the DHCP DISCOVER broadcast back the next lease which is available via DHCP OFFER message which, ideally, contains all the configuration parameters the client explicitly requested, or all the configuration parameters the server has been configured ot pass if the client did not request a specific list. Unfortunately, RFC2131 leaves some ambiguity as to whether or not the server should @strong{only} send specific options requested in the parameter request list, or all options it has been configured with. The dhcp-agent client can be configured to request specific options, require that specific options are available in a response, and configure only a set of specific options. This is a valuable feature to get around uncooperative servers, or very generous servers. @xref{Configuring dhcp-client}. Once the client receives an offer for a suitable lease it responds with a DHCP REQUEST which includes a server identifier refering to whichever server the client has accepted the lease from. The server then responds with a DHCP ACK, or a DHCP NACK, acknowledging or retracting the offer, respectively. If the client receives an acknowledgement it configures its host with the values passed. Among the values passed is the lease expiry time expressed in seconds. Additionally a ``renew'' and ``rebind'' time can also be passed from the server. The expiry, renew, and rebind values are used to setup three timers. The first timer is the renew timer when the client attempts to renew its lease by requesting it again from the server it received the lease from. The rebind timer is whenx the client attempts to renew its lease from broadcasting to any server that can hear it. Finally, once the lease expires the client will unconfigure the settings and attempt to discover a new lease. Unfortunately, more ambigiouty exists with RFC2131. There is no mention of what the client should do if it receives no expiry time. dhcp-agent's client will assume an infinite time and never give up its lease unless explicitly killed. @xref{Invoking dhcp-client}. There is no mention of what the client should do if the lease received during a rebind or renew differs from its own lease, except that the client should notify the user. dhcp-agent allows additional rebind and renew hooks in its sysconf script to handle this. @xref{Extending dhcp-client}. And so the circle of life in the DHCP UNIXverse continues on. Kind of. [ It should be noted that this protocol overview is client centric. More will be added in the future when the server is closer to completion. ] @node System Specific Notes @chapter System Specific Notes @cindex System Specific Notes @section GNU/Linux The client under Linux may not be entirely happy when applied to an aliased interface. You will see some error messages, however things should proceed OK. @section Solaris No major issues so far. Building the package may become ``interesting'' if you have not setup your build environment properly. @section FreeBSD Under FreeBSD the client, sniffer, and the server will make use of two bpf devices. This is because of a limitation in dnet which makes it only single directional for sending packets. Consequently libpcap is used to open another bpf devices for reading. If you run out of bpf devices you will need to compile a kernel with more bpf devices. @section NetBSD NetBSD ships with a pcap which does not come with @dfn{pcap_freecode} this results in a small mem leak when the client reinitializes its raw network code. To avoid this upgrade to the latest version of pcap and nuke your old pcap library. See above note for FreeBSD and BPF since it applies to all BSDs. @section OpenBSD OpenBSD has some brain damage with its bpf structure. Unlike the other BSD flavors it insists on using unsigned instead of signed integers for the number of seconds in its timestamp. This results in some inaccuracy when calculating timeouts. Lobby your OpenBSD developers to stop the brain damage. See above note for FreeBSD and BPF since it applies to all BSDs. --- NEW FILE: part-3.texi --- @node Configuration Intro @chapter Configuration Intro @cindex Configuration Intro This section describes configuration of the dhcp-agent components. @section The Configuration File Parser All configurable components use a single parser, which follows a simple grammar and accepts the same type of tokens. This is good news since it means the configuration files will look very similar. The only differences will be the directives each component accepts. @section The Tokens The parser accepts a set of tokens which it uses to build complete statements. @itemize @item string Strings can be a single alphanumeric contiginous string of characters, a quoted alphanumeric string of characters, and may contain other characters as long as they are preceeded by a backslash. If newlines are present, they may only be present in a quoted string and must be preceeded by a backslash. examples: @example foobar @end example @example ``foo bar'' @end example @example ``foo:bar'' @end example @example ``foo \ bar'' @end example @item assignment: The equal character (``='') signifies assignment. examples: @example foo = bar @end example @example blah = "foo bar" @end example @item blocks: Grouping can be done via blocks which begin with a ``@{`` character and are terminated by a ``@}'' character examples: @example foo @{ bar = foo @} @end example @item terminator: The semicolon (``;'') character is used to terminate statements. examples: @example foo = bar; @end example @item lists: Commas (``,'') are used to denote a list of items. Currently lists of strings are used. @example foo = bar, blah; @end example @end itemize As the reader has noted, anything except a few special characters defaults to a string which is then evaluated at a higher level. @section Directives The configuration files are made up of directives which in turn are made up of the above tokens. Each directive begins with an identifier and is terminated by the terminator (``;''). @example set foo = blah; @end example Here ``set'' is the identifier, or the command name, and what follows is dependant on the command. The chapters below will describe all the configuration directives for the components of dhcp-gent. @node Configuring dhcp-client @chapter Configuring dhcp-client @cindex Configuring dhcp-client @section The Configuration Files dhcp-client will look for two files for a configuration information. Both these files should be located in the system configuration directory. By default this is defined as @file{/usr/local/etc} You can change this definition at build time by specifying a different prefix to the @command{configure} script. The first file that is checked for begins with the name of the interface the client is configuring. For example, if the name of our interface is ``xl0'' then the configuration file to be checked will be @file{/usr/local/etc/dhcp-agent/dhcp-client/xl0.conf} If this file does not exist then the default configuration file is @file{/usr/local/etc/dhcp-agent/dhcp-client/default.conf} This allows dhcp-client to accept configuration per interface, and use a default file without forcing the user to name interfaces in the actual configuration file. It is believed that configuration files are more portable this way and are not dependant on interface names by avoiding having to specify interface names in the configuration file. @section Configuration Directives @subheading DHCP Option Handling The following directives affect DHCP option handling by the client @deffn {Client Configuration Directive} request This directive instructs the client to request a set of dhcp options. The request directive accepts a list of strings which name the options to be requested: @example request subnet-mask, ip-address-lease-time, renewal-time, rebinding-time, interface-mtu, domain-name, domain-name-servers; @end example @end deffn @deffn {Client Configuration Directive} require This directive instructs the client to require a set of dhcp options to be passed before accepting the lease. This is useful to make sure you receive a minimum of desired options. If these options are never met the client will eventually timeout. If this directive is not set, the first DHCP lease offer will be accepted. @example require subnet-mask, ip-address-lease-time, renewal-time, rebinding-time, interface-mtu; @end example @end deffn @deffn {Client Configuration Directive} configure This directive instructs the client to only configure a set of dhcp options. This is useful if the server is passing you options you would rather not configure but implicitly claim to configure by accepting the lease. This directive does not define how options are configured. In order to define how configuration is done see ``Writing Client Extensions,'' for more info. @example configure subnet-mask, ip-address-lease-time, renewal-time, rebinding-time, interface-mtu, domain-name, domain-name-servers; @end example @end deffn @deffn {Client Configuration Directive} append This directive instructs the client to append a value to a DHCP option prior to system configuration. If this option is a list of values, the value specified is merely appended. If this value is a string the value is appended to the string. If this option is a single datum then you should be using the override option instead. @example append domain-name-servers = 127.0.0.1, 192.168.0.1; @end example @end deffn @deffn {Client Configuration Directive} prepend This directive works the same as the append directive only the values are placed at the beginning of the list or string. You should not use prepend on single datum options and should use override instead. @example prepend domain-name-servers = 127.0.0.1, 192.168.0.1; @end example @end deffn @deffn {Client Configuration Directive} override This directive instructs the client to overwrite a DHCP option with a specified value prior to system configuration. This is useful to for clients that wish to use an alternate value for a DHCP option than the one passed by the DHCP server. @example override domain-name = "example.com"; @end example @end deffn @subheading Variable Settings @deffn {Client Configuration Directive} set This directive instructs the client to set a variable to a defined value. @example set default-subnet-mask = 255.255.255.0; @end example @end deffn @deffn {Client Configuration Directive} enable This directive instructs the client to set a boolean variable to a defined value. The boolean variable only accepts ``yes'' or ``no'' for values. @example enable do-measure-router-latency = no; @end example @end deffn @subheading Configurable Variables dhcp-client accepts a number of variables to configure default values, values passed to the server, and control some of its behaviour. @defvr {Client Configuration Variable} hostname This variable can be set to a string which is passed as the hostname DHCP option to the server. This allows servers to pass configuration based on a hostname passed by the client. It will also instruct the client to set the hostname to that variable. If you want to pass a hostname to the server you should set this variable and not use the ``override'' directive because the ``override'' directive only affects system configuration. @example set hostname = "foo.example.com"; @end example @end defvr @defvr {Client Configuration Variable} dhcp-discovery-retries This variable can be set to an integer value which instructs the client on how many times it should retry a DHCP discover before it gives up. @example set dhcp-discovery-retries = 3; @end example @end defvr @defvr {Client Configuration Variable} icmp-retries This variable can be set to an integer value which instructs the client on how many times it should retry an ICMP operation. This affects operations such as router latency discovery, ICMP netmask discovery etc. @example set icmp-retries = 3; @end example @end defvr @defvr {Client Configuration Variable} default-interface-mtu This variable can be set to an integer value which instructs the client on what it's default interface MTU should be. This MTU is used during the initial DHCP discovery messages, and later used to configure the interface MTU if no MTU was specified by the DHCP server. @example set default-interface-mtu = 1500; @end example @end defvr @defvr {Client Configuration Variable} default-subnet-mask This variable can be set to a netmask value to specify a default subnet mask in case none is provided by the DHCP operation. Unlike the ``override'' directive this provides a fallback in case no subnet-mask is provided by the server. @example set default-subnet-mask = 255.255.255.0; @end example @end defvr @defvr {Client Configuration Variable} do-measure-router-latency This variable can be set to a boolean value to indicate whether or not the client should attempt to send ICMP ECHO requests to routers passed by the DHCP server and determine which is one has the least latency to become the default route. Disabling this variable stops this operation from taking place, and the first router is used as the default route. This is useful if the routers cannot be reached by ICMP ECHO requests. @example enable do-measure-router-latency = yes; @end example @end defvr @node Configuring dhcp-server @chapter Configuring dhcp-server @cindex Configuring dhcp-server [TODO] @node Configuring dhcp-relay @chapter Configuring dhcp-relay @cindex Configuring dhcp-relay [TODO] --- NEW FILE: part-2.texi --- @node Invoking dhcp-client @chapter Invoking dhcp-client @cindex Invoking dhcp-client dhcp-client runs on a per interface basis. By default the client will start up, look for the first ethernet interface which is down, and attempt to use it to perform DHCP operations through. You can force the client to use a specific interface by referring it to a particular interface. @xref{Invoking dhcp-client, Command Line Options}. @section Command Line Options @itemize @item -h Print out usage. @item -v Print out version information @item -a Always run in the foreground and do not go into the background. @item -c Clear the cache. This is useful in case a stale cache is left behind by an earlier invocation. @item -k Kill a dhcp-client instance. Coupled with the -i option this will kill a specific instance of dhcp-client. Otherwise the first dhcp-client found on an active ethernet interface is terminated. @item -p Forces dhcp-client to use promiscious mode. This is only useful on systems which are sufficiently broken that require promiscious mode to receive broadcast messages. @item -w Wake a dhcp-client instance. Coupled with the -i option this will wake up a client on a specified interface and cause it to either rebind, or renew earlier depending on which timer is next. Use this to force the client to reacquire a lease. @item -s Print out status information on the most recent lease acquired by the client. @item -i @dfn{interface} Force dhcp-client to use the interface specified. This is useful to make sure dhcp-client uses a specific interface if the host is multi-homed. @item -l @dfn{level} Generate messages at the level specified. The level should be an integer between 0 - 4. The levels are no messages, error messages, info messages (default), warnings, diagnostic-messages, respectively. Each level includes all messages below it. The default is info messages which also include error messages. @item -m @dfn{mac address} Fake a mac address during the DHCP operation. This will only affect the DHCP operations and no others. This is useful for debugging a DHCP server that is not behaving itself. @end itemize @node Invoking dhcp-server @chapter Invoking dhcp-server @cindex Invoking dhcp-server [TODO] @node Invoking dhcp-sniff @chapter Invoking dhcp-sniff @cindex Invoking dhcp-sniff [TODO] @node Invoking dhcp-relay @chapter Invoking dhcp-relay @cindex Invoking dhcp-relay [TODO] --- NEW FILE: part-5.texi --- @node dhcp-sniff Output Format @chapter dhcp-sniff Output Format @cindex dhcp-sniff Output Format [TODO] @node dhcp-client Lease Introspection @chapter dhcp-client Lease Introspection @cindex dhcp-client Lease Introspection [TODO] @node dhcp-server Lease Introspection @chapter dhcp-server Lease Introspection @cindex dhcp-server Lease Introspection [TODO] --- NEW FILE: part-4.texi --- @node Extensions Intro @chapter Extensions Intro @cindex Extensions Intro [TODO] @node Extending dhcp-client @chapter Extending dhcp-client @cindex Extending dhcp-client dhcp-client uses guile (GNU's Ubiquitous Intelligent Language for Extensions) to extend itself. Extensions can currently be written for handling DHCP options during system configuration time. Essentially, the extension script defines how the client configures the local system according to the DHCP options passed. The rest of this section assumes you are familiar with the Scheme programming language. If you are not familiar with the Scheme programming language then you cannot extend the client to configure options it is not programmed to handle. @section The Client Sysconf Script dhcp-client calls a sysconf script which is placed in the same directory as the configuration file. This script, like the configuration file, can be named either ``default.sysconf'' or after an interface name. The file naming convention is the same as the configuration file. @xref{Configuring dhcp-client}. @section Looking At The Sysconf Script The default sysconf script which is shipped with dhcp-agent is made up of several lambda expressions which are placed inside closures. If you're not familiar with the concept of closures, refer to the guile documentation. Under each closure is a configure/unconfigure lambda expression which are bound to top level symbols. These symbols are then placed in two hooks, one for the bound state, and one for the release state. @subsection The DNS Configuration: An Example We'll walk through the DNS configuration (a very simple example) to see how it was written. After this example a more in-depth discussion follows. If you notice some details are skipped over, don't worry. It will become clear later. @example (define configure-dns #f) (define unconfigure-dns #f) @end example First we define two top level symbols to false. We'll later bind against these in the closure. @example (let ((configured-domain-name #f) (configured-domain-name-servers #f) @end example We begin the closure by defining two variables which will be used to hold any configured domain name and domain name servers. For DNS configuration these aren't useful, but for other sysconf code keeping the values of configured data is useful when it comes time to unconfigure the system on a DHCP RELEASE. @example ; check to see if we really need to configure (do-configure (lambda() (and (client-configure? client-control 'dhcp-domain-name-servers) (client-configure? client-control 'dhcp-domain-name) (defined? 'dhcp-domain-name-servers) (defined? 'dhcp-domain-name))))) @end example Here we define a lambda expression which will tell us whether or not we should be performing any configuration for dns. The expression will return true if the options ``domain-name-servers'' and ``domain-name'' have been passed to us by the DHCP server. Also it checks if the user has requested that we configure these options. @example ; configure dns options (set! configure-dns (lambda () (if (do-configure) (let ((resolv-conf-file-port (open "/etc/resolv.conf" (logior O_WRONLY O_TRUNC) 0644))) (client-info-message "configuring resolver") (map-in-order (lambda (dns-server) (simple-format resolv-conf-file-port "nameserver ~A\n" dns-server)) dhcp-domain-name-servers) (simple-format resolv-conf-file-port "search ~A\n" dhcp-domain-name) (close-port resolv-conf-file-port) ; now setup the options so we can use them again in unconfigure. (set! configured-domain-name dhcp-domain-name) (set! configured-domain-name-servers dhcp-domain-name-servers))))) @end example The ``configure-dns'' function will first check if ``do-configure'' returns true. It will then open ``/etc/resolv.conf'' and notify the user that the resolver is being configured. It then writes out the contents of the string list ``dhcp-domain-name-servers'' to the file prefixing each string with the keyword ``nameserver.'' Finally the ``search'' keyword is written with the domain name. After the configuration is complete, the values are stored in ``configured-domain-name'' and ``configured-domain-name-servers.'' This allows us to remember the values in the event of unconfiguring the system. @example ; unconfigure dns options (set! unconfigure-dns (lambda() ; We shouldn't really be doing anything. Any name server ; is a good server :-) #t))) @end example As mentioned in the comment there's no need to do any unconfiguration. We'd rather have a resolv.conf than delete it. You can always modify this to delete the file, or insert a different set of values. @example (add-hook! dhcp-bind-hook configure-dns) (add-hook! dhcp-release-hook unconfigure-dns) @end example Finally the two routines are bound to the DHCP BIND and DHCP RELEASE hooks. It is important to add the option handlers in reverse order. You'll notice ``configure-interface'' is added last so that the interface is configured first. @subsection The DHCP BOUND and DHCP RELEASE hooks Two hooks are defined at the top level by the client. ``dhcp-bind-hook'' and ``dhcp-release-hook.'' When the client wants to configure itself it will call ``dhcp-bind-hook'' and when it releases its lease it will call ``dhcp-release-hook.'' @subsection How DHCP Options Are Passed To The Sysconf Script When the DHCP BOUND hook is called, all the options are defined as top level symbols which refer to either a string, or a list of strings depending on whether the option is a single atom, or a list of atoms [ TODO: make list of handled options along with their types. ] In order to check for the existance of an option, simple use ``defined?'' to check if the symbol is bound. @example ; check for the routers option (defined? 'dhcp-routers) @end example This will return a boolean value of true of false depending on whether the DHCP option has been bound at the top level. @section Scheme Procedures Provided By The Client At the top level a ``client-control'' symbol is bound to a control object which is used in every invocation of routines provided by the client. @deffn {Client Sysconf Routine} client-configure? client-control option-symbol Returns #t of #f depending on whether or not the user has explicitly stated that the dhcp option should be configured. @end deffn @deffn {Client Sysconf Routine} client-interface-up client-control ip-address netmask mtu Initializes the network interface the client is handling and assigns the requested @var{ip-address}, the @var{netmask} and @var{mtu}. @end deffn @deffn {Client Sysconf Routine} client-set-default-route client-control ip-address Sets the default route to the @var{ip-address} specified. @end deffn @deffn {Client Sysconf Routine} client-remove-default-route client-control ip-address Removes the default route to the @var{ip-address} specified. @end deffn @deffn {Client Sysconf Routine} client-get-default-mtu client-control Returns the default mtu specified by the user. @end deffn @deffn {Client Sysconf Routine} client-get-default-subnet-mask client-control Returns the default subnet-mask specified by the user. @end deffn @deffn {Client Sysconf Routine} client-info-message string Prints out the string using the client's @dfn{info_message} routine. @end deffn @deffn {Client Sysconf Routine} client-error-message string Prints out the string using the client's @dfn{error_message} routine. @end deffn @deffn {Client Sysconf Routine} client-fatal-message string Prints out the string using the client's @dfn{fatal_message} routine. This exits after passing the message to the user. @end deffn @deffn {Client Sysconf Routine} client-shutdown client-control Invokes the @dfn{shutdown} routine in the client and causes the client to exit as cleanly as possible, relinquishing any leases it has. Warning! This should not be called from within a release hook. @end deffn @deffn {Client Sysconf Routine} client-discover-icmp-latency client-control address-list Accepts a list of addresses @var{address-list} and performs ICMP ECHO latency tests to determine which host is responding fastest. A list of address/average-latency pairs is returned. @end deffn @deffn {Client Sysconf Routine} client-do-discover-icmp-latency client-control Returns #t if the user enabled ``do-measure-router-latency'' or #f if not. @end deffn @node Extending dhcp-server @chapter Extending dhcp-server @cindex Extending dhcp-server [TODO] Index: dhcp-agent.texi =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/doc/dhcp-agent.texi,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-agent.texi 18 May 2003 03:25:44 -0000 1.2 --- dhcp-agent.texi 22 Jul 2003 20:18:53 -0000 1.3 *************** *** 15,18 **** --- 15,24 ---- @node Top @top dhcp-agent + + This is the reference manual for dhcp-agent, an extendable, portable + UNIX DHCP suite. It contains a brief introduction on DHCP, and an + overview of the suite's features, and is a reference to its operation + and features. + @end ifnottex *************** *** 20,37 **** @c ** add new menu items here. @menu ! * Introduction:: ! * dhcp-client:: ! * dhcp-server:: ! * dhcp-sniff:: ! * dhcp-relay:: @end menu @contents ! @include introduction.texi ! @include dhcp-client.texi ! @include dhcp-server.texi ! @include dhcp-sniff.texi ! @include dhcp-relay.texi @bye --- 26,78 ---- @c ** add new menu items here. @menu ! ! Part I: Introduction to dhcp-agent. ! ! * The dhcp-agent License:: ! * Manual Layout:: ! * Components Overview:: ! * The Dynamic Host Configuration Protocol:: ! * System Specific Notes:: ! ! Part II: Invoking the dhcp-agent components. ! ! * Invoking dhcp-client:: ! * Invoking dhcp-server:: ! * Invoking dhcp-sniff:: ! * Invoking dhcp-relay:: ! ! Part III: Configuration ! ! * Configuration Intro:: ! * Configuring dhcp-client:: ! * Configuring dhcp-server:: ! * Configuring dhcp-relay:: ! ! Part IV: Writing Extensions ! ! * Extensions Intro:: ! * Extending dhcp-client:: ! * Extending dhcp-server:: ! ! Part V: Troubleshooting and Diagnostics ! ! * dhcp-sniff Output Format:: ! * dhcp-client Lease Introspection:: ! * dhcp-server Lease Introspection:: ! ! Appendix ! ! * DHCP Options:: ! @end menu @contents ! @include part-1.texi ! @include part-2.texi ! @include part-3.texi ! @include part-4.texi ! @include part-5.texi ! @include appendix.texi @bye |
From: <act...@us...> - 2003-07-22 20:18:32
|
Update of /cvsroot/dhcp-agent/dhcp-agent/doc In directory sc8-pr-cvs1:/tmp/cvs-serv30544 Removed Files: dhcp-client.texi dhcp-relay.texi dhcp-server.texi dhcp-sniff.texi introduction.texi Log Message: removing old docs --- dhcp-client.texi DELETED --- --- dhcp-relay.texi DELETED --- --- dhcp-server.texi DELETED --- --- dhcp-sniff.texi DELETED --- --- introduction.texi DELETED --- |
From: <act...@us...> - 2003-07-21 05:15:30
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv6815 Modified Files: LICENSE Log Message: updated copyright year Index: LICENSE =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/LICENSE,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LICENSE 30 Oct 2002 05:02:11 -0000 1.2 --- LICENSE 21 Jul 2003 05:15:27 -0000 1.3 *************** *** 1,3 **** ! Copyright 2002 Thamer Alharbash <tm...@wh...> Redistribution and use in source and binary forms, with or without --- 1,3 ---- ! Copyright 2002, 2003 Thamer Alharbash <tm...@wh...> Redistribution and use in source and binary forms, with or without |
From: <act...@us...> - 2003-07-21 05:15:20
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv6782 Modified Files: acinclude.m4 configure.ac Log Message: now using Albert Chin's patch to libtool; added clearer messages for failure of locating dependencies Index: acinclude.m4 =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/acinclude.m4,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** acinclude.m4 18 May 2003 02:58:25 -0000 1.2 --- acinclude.m4 21 Jul 2003 05:15:16 -0000 1.3 *************** *** 31,41 **** fi done - - if test $ac_pcap_lib_dir = "none" ; then - AC_MSG_ERROR([ - I cannot find the pcap library anywhere. Perhaps you did not install - the pcap package, or you did not install its development header files.], 1) - fi - AC_MSG_RESULT($ac_pcap_lib_dir)]) --- 31,34 ---- Index: configure.ac =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.ac,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** configure.ac 16 Jul 2003 05:42:24 -0000 1.16 --- configure.ac 21 Jul 2003 05:15:16 -0000 1.17 *************** *** 17,20 **** --- 17,22 ---- AM_INIT_AUTOMAKE([dhcp-agent], [0.41]) AC_CONFIG_SRCDIR([src/dhcp-client.c]) + AC_LANG(C) + AC_LIBTOOL_TAGS([]) dnl *************** *** 142,145 **** --- 144,164 ---- AC_WF_CHECK_PCAP_LIB_DIR + + if test x$ac_pcap_lib_dir = "xnone"; then + + echo --------------------------------------------------------- + echo Could not find libpcap on this system. + echo This package uses libpcap to perform low level + echo packet capturing. + echo + echo You will need to download a copy of libpcap from: + echo + echo http://www.tcpdump.org/ + echo + echo ---------------------------------------------------------- + + exit -1 + fi + PCAP_LIB="-L$ac_pcap_lib_dir -lpcap" *************** *** 209,213 **** if test $DNET_PATH = "no"; then ! AC_MSG_ERROR([libdnet not found. get a copy from http://libdnet.sourceforge.net]) else --- 228,242 ---- if test $DNET_PATH = "no"; then ! echo --------------------------------------------------------- ! echo Could not libdnet on this system. ! echo This package uses libdnet for portable low level networking ! echo ! echo You will need to download a copy of libdnet from: ! echo ! echo http://libdnet.sourceforge.net/ ! echo ! echo ---------------------------------------------------------- ! ! exit -1 else *************** *** 222,226 **** if test $GUILE_PATH = "no"; then ! AC_MSG_ERROR([could not find guile on this system. get a copy from http://www.gnu.org/software/guile]) else --- 251,266 ---- if test $GUILE_PATH = "no"; then ! echo --------------------------------------------------------- ! echo Could not find guile on this system. ! echo This package uses guile to allow it to be extended by the ! echo Scheme programming language. ! echo ! echo You will need to download a copy of guile from: ! echo ! echo http://www.gnu.org/software/guile ! echo ! echo ---------------------------------------------------------- ! ! exit -1 else *************** *** 234,238 **** if test $TEXI2HTML_PATH = "no"; then ! AC_MSG_ERROR([you selected --enable-htmldoc and no texi2html has been found. please install texi2html first.]) fi; fi --- 274,291 ---- if test $TEXI2HTML_PATH = "no"; then ! ! echo --------------------------------------------------------- ! echo Could not find texi2html on this system. ! echo This package uses texi2html to create HTML ! echo documentation from raw texi sources. ! echo ! echo You will need to download a copy of texi2html from: ! echo ! echo http://www.mathematik.uni-kl.de/~obachman/Texi2html ! echo ! echo ---------------------------------------------------------- ! ! exit -1 ! fi; fi |
From: <act...@us...> - 2003-07-20 05:52:34
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1609/src Modified Files: dhcp-server-control.c dhcp-server-states.c dhcp-server.c dhcp-server.h Log Message: update to server code; now using udp socket for DHCP and rawnet for everything else; added skeleton for state machine Index: dhcp-server-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-control.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-server-control.c 8 Jul 2003 07:05:07 -0000 1.3 --- dhcp-server-control.c 20 Jul 2003 05:52:31 -0000 1.4 *************** *** 35,39 **** dhcp_server_control_t *dhcp_server_control_create(const char *interface) { ! int dport, sport; stringbuffer_t *filter; dhcp_server_control_t *dhcp_server_control; --- 35,39 ---- dhcp_server_control_t *dhcp_server_control_create(const char *interface) { ! int port; stringbuffer_t *filter; dhcp_server_control_t *dhcp_server_control; *************** *** 47,74 **** } ! /* get the source port and destination port for BOOTP. */ ! dport = rawnet_port_for_service("bootps", "udp"); ! sport = rawnet_port_for_service("bootpc", "udp"); ! ! dport = ntohs(dport); ! sport = ntohs(sport); ! if(dport == -1 || sport == -1) { WARN_MESSAGE ("could not lookup dhcp services in service db (%s) will use reasonable defaults."); ! sport = BOOTP_CLIENT; ! dport = BOOTP_SERVER; } /* Create filter. */ filter = stringbuffer_create(); ! stringbuffer_aprintf(filter, "arp or icmp or (udp and src port %d)", sport); ! /* create rawnet handler. */ ! if((dhcp_server_control->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), -1, sport, ! dport, 0, 0)) == NULL) { FATAL_MESSAGE("could not create raw network handler."); } --- 47,78 ---- } ! /* get the source port for BOOTP. */ ! port = rawnet_port_for_service("bootpc", "udp"); ! if(port == -1) { WARN_MESSAGE ("could not lookup dhcp services in service db (%s) will use reasonable defaults."); ! port = BOOTP_SERVER; } + port = ntohs(port); + /* Create filter. */ filter = stringbuffer_create(); ! stringbuffer_aprintf(filter, "arp or icmp"); ! /* create rawnet handler: we pass sport/dport as 0 because we ! * won't be doing any DHCP handling rawly for the server. */ ! if((dhcp_server_control->rawnet = rawnet_create(interface, stringbuffer_getstring(filter), -1, 0, ! 0, 0, 0)) == NULL) { FATAL_MESSAGE("could not create raw network handler."); + } + + if((dhcp_server_control->udp_sock = + udp_sock_create(port, + rawnet_get_ip_addr(dhcp_server_control->rawnet))) < 0) { + FATAL_MESSAGE("unable to open udp socket"); } Index: dhcp-server-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-states.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-server-states.c 15 Jul 2003 10:57:55 -0000 1.3 --- dhcp-server-states.c 20 Jul 2003 05:52:31 -0000 1.4 *************** *** 38,48 **** /******************************* * event processing routines. * *******************************/ static int server_next_event(dhcp_server_control_t *sc) { ! ! return 0; } --- 38,137 ---- /******************************* + * utilities * + *******************************/ + + /* turn an interrupt type to an event. */ + int interrupt2event(void) + { + /* convert current interrupt to event type. */ + switch(got_interrupt_type()) { + + case INTERRUPT_ALARM: + return SERVER_EVENT_LEASE_EXPIRE; + + case INTERRUPT_HUP: + return SERVER_EVENT_USER_HUP; + + case INTERRUPT_TERM: + return SERVER_EVENT_TERMINATE; + + default: + FATAL_MESSAGE("received illegal signal type"); + exit(1); + } + + } + + /******************************* * event processing routines. * *******************************/ + /* process next event: this means waiting for data on our udp descriptor or getting an interrupt. */ static int server_next_event(dhcp_server_control_t *sc) { ! struct timeval timeout; ! int retval; ! fd_set fd; ! ! /* allow signal starvation if necessary, but we don't want to ! * handle interrupts with gaps in between for everyime we ! * select. call once at the beginning and per select ! * timeout. */ ! ! if(check_for_interrupts()) { ! return interrupt2event(); ! } ! ! while(1) { ! ! FD_ZERO(&fd); ! FD_SET(sc->udp_sock, &fd); ! ! /* main even handling loop. we return one of the event ! * types depending on whether we received data, or caught ! * a signal. */ ! ! timeout.tv_usec = 0; ! timeout.tv_sec = server_conf_get_poll_timeout(sc->server_conf); ! ! /* Why pass a timeout to select? We check for signals ! * atomically. There's no way to run select, and catch ! * signals which would just set a global variable. For ! * example: ! * ! * unblock_interrupts(); ! * retval = select(sc->udp_sock + 1, &fd, NULL, NULL, NULL); ! * ! * Would not work. There is a race condition in between ! * unblocking and the call to select. ! * ! * To get around this we implement a small but reasonable ! * timeout. It's user configurable, but by default we set ! * it to something small like 5 seconds. On today's ! * hardware this doesn't hurt at all. We literally run a ! * bunch of syscalls to check for interrupts and then get ! * back in the select. */ ! ! retval = select(sc->udp_sock + 1, &fd, NULL, NULL, &timeout); ! ! if(retval < 0) { ! /* this is very bad. */ ! ERROR_MESSAGE("error from select(): %s", strerror(errno)); ! FATAL_MESSAGE("I cannot carry on. exiting."); ! } ! ! if(retval == 0) { /* timeout */ ! ! if(check_for_interrupts()) { ! return interrupt2event(); /* check for interrupt. */ ! } ! } ! ! if(retval > 0) { /* we have data. */ ! ! return SERVER_EVENT_DATA_WAITING; ! } ! } ! } *************** *** 56,70 **** * receive one of the following events back. * - * (1) SERVER_EVENT_LEASE_EXPIRE - * (2) SERVER_EVENT_DATA_WAITING - * */ ! int server_wait(dhcp_server_control_t *sc) { ! server_next_event(sc); return STATE_SHUTDOWN; } int server_shutdown(dhcp_server_control_t *sc) { --- 145,179 ---- * receive one of the following events back. * */ ! /* main loop: essentially an event2state converter. */ ! int server_listen(dhcp_server_control_t *sc) { ! int event; ! ! event = server_next_event(sc); ! ! switch(event) { ! ! case SERVER_EVENT_LEASE_EXPIRE: ! return STATE_CLEAN_LEASES; ! ! case SERVER_EVENT_DATA_WAITING: ! return STATE_HANDLE_PACKET; ! ! case SERVER_EVENT_USER_HUP: ! return STATE_HUP; ! ! case SERVER_EVENT_TERMINATE: ! return STATE_SHUTDOWN; ! ! default: ! FATAL_MESSAGE("illegal event generated. this is a bug. report me."); ! } ! return STATE_SHUTDOWN; } + /* shutdown state. */ int server_shutdown(dhcp_server_control_t *sc) { *************** *** 81,82 **** --- 190,210 ---- } + /* handle an incoming DHCP packet. */ + int server_handle_packet(dhcp_server_control_t *sc) + { + /* TODO. */ + return STATE_LISTEN; + } + + /* handle user hup. */ + int server_hup(dhcp_server_control_t *sc) + { + /* TODO. */ + return STATE_LISTEN; + } + + int server_clean_leases(dhcp_server_control_t *sc) + { + /* TODO. */ + return STATE_LISTEN; + } Index: dhcp-server.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-server.c 15 Jul 2003 10:57:18 -0000 1.8 --- dhcp-server.c 20 Jul 2003 05:52:31 -0000 1.9 *************** *** 63,68 **** server_state server_states[] = { - NULL, server_shutdown, }; --- 63,71 ---- server_state server_states[] = { server_shutdown, + server_listen, + server_clean_leases, + server_handle_packet, + server_hup, }; *************** *** 134,137 **** --- 137,141 ---- INFO_MESSAGE("default-rebind-percent: %d", server_conf->default_rebind_percent); INFO_MESSAGE("default-renew-percent: %d", server_conf->default_renew_percent); + INFO_MESSAGE("poll-timeout: %d", server_conf->poll_timeout); INFO_MESSAGE(" "); Index: dhcp-server.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-server.h 15 Jul 2003 10:57:55 -0000 1.5 --- dhcp-server.h 20 Jul 2003 05:52:31 -0000 1.6 *************** *** 32,35 **** --- 32,36 ---- server_conf_t *server_conf; /* server configuration. */ + int udp_sock; /* udp socket. */ } dhcp_server_control_t; *************** *** 41,46 **** /* constants. */ enum command_codes { DO_VERSION = 0, DO_KILL, DO_STATUS, DO_SERVER, DO_CHECK_CONFIG }; ! enum server_states { STATE_LISTEN, STATE_SHUTDOWN = 0 }; ! enum server_events { SERVER_EVENT_DATA_WAITING = 0, SERVER_EVENT_LEASE_EXPIRE, SERVER_EVENT_ERROR }; /* prototypes. */ --- 42,47 ---- /* constants. */ enum command_codes { DO_VERSION = 0, DO_KILL, DO_STATUS, DO_SERVER, DO_CHECK_CONFIG }; ! enum server_states { STATE_SHUTDOWN = 0, STATE_LISTEN, STATE_CLEAN_LEASES, STATE_HANDLE_PACKET, STATE_HUP }; ! enum server_events { SERVER_EVENT_LEASE_EXPIRE = 0, SERVER_EVENT_DATA_WAITING, SERVER_EVENT_USER_HUP, SERVER_EVENT_TERMINATE }; /* prototypes. */ *************** *** 50,53 **** --- 51,58 ---- extern int server_shutdown(dhcp_server_control_t *sc); + extern int server_listen(dhcp_server_control_t *sc); + extern int server_clean_leases(dhcp_server_control_t *sc); + extern int server_handle_packet(dhcp_server_control_t *sc); + extern int server_hup(dhcp_server_control_t *sc); #endif /* DHCP_SERVER_H */ |
From: <act...@us...> - 2003-07-20 05:51:38
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1529/src Modified Files: dhcp-server-conf.c Log Message: fixes to server conf code Index: dhcp-server-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-conf.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-server-conf.c 15 Jul 2003 10:56:34 -0000 1.8 --- dhcp-server-conf.c 20 Jul 2003 05:51:35 -0000 1.9 *************** *** 326,329 **** --- 326,330 ---- default: ERROR_MESSAGE("illegal directive specified in a range lease definition"); + return 1; } } |
From: <act...@us...> - 2003-07-20 05:50:59
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1450/src Modified Files: dhcp-librawnet.h Log Message: prototype for icmp echo now in librawnet Index: dhcp-librawnet.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** dhcp-librawnet.h 5 Jul 2003 19:18:17 -0000 1.21 --- dhcp-librawnet.h 20 Jul 2003 05:50:56 -0000 1.22 *************** *** 580,583 **** --- 580,584 ---- extern int icmp_subnet_mask_discovery(rawnet_t *net, int retries, uint32_t *subnet_mask); extern list_t *icmp_rtt_discovery(rawnet_t *net, int timeout, int sends, int arp_retries, int arp_timeout, list_t *addresses); + extern int icmp_do_echo(rawnet_t *net, ip_addr_t dest_addr, eth_addr_t dest_mac); /* ARP discovery routines. */ |
From: <act...@us...> - 2003-07-20 05:49:52
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1313/src Modified Files: dhcp-net.c dhcp-libutil.h Log Message: fixed up udp code Index: dhcp-net.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-net.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-net.c 17 Jul 2003 13:18:10 -0000 1.4 --- dhcp-net.c 20 Jul 2003 05:49:49 -0000 1.5 *************** *** 42,46 **** if((sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { ! FATAL_MESSAGE("unable to open UDP socket: %s", strerror(errno)); } --- 42,47 ---- if((sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { ! ERROR_MESSAGE("unable to open UDP socket: %s", strerror(errno)); ! return -1; } *************** *** 48,60 **** if(setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &opt_on, len) < 0) { ! FATAL_MESSAGE("unable to set SO_REUSEADDR on socket: %s", strerror(errno)); } if(setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &opt_on, len) < 0) { ! FATAL_MESSAGE("unable to set SO_BROADCAST on socket: %s", strerror(errno)); } if(fcntl(sd, F_SETFL, O_NONBLOCK) < 0) { ! FATAL_MESSAGE("unable to set O_NONBLOCK on socket: %s", strerror(errno)); } --- 49,64 ---- if(setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &opt_on, len) < 0) { ! ERROR_MESSAGE("unable to set SO_REUSEADDR on socket: %s", strerror(errno)); ! return -1; } if(setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &opt_on, len) < 0) { ! ERROR_MESSAGE("unable to set SO_BROADCAST on socket: %s", strerror(errno)); ! return -1; } if(fcntl(sd, F_SETFL, O_NONBLOCK) < 0) { ! ERROR_MESSAGE("unable to set O_NONBLOCK on socket: %s", strerror(errno)); ! return -1; } *************** *** 66,70 **** if(bind(sd, (struct sockaddr *)&myaddr, len) < 0) { ! FATAL_MESSAGE("unable to bind UDP socket: %s", strerror(errno)); } --- 70,75 ---- if(bind(sd, (struct sockaddr *)&myaddr, len) < 0) { ! ERROR_MESSAGE("unable to bind UDP socket: %s", strerror(errno)); ! return -1; } *************** *** 113,162 **** if(retval != size) - return 1; - - return 0; - } - - /* read a line in from a tcp socket. */ - char *tcp_sock_read_line(int sock) - { - stringbuffer_t *sb; - char c; - int retval; - char *line; - - sb = stringbuffer_create(); - - while(1) { - - retval = recv(sock, &c, 1 , 0); - if(retval == -1) { - stringbuffer_destroy(sb); - return NULL; - } - - if(c != '\n') { - - stringbuffer_append_c(sb, c); - - } else { - - /* we're done. */ - line = xstrdup(stringbuffer_getstring(sb)); - stringbuffer_destroy(sb); - return line; - } - } - } - - /* write a line to a tcp socket. */ - int tcp_sock_write_line(int sock, const char *line) - { - int len = strlen(line); - - if(send(sock, line, len, 0) != len) - return 1; - - if(send(sock, "\n", 1, 0) != 1) return 1; --- 118,121 ---- Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** dhcp-libutil.h 17 Jul 2003 13:18:37 -0000 1.31 --- dhcp-libutil.h 20 Jul 2003 05:49:49 -0000 1.32 *************** *** 320,325 **** extern size_t udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr); extern int udp_sock_send(int udp_sock, uint8_t *msg, size_t size, ip_addr_t dst_addr, uint16_t dest_port); - extern char *tcp_sock_read_line(int sock); - extern int tcp_sock_write_line(int sock, const char *line); /* constants. */ --- 320,323 ---- |
From: <act...@us...> - 2003-07-20 05:48:39
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv1192 Modified Files: INSTALL README Log Message: fixes to top level texts Index: INSTALL =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/INSTALL,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** INSTALL 19 Jul 2003 02:28:05 -0000 1.4 --- INSTALL 20 Jul 2003 05:48:35 -0000 1.5 *************** *** 2,6 **** ----------------------- ! Prerequisites ------------- --- 2,6 ---- ----------------------- ! Dependencies ------------- Index: README =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/README,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README 19 Jul 2003 02:28:05 -0000 1.12 --- README 20 Jul 2003 05:48:36 -0000 1.13 *************** *** 57,61 **** When submitting patches please try to keep your programming style ! consistent with ours. This shouldn't be too hard, Installing: --- 57,61 ---- When submitting patches please try to keep your programming style ! consistent with ours. This shouldn't be too hard. Installing: |
From: <act...@us...> - 2003-07-19 02:28:09
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv10572 Modified Files: README INSTALL TODO Log Message: update to top level text files Index: README =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/README,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** README 8 Jul 2003 17:48:55 -0000 1.11 --- README 19 Jul 2003 02:28:05 -0000 1.12 *************** *** 1,33 **** $Header$ ! dhcp-agent ! ---------- ! ! This is a pre-release version of dhcp-agent. ! ! dhcp-agent will be a complete DHCP client/server suite, with a ! number of tools for network troubleshooting, and configuration. In ! its current state a simple dhcp sniffer and an beta-quality dhcp ! client have been implemented. ! ! The current implementation of the dhcp-server is just skeleton ! code. Expect a complete server in the next month (hopefully). ! ! Your help in building and testing this suite will be much ! appreciated. ! Please know that, only the desperate and depraved would run the ! client on a production machine. ! Read the INSTALL file for instructions on compiling and installing dhcp-agent. The project's website is: ! http://dhcp-agent.sf.net/ Supported Platforms ------------------- ! dhcp-agent has been tested on: GNU/Linux 2.4.x (i386) --- 1,30 ---- $Header$ ! dhcp-agent: A Portable, and ! Extendable UNIX DHCP Suite ! --------------------------------------- ! dhcp-agent is a portable and extendable UNIX DHCP Suite. It is ! portable because it relies on two portable raw network layer ! libraries: libdnet, and libpcap. In addition to that, we've done ! our best to keep the C code as portable as possible. Still, some ! work may be needed to get this suite to work on exotic UNIX ! flavors. We'll gladly accept patches for that purpose. ! The DHCP suite's components are extendable, where applicable, ! with the Scheme programming language. This is done by embedding ! guile, GNU's Ubiquitous Intelligent Language for Extension. If ! you're a fellow Schemer then this feature will make you very ! happy. If not, don't worry. The suite is still useable without ! you writing extensions for it. The project's website is: ! http://dhcp-agent.sourceforge.net/ Supported Platforms ------------------- ! dhcp-agent has been tested, and built (using GCC) on: GNU/Linux 2.4.x (i386) *************** *** 36,39 **** --- 33,67 ---- Solaris 2.8 (SPARC) + State of the code: + ------------------ + + This is a pre-release version of dhcp-agent. The suite is still + in development mode, and needs as much testing and bug reporting + as you, the user, can provide. + + Currently a beta quality DHCP client, and sniffer have been + implemented. There are a few quirks with both these components + but we believe they're ready for you to test and probably use + with some measure of success. + + We've had reports of users who have used the client with a + greater measure of success than they had with other DHCP clients. + + The DHCP server is currently being developed, and we do not + believe it is ready for use. + + Most of the code is OK. Some FIXMEs crop up and are taken care of + in between releases. Some parts are becoming ugly, or badly + named. Currently, we do not have a hacker's guide. The code is + the documentation if you plan on hacking on it. + + When submitting patches please try to keep your programming style + consistent with ours. This shouldn't be too hard, + + Installing: + ----------- + + Read the INSTALL file for instructions on compiling and installing dhcp-agent. + Support ------- *************** *** 71,74 **** --- 99,105 ---- bug is found -- while allowing you, the user, to get any quick fixes, patches, and workarounds for known issues. + + I announce major updates to the ERRATA file on the + dhcp-agent-users list Documentation Index: INSTALL =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/INSTALL,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INSTALL 28 Jun 2003 02:21:29 -0000 1.3 --- INSTALL 19 Jul 2003 02:28:05 -0000 1.4 *************** *** 1,4 **** ! dhcp-agent ! ---------- Prerequisites --- 1,4 ---- ! dhcp-agent Installation ! ----------------------- Prerequisites *************** *** 47,58 **** To install: "make install;" If you are using a system which does not use GNU make by default, please install GNU make. Usually it is installed as "gmake" - To install with GNU make explicitly: "gmake install;" - Before installing please uninstall any previous distribution of ! dhcp-agent, or dhcp suite package. Make sure you also disabled ! any dhcp client or server running on the host. Additional Configuration Options --- 47,60 ---- To install: "make install;" + Tp install a stripped version, which will take up less space: + + "make install-strip" + If you are using a system which does not use GNU make by default, please install GNU make. Usually it is installed as "gmake" Before installing please uninstall any previous distribution of ! dhcp-agent. Make sure you also disabled any dhcp client or server ! running on the host before running components of dhcp-agent. Additional Configuration Options Index: TODO =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/TODO,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** TODO 10 Jul 2003 23:18:53 -0000 1.21 --- TODO 19 Jul 2003 02:28:05 -0000 1.22 *************** *** 1,24 **** ! [ Quite a bit! ] ! ! Things that need to be done for RFC compliance: ! ! -- allow options to be concantonated together (which ! extend over 255 octets) ! probably many more to come once the rest of the todos are ! complete. currently the client seems to be behaving properly. ! major todos: ! -- make dhcpclient relay agent friendly ! -- check rfcs for any catch 22s ! -- write dhcpserver ! -- write dhcpdiscover ! a scanner to output information on servers/relay agents ! responding ! other todo: -- rawnet_is_valid needs more checks. --- 1,23 ---- ! TODO List ! ---------- ! Current Status ! -------------- ! dhcp-client : beta ! dhcp-sniff : beta ! dhcp-server : vapour ! dhcp-relay : vapour ! Things we need to do: ! --------------------- ! -- allow options to be concantonated together (which ! extend over 255 octets) ! -- make dhcp-client relay agent friendly ! -- check rfcs for any catch 22s ! -- write dhcp-server -- rawnet_is_valid needs more checks. *************** *** 38,42 **** -- stringbuffer used in almost _all_ string operations except really simple ones. ! -- document output from dhcpsniff -- especially how brief mode is layed out. -- in dhcp-tokenizer use mmap() to implement nicer peeking. --- 37,41 ---- -- stringbuffer used in almost _all_ string operations except really simple ones. ! -- document output from dhcp-sniff -- especially how brief mode is layed out. -- in dhcp-tokenizer use mmap() to implement nicer peeking. |
From: <act...@us...> - 2003-07-17 13:18:40
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv2777/src Modified Files: dhcp-libutil.h Log Message: added new prototypes for tcp routines and new fork_and_exec Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** dhcp-libutil.h 17 Jul 2003 00:21:38 -0000 1.30 --- dhcp-libutil.h 17 Jul 2003 13:18:37 -0000 1.31 *************** *** 313,316 **** --- 313,317 ---- extern void go_background(char *dir); extern void setup_interrupt_handlers(void); + extern int fork_and_exec(const char *path_to_exec); /* udp socket routines. */ *************** *** 319,322 **** --- 320,325 ---- extern size_t udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr); extern int udp_sock_send(int udp_sock, uint8_t *msg, size_t size, ip_addr_t dst_addr, uint16_t dest_port); + extern char *tcp_sock_read_line(int sock); + extern int tcp_sock_write_line(int sock, const char *line); /* constants. */ |
From: <act...@us...> - 2003-07-17 13:18:13
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv2683/src Modified Files: dhcp-net.c Log Message: added tcp routines Index: dhcp-net.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-net.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-net.c 17 Jul 2003 00:21:38 -0000 1.3 --- dhcp-net.c 17 Jul 2003 13:18:10 -0000 1.4 *************** *** 117,118 **** --- 117,164 ---- return 0; } + + /* read a line in from a tcp socket. */ + char *tcp_sock_read_line(int sock) + { + stringbuffer_t *sb; + char c; + int retval; + char *line; + + sb = stringbuffer_create(); + + while(1) { + + retval = recv(sock, &c, 1 , 0); + if(retval == -1) { + stringbuffer_destroy(sb); + return NULL; + } + + if(c != '\n') { + + stringbuffer_append_c(sb, c); + + } else { + + /* we're done. */ + line = xstrdup(stringbuffer_getstring(sb)); + stringbuffer_destroy(sb); + return line; + } + } + } + + /* write a line to a tcp socket. */ + int tcp_sock_write_line(int sock, const char *line) + { + int len = strlen(line); + + if(send(sock, line, len, 0) != len) + return 1; + + if(send(sock, "\n", 1, 0) != 1) + return 1; + + return 0; + } |
From: <act...@us...> - 2003-07-17 13:12:57
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv1545/src Modified Files: dhcp-daemon.c Log Message: added routine to fork helper child Index: dhcp-daemon.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-daemon.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-daemon.c 25 May 2003 02:18:46 -0000 1.5 --- dhcp-daemon.c 17 Jul 2003 13:12:54 -0000 1.6 *************** *** 209,210 **** --- 209,251 ---- return; } + + int fork_and_exec(const char *path_to_exec) + { + int fdpair[2]; + + /* open socket pair. */ + if(socketpair(PF_UNIX, SOCK_STREAM, 0, fdpair) == -1) { + return -1; + } + + /* fork out. */ + switch(fork()) { + + case 0: /* child. */ + + /* close up stdin, stdout, stderr. */ + + close(0); + close(1); + close(2); + + dup2(fdpair[1], 0); + dup2(fdpair[1], 1); + dup2(fdpair[1], 2); + close(fdpair[0]); + execl(path_to_exec, NULL); + + /* we should never get here unless something is + * tragically broken. */ + + exit(1); + + case -1: /* error. */ + return -1; + + default: /* parent. */ + + close(fdpair[1]); + return fdpair[0]; + } + } |
From: <act...@us...> - 2003-07-17 00:35:57
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv22667/src Modified Files: dhcp-client-control.c Log Message: fix to client: check for failed service lookup before converting to host order Index: dhcp-client-control.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-control.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** dhcp-client-control.c 25 Jun 2003 03:08:32 -0000 1.19 --- dhcp-client-control.c 17 Jul 2003 00:35:52 -0000 1.20 *************** *** 147,153 **** sport = rawnet_port_for_service("bootpc", "udp"); - dport = ntohs(dport); - sport = ntohs(sport); - if(dport == -1 || sport == -1) { --- 147,150 ---- *************** *** 158,161 **** --- 155,161 ---- dport = BOOTP_SERVER; } + + dport = ntohs(dport); + sport = ntohs(sport); /* Create filter. */ |
From: <act...@us...> - 2003-07-17 00:22:35
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv21332/src Modified Files: Makefile.am Log Message: dhcp-net.c now compiled as part of the utility library Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/Makefile.am,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Makefile.am 12 Jul 2003 17:42:36 -0000 1.31 --- Makefile.am 17 Jul 2003 00:22:28 -0000 1.32 *************** *** 53,57 **** dhcp-option-convert.c \ dhcp-daemon.c \ ! dhcp-options-strings.c --- 53,58 ---- dhcp-option-convert.c \ dhcp-daemon.c \ ! dhcp-options-strings.c \ ! dhcp-net.c |
From: <act...@us...> - 2003-07-17 00:21:43
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv21221/src Modified Files: dhcp-libutil.h Added Files: dhcp-net.c Log Message: new udp socket routines for socket level networking Index: dhcp-libutil.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-libutil.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** dhcp-libutil.h 8 Jul 2003 07:01:42 -0000 1.29 --- dhcp-libutil.h 17 Jul 2003 00:21:38 -0000 1.30 *************** *** 134,137 **** --- 134,142 ---- } conf_t; + /* udp socket object. */ + typedef struct { + int sockd; + } udp_sock_t; + /* prototypes. */ *************** *** 306,312 **** /* daemon routines. */ - extern void go_background(char *dir); extern void setup_interrupt_handlers(void); /* constants. */ --- 311,322 ---- /* daemon routines. */ extern void go_background(char *dir); extern void setup_interrupt_handlers(void); + + /* udp socket routines. */ + extern int udp_sock_create(uint16_t source_port, ip_addr_t local_addr); + extern void udp_sock_destroy(int sd); + extern size_t udp_sock_recv(int sd, uint8_t *buff, size_t buffsize, ip_addr_t *src_addr); + extern int udp_sock_send(int udp_sock, uint8_t *msg, size_t size, ip_addr_t dst_addr, uint16_t dest_port); /* constants. */ |
From: <act...@us...> - 2003-07-16 05:42:31
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv23074 Modified Files: configure.ac config.h.in Log Message: added pcap_setnonblock Index: configure.ac =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.ac,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** configure.ac 15 Jul 2003 11:01:27 -0000 1.15 --- configure.ac 16 Jul 2003 05:42:24 -0000 1.16 *************** *** 158,162 **** dnl check for pcap_freecode - AC_MSG_CHECKING([pcap_freecode in pcap]) LIBS=$PCAP_LIB --- 158,161 ---- *************** *** 174,177 **** --- 173,192 ---- distribution from http://www.tcpdump.org/]) fi + + dnl check for pcap_setnonblock + + AC_MSG_CHECKING([pcap_setnonblock in pcap]) + LIBS=$PCAP_LIB + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ pcap_setnonblock(); ]])],[ have_pcap_setnonblock="yes" ],[ have_pcap_setnonblock="no" ]) + LIBS= + + if test x$have_pcap_setnonblock = "xyes"; then + AC_MSG_RESULT([found]) + AC_DEFINE(HAVE_PCAP_SETNONBLOCK, 1, [have pcap_nonblock()]) + else + AC_MSG_RESULT([not found]) + fi + + dnl check for BIOCIMMEDIATE AC_MSG_CHECKING(BIOCIMMEDIATE) Index: config.h.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/config.h.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** config.h.in 9 Jun 2003 02:01:01 -0000 1.6 --- config.h.in 16 Jul 2003 05:42:24 -0000 1.7 *************** *** 34,37 **** --- 34,40 ---- #undef HAVE_PCAP_FREECODE + /* have pcap_nonblock() */ + #undef HAVE_PCAP_SETNONBLOCK + /* have __progname var */ #undef HAVE_PROGNAME |
From: <act...@us...> - 2003-07-16 05:42:31
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv23074/src Modified Files: dhcp-rawnet.c Log Message: added pcap_setnonblock Index: dhcp-rawnet.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-rawnet.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-rawnet.c 6 Jul 2003 05:37:23 -0000 1.12 --- dhcp-rawnet.c 16 Jul 2003 05:42:24 -0000 1.13 *************** *** 187,190 **** --- 187,200 ---- #endif /* HAVE_PCAP_FREECODE */ + #if defined(HAVE_PCAP_NONBLOCK) + + if(pcap_setnonblock(pcap, 1, errbuf) < 0) { + ERROR_MESSAGE("could not set pcap into nonblocking mode: %s", errbuf); + pcap_close(pcap); + return NULL; + } + + #endif /* HAVE_PCAP_NONBLOCK */ + #if defined(HAVE_BPF_IMMEDIATE) /* FreeBSD, and possibly other flavors with BPF need us to |
From: <act...@us...> - 2003-07-15 11:01:32
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory sc8-pr-cvs1:/tmp/cvs-serv3470 Modified Files: configure.ac Log Message: bump up version to 0.41 Index: configure.ac =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/configure.ac,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** configure.ac 6 Jul 2003 17:08:59 -0000 1.14 --- configure.ac 15 Jul 2003 11:01:27 -0000 1.15 *************** *** 14,19 **** AC_PREREQ(2.57) ! AC_INIT([dhcp-agent],[0.39],[tm...@wh...]) ! AM_INIT_AUTOMAKE([dhcp-agent], [0.40]) AC_CONFIG_SRCDIR([src/dhcp-client.c]) --- 14,19 ---- AC_PREREQ(2.57) ! AC_INIT([dhcp-agent],[0.41],[tm...@wh...]) ! AM_INIT_AUTOMAKE([dhcp-agent], [0.41]) AC_CONFIG_SRCDIR([src/dhcp-client.c]) |
From: <act...@us...> - 2003-07-15 10:57:59
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv3026/src Modified Files: dhcp-server-states.c dhcp-server.h Log Message: added stuff to states Index: dhcp-server-states.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server-states.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-server-states.c 8 Jul 2003 07:06:40 -0000 1.2 --- dhcp-server-states.c 15 Jul 2003 10:57:55 -0000 1.3 *************** *** 36,42 **** --- 36,69 ---- #include "dhcp-server.h" + + /******************************* + * event processing routines. * + *******************************/ + + static int server_next_event(dhcp_server_control_t *sc) + { + + return 0; + } + /*************************** * server states * ***************************/ + + /* server wait: this is the main server loop. + * + * We call server_next_event() and we + * receive one of the following events back. + * + * (1) SERVER_EVENT_LEASE_EXPIRE + * (2) SERVER_EVENT_DATA_WAITING + * + */ + + int server_wait(dhcp_server_control_t *sc) + { + server_next_event(sc); + return STATE_SHUTDOWN; + } int server_shutdown(dhcp_server_control_t *sc) Index: dhcp-server.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-server.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-server.h 13 Jul 2003 04:53:30 -0000 1.4 --- dhcp-server.h 15 Jul 2003 10:57:55 -0000 1.5 *************** *** 42,45 **** --- 42,46 ---- enum command_codes { DO_VERSION = 0, DO_KILL, DO_STATUS, DO_SERVER, DO_CHECK_CONFIG }; enum server_states { STATE_LISTEN, STATE_SHUTDOWN = 0 }; + enum server_events { SERVER_EVENT_DATA_WAITING = 0, SERVER_EVENT_LEASE_EXPIRE, SERVER_EVENT_ERROR }; /* prototypes. */ |