[Dhcp-agent-commits] CVS: dhcp-agent Makefile.am,1.6,1.7 Makefile.in,1.6,1.7 dhcp-client.c,1.12,1.13
Status: Alpha
Brought to you by:
actmodern
|
From: Thamer Al-H. <act...@us...> - 2002-02-08 17:04:36
|
Update of /cvsroot/dhcp-agent/dhcp-agent
In directory usw-pr-cvs1:/tmp/cvs-serv8818
Modified Files:
Makefile.am Makefile.in dhcp-client.c dhcp-convert.c
dhcp-files.c dhcp-sysconf.c dhcp-util.c
Log Message:
fixed up logging; dhcp-files now handles variable length strings properly;
Index: Makefile.am
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile.am 1 Feb 2002 18:31:17 -0000 1.6
--- Makefile.am 8 Feb 2002 17:04:32 -0000 1.7
***************
*** 22,26 ****
dhcp-sysconf.c dhcp-rtt.c
! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@
noinst_HEADERS = dhcp-agent.h config.h
--- 22,26 ----
dhcp-sysconf.c dhcp-rtt.c
! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence
noinst_HEADERS = dhcp-agent.h config.h
Index: Makefile.in
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.in,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile.in 1 Feb 2002 18:31:17 -0000 1.6
--- Makefile.in 8 Feb 2002 17:04:32 -0000 1.7
***************
*** 86,90 ****
! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@
noinst_HEADERS = dhcp-agent.h config.h
--- 86,90 ----
! dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ -lefence
noinst_HEADERS = dhcp-agent.h config.h
Index: dhcp-client.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** dhcp-client.c 7 Feb 2002 18:41:47 -0000 1.12
--- dhcp-client.c 8 Feb 2002 17:04:32 -0000 1.13
***************
*** 26,30 ****
int interactive = 1; /* by default we begin interactive (messages on stdout/stderr). */
! char *binname = NULL; /* we need a name. */
char *work_dir = CLIENT_WORK_DIR; /* our default working directory */
--- 26,30 ----
int interactive = 1; /* by default we begin interactive (messages on stdout/stderr). */
! char *binname = "dhcpclient"; /* we need a name. */
char *work_dir = CLIENT_WORK_DIR; /* our default working directory */
***************
*** 144,147 ****
--- 144,148 ----
}
+ info_message("killed client on pid: %u", pid);
return;
}
***************
*** 223,227 ****
static char *fake_hw_addr = NULL;
! while((c = getopt(argc, argv, "cdavim:kwh:l:")) != -1) {
switch(c) {
--- 224,228 ----
static char *fake_hw_addr = NULL;
! while((c = getopt(argc, argv, "gcdavim:kwh:l:")) != -1) {
switch(c) {
***************
*** 278,282 ****
}
! binname = argv[0];
info_message("starting for interface %s", interface);
--- 279,283 ----
}
! info_message("(C) 2001 Thamer Al-Harbash <tm...@wh...>");
info_message("starting for interface %s", interface);
Index: dhcp-convert.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-convert.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** dhcp-convert.c 5 Feb 2002 02:00:59 -0000 1.4
--- dhcp-convert.c 8 Feb 2002 17:04:32 -0000 1.5
***************
*** 192,196 ****
string_addr_list_to_network, purge_list_internal }, /* 44 */ /* NetBIOS over TCP/IP Name Server */
{ network_addr_list_to_string, string_to_addr_list,
! string_addr_list_to_network, purge_list_internal }, /* 45 */ /* NetBIOS over TCP/IP Name Server */
{ network_byte_to_string_byte, string_byte_to_byte,
string_byte_to_network, xfree }, /* 46 */ /* NetBIOS over TCP/IP Node Type. */
--- 192,196 ----
string_addr_list_to_network, purge_list_internal }, /* 44 */ /* NetBIOS over TCP/IP Name Server */
{ network_addr_list_to_string, string_to_addr_list,
! string_addr_list_to_network, purge_list_internal }, /* 45 */ /* NetBIOS over TCP/IP Datagram Dist Server */
{ network_byte_to_string_byte, string_byte_to_byte,
string_byte_to_network, xfree }, /* 46 */ /* NetBIOS over TCP/IP Node Type. */
***************
*** 539,543 ****
char *s = NULL;
char *string = NULL;
!
if(len == 0 ||
len%sizeof(uint16_t))
--- 539,543 ----
char *s = NULL;
char *string = NULL;
!
if(len == 0 ||
len%sizeof(uint16_t))
Index: dhcp-files.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-files.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** dhcp-files.c 5 Feb 2002 13:47:38 -0000 1.3
--- dhcp-files.c 8 Feb 2002 17:04:32 -0000 1.4
***************
*** 25,29 ****
#include <dhcp-agent.h>
! static char buff[GENERIC_BUFFSIZE];
static char *var_name = NULL;
static char *var_val = NULL;
--- 25,29 ----
#include <dhcp-agent.h>
! static char *line_buff = NULL;
static char *var_name = NULL;
static char *var_val = NULL;
***************
*** 79,83 ****
case PARSE_DOUBLE_STRINGS:
! s = strchr(buff, '=');
if(s == NULL)
return -1;
--- 79,83 ----
case PARSE_DOUBLE_STRINGS:
! s = strchr(line_buff, '=');
if(s == NULL)
return -1;
***************
*** 87,91 ****
if(*s == '\0' || *s == '\n' || *s == '\r')
return -1;
! var_name = buff;
var_val = s;
--- 87,91 ----
if(*s == '\0' || *s == '\n' || *s == '\r')
return -1;
! var_name = line_buff;
var_val = s;
***************
*** 99,104 ****
case PARSE_SINGLE_STRING:
! trim_string(buff);
! var_name = buff;
if(!isascii(*var_name))
--- 99,104 ----
case PARSE_SINGLE_STRING:
! trim_string(line_buff);
! var_name = line_buff;
if(!isascii(*var_name))
***************
*** 114,124 ****
}
int file_get_var_string(FILE *fp)
{
! if(fgets(buff, sizeof(buff), fp) == NULL)
return 1;
! else
return 0;
}
--- 114,176 ----
}
+ /* Get the next string from the file.
+ * In order to do this for variable length strings which may be
+ * very long or very short we do a walk ahead till we find the
+ * newline character and then read everything up to it.
+ * We need to do this to support options which are larger
+ * than 255 octets which we may receive.
+ *
+ * Should we worry about size limits? No. An IP packet cannot be
+ * bigger than 65535 bytes, and we're most likely receiving a
+ * little under 600 bytes from the UDP packet. We can handle both
+ * such sizes reasonably well.
+ *
+ */
+
int file_get_var_string(FILE *fp)
{
+ long begin_line_seek, end_line_seek;
+ int c;
+ unsigned char have_line = 0;
+ size_t string_size;
! begin_line_seek = ftell(fp);
!
! if(line_buff != NULL) {
! /* free up old string. */
! xfree(line_buff);
! line_buff = NULL;
! }
!
! while((c = fgetc(fp)) != EOF) {
! if(c == '\n') {
! have_line = 1;
! break;
! }
! }
!
! if(!have_line)
return 1;
!
! end_line_seek = ftell(fp);
!
! /* Our buffer needs to be as big as the line plus
! * one for the null termination. */
!
! string_size = (end_line_seek - begin_line_seek);
! line_buff = xmalloc(string_size + 1);
!
! /* seek back. */
! fseek(fp, begin_line_seek, SEEK_SET);
!
!
! /* all done. read up! */
! if(fread(line_buff, sizeof(char), string_size, fp) != string_size)
! return 1;
! else {
! line_buff[string_size] = 0;
! warn_message("string read: %s",line_buff);
return 0;
+ }
}
Index: dhcp-sysconf.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-sysconf.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** dhcp-sysconf.c 1 Feb 2002 18:31:17 -0000 1.4
--- dhcp-sysconf.c 8 Feb 2002 17:04:32 -0000 1.5
***************
*** 23,27 ****
*/
! /* Configure host or internal structures. */
#include <dhcp-agent.h>
--- 23,27 ----
*/
! /* Configure host internal structures. */
#include <dhcp-agent.h>
***************
*** 29,77 ****
sysconf_handler sysconf_handlers[] = {
{ NULL, }, /* 0 */
! { NULL, }, /* 1 */
! { NULL, }, /* 2 */
! { sysconf_routers, }, /* 3 */
! { NULL, }, /* 4 */
! { NULL, }, /* 5 */
! { sysconf_domain_name_servers, }, /* 6 */
! { NULL, }, /* 7 */
! { NULL, }, /* 8 */
! { NULL, }, /* 9 */
! { NULL, }, /* 10 */
! { NULL, }, /* 11 */
! { NULL, }, /* 12 */
! { NULL, }, /* 13 */
! { NULL, }, /* 14 */
! { sysconf_domain_name, }, /* 15 */
! { NULL, }, /* 16 */
! { NULL, }, /* 17 */
! { NULL, }, /* 18 */
! { NULL, }, /* 17 */
! { NULL, }, /* 18 */
! { NULL, }, /* 19 */
! { NULL, }, /* 20 */
! { NULL, }, /* 21 */
! { NULL, }, /* 23 */
! { NULL, }, /* 24 */
! { NULL, }, /* 25 */
! { NULL, }, /* 26 */
! { NULL, }, /* 27 */
! { NULL, }, /* 28 */
! { NULL, }, /* 29 */
! { NULL, }, /* 30 */
! { NULL, }, /* 31 */
! { NULL, }, /* 32 */
! { NULL, }, /* 33 */
! { NULL, }, /* 34 */
! { NULL, }, /* 35 */
! { NULL, }, /* 36 */
! { NULL, }, /* 37 */
! { NULL, }, /* 38 */
! { NULL, }, /* 39 */
! { NULL, }, /* 40 */
! { NULL, }, /* 41 */
! { NULL, }, /* 42 */
! { NULL, }, /* 43 */
! { NULL, }, /* 44 */
{ NULL, }, /* 45 */
{ NULL, }, /* 46 */
--- 29,75 ----
sysconf_handler sysconf_handlers[] = {
{ NULL, }, /* 0 */
! { NULL, }, /* 1 */ /* Subnet mask -- don't handle here.*/
! { NULL, }, /* 2 */ /* time offset. */
! { sysconf_routers, }, /* 3 */ /* routers. */
! { NULL, }, /* 4 */ /* time server. */
! { NULL, }, /* 5 */ /* name server (old). */
! { sysconf_domain_name_servers, }, /* 6 */ /* domain name servers. */
! { NULL, }, /* 7 */ /* mit-lcs log server. */
! { NULL, }, /* 8 */ /* cookie servers. */
! { NULL, }, /* 9 */ /* lpr servers. */
! { NULL, }, /* 10 */ /* impress server. */
! { NULL, }, /* 11 */ /* resource location server. */
! { NULL, }, /* 12 */ /* host name option. */
! { NULL, }, /* 13 */ /* boot file size option. */
! { NULL, }, /* 14 */ /* merit dump file. */
! { sysconf_domain_name, }, /* 15 */ /* domain name. */
! { NULL, }, /* 16 */ /* swap server. */
! { NULL, }, /* 17 */ /* root path. */
! { NULL, }, /* 18 */ /* extension path */
! { NULL, }, /* 19 */ /* ip forwarding. */
! { NULL, }, /* 20 */ /* non local source routing. */
! { NULL, }, /* 21 */ /* policy filter option. */
! { NULL, }, /* 23 */ /* maximum dgram reassembly. */
! { NULL, }, /* 24 */ /* mtu aging timeout. */
! { NULL, }, /* 25 */ /* mtu plateau table. */
! { NULL, }, /* 26 */ /* interface mtu */
! { NULL, }, /* 27 */ /* subnets are local. */
! { NULL, }, /* 28 */ /* broadcast address. */
! { NULL, }, /* 29 */ /* perform mask discovery. */
! { NULL, }, /* 30 */ /* mask supplier. */
! { NULL, }, /* 31 */ /* perform router discovery. */
! { NULL, }, /* 32 */ /* router soliciation address. */
! { NULL, }, /* 33 */ /* static route. */
! { NULL, }, /* 34 */ /* trailer encapsulation. */
! { NULL, }, /* 35 */ /* arp cache timeout. */
! { NULL, }, /* 36 */ /* ethernet encapsulation. */
! { NULL, }, /* 37 */ /* tcp default ttl. */
! { NULL, }, /* 38 */ /* tcp keepalive garbage option. */
! { NULL, }, /* 39 */ /* network information service domain. */
! { NULL, }, /* 40 */ /* network time protocol servers. */
! { NULL, }, /* 41 */ /* vendor specific. */
! { NULL, }, /* 42 */ /* netbios over TCP/IP name server. */
! { NULL, }, /* 43 */ /* netbios over tcp/ip */
! { NULL, }, /* 44 */
{ NULL, }, /* 45 */
{ NULL, }, /* 46 */
***************
*** 202,209 ****
if(have_addr && have_netmask) /* if we're done finding both, break out. */
break;
!
continue;
}
!
if(string_matches(dhcp_options_strings[TAG_DHCP_SUBNET_MASK],
ce->name)) {
--- 200,207 ----
if(have_addr && have_netmask) /* if we're done finding both, break out. */
break;
!
continue;
}
!
if(string_matches(dhcp_options_strings[TAG_DHCP_SUBNET_MASK],
ce->name)) {
Index: dhcp-util.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-util.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dhcp-util.c 8 Feb 2002 01:37:29 -0000 1.6
--- dhcp-util.c 8 Feb 2002 17:04:32 -0000 1.7
***************
*** 51,55 ****
va_list ap;
! if(verbosity_level <= QUIET_VERBOSITY_LEVEL)
return;
--- 51,55 ----
va_list ap;
! if(verbosity_level == QUIET_VERBOSITY_LEVEL)
return;
***************
*** 59,63 ****
if(interactive == 1) {
! fprintf(stderr, "error: %s", msgbuff);
fprintf(stderr,"\n");
} else
--- 59,63 ----
if(interactive == 1) {
! fprintf(stderr, "%s: error: %s", binname, msgbuff);
fprintf(stderr,"\n");
} else
***************
*** 72,76 ****
va_list ap;
! if(verbosity_level <= QUIET_VERBOSITY_LEVEL)
return;
--- 72,76 ----
va_list ap;
! if(verbosity_level == QUIET_VERBOSITY_LEVEL)
return;
***************
*** 80,84 ****
if(interactive == 1) {
! fprintf(stderr, "fatal error: %s", msgbuff);
fprintf(stderr,"\n");
} else
--- 80,84 ----
if(interactive == 1) {
! fprintf(stderr, "%s: fatal error: %s", binname, msgbuff);
fprintf(stderr,"\n");
} else
***************
*** 94,98 ****
va_list ap;
! if(verbosity_level <= ERROR_VERBOSITY_LEVEL)
return;
--- 94,98 ----
va_list ap;
! if(verbosity_level < ERROR_VERBOSITY_LEVEL)
return;
***************
*** 102,106 ****
if(interactive == 1) {
! fprintf(stdout, "%s", msgbuff);
fprintf(stdout,"\n");
} else
--- 102,106 ----
if(interactive == 1) {
! fprintf(stdout, "%s: %s", binname, msgbuff);
fprintf(stdout,"\n");
} else
***************
*** 115,119 ****
va_list ap;
! if(verbosity_level <= WARNING_VERBOSITY_LEVEL)
return;
--- 115,119 ----
va_list ap;
! if(verbosity_level < WARNING_VERBOSITY_LEVEL)
return;
***************
*** 123,127 ****
if(interactive == 1) {
! fprintf(stdout, "warning: %s", msgbuff);
fprintf(stdout,"\n");
} else
--- 123,127 ----
if(interactive == 1) {
! fprintf(stdout, "%s warning: %s", binname, msgbuff);
fprintf(stdout,"\n");
} else
***************
*** 136,140 ****
va_list ap;
! if(verbosity_level <= DEBUG_VERBOSITY_LEVEL)
return;
--- 136,140 ----
va_list ap;
! if(verbosity_level < DEBUG_VERBOSITY_LEVEL)
return;
***************
*** 144,148 ****
if(interactive == 1) {
! fprintf(stdout, "debug: %s", msgbuff);
fprintf(stdout,"\n");
} else
--- 144,148 ----
if(interactive == 1) {
! fprintf(stdout, "%s: debug: %s", binname, msgbuff);
fprintf(stdout,"\n");
} else
|