[dhcp-agent-commits] dhcp-agent/src dhcp-log.h,NONE,1.1 Makefile.am,1.3,1.4 dhcp-files.c,1.1.1.1,1.2
Status: Alpha
Brought to you by:
actmodern
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory usw-pr-cvs1:/tmp/cvs-serv5669 Modified Files: Makefile.am dhcp-files.c dhcp-local.h dhcp-log.c dhcp-parser.c dhcp-parser.h dhcp-util.c dhcp-varfile.c Added Files: dhcp-log.h Log Message: linked in file/parser routines to utility library --- NEW FILE: dhcp-log.h --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-log.h,v 1.1 2002/11/09 16:59:15 actmodern Exp $ * * Copyright 2002 Thamer Alharbash <tm...@wh...> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * System logging functions. * */ #ifndef DHCP_LOG_H #define DHCP_LOG_H extern void init_log(const char *s); extern void close_log(void); extern void error_log(const char *msg); extern void info_log(const char *msg); #endif /* DHCP_LOG_H */ Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 3 Nov 2002 16:34:55 -0000 1.3 --- Makefile.am 9 Nov 2002 16:59:15 -0000 1.4 *************** *** 3,6 **** --- 3,7 ---- # Main source Makefile.am + CFLAGS = -Wall -Werror INCLUDES = @PCAP_INC@ @DNET_INC@ DEFS = @DEFS@ *************** *** 12,22 **** libdhcputil_la_SOURCES = dhcp-util.c \ - dhcp-util.h \ dhcp-stringbuffer.c \ dhcp-list.c \ dhcp-log.c \ ! dhcp-snprintf.c ! # dhcp-rawnet.c \ ! # dhcp-align.c \ # dhcp-com.c \ # dhcp-eth.c \ --- 13,27 ---- libdhcputil_la_SOURCES = dhcp-util.c \ dhcp-stringbuffer.c \ dhcp-list.c \ dhcp-log.c \ ! dhcp-snprintf.c \ ! dhcp-rtt.c \ ! dhcp-timer.c \ ! dhcp-varfile.c \ ! dhcp-parser.c \ ! dhcp-files.c ! # dhcp-rawnet.c ! # dhcp-align.c # dhcp-com.c \ # dhcp-eth.c \ *************** *** 25,30 **** # dhcp-arp.c \ # dhcp-icmp.c \ ! # dhcp-rtt.c \ ! # dhcp-interface.c # dhcp_sniff_SOURCES = \ --- 30,40 ---- # dhcp-arp.c \ # dhcp-icmp.c \ ! # dhcp-interface.c \ ! dhcp-libutil.h \ ! # dhcp-librawnet.h \ ! # dhcp-packet-build.c \ ! # dhcp-icmp-discovery.c \ ! # dhcp-arp-discovery.c \ ! dhcp-local.h # dhcp_sniff_SOURCES = \ *************** *** 44,60 **** # dhcp-client-control.c \ # dhcp-client-conf.c \ - # dhcp-files.c \ # dhcp-client-states.c \ # dhcp-options-strings.c \ # dhcp-convert.c \ # dhcp-sysconf.c \ - # dhcp-packet-build.c \ - # dhcp-icmp-discovery.c \ - # dhcp-arp-discovery.c \ # dhcp-route.c \ ! # dhcp-globconf.c \ ! # dhcp-parser.c \ ! # dhcp-varfile.c \ ! # dhcp-timer.c # dhcp_client_LDADD = @PCAP_LIB@ @DNET_LIB@ --- 54,64 ---- # dhcp-client-control.c \ # dhcp-client-conf.c \ # dhcp-client-states.c \ # dhcp-options-strings.c \ # dhcp-convert.c \ # dhcp-sysconf.c \ # dhcp-route.c \ ! # dhcp-globconf.c ! # dhcp_client_LDADD = @PCAP_LIB@ @DNET_LIB@ Index: dhcp-files.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-files.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dhcp-files.c 29 Oct 2002 17:11:23 -0000 1.1.1.1 --- dhcp-files.c 9 Nov 2002 16:59:15 -0000 1.2 *************** *** 26,32 **** #define MODULE_NAME "dhcp-files" ! #include <dhcp-agent.h> ! #include <dhcp-util.h> ! #include <dhcp-files.h> static FILE *file_open_proc(const char *filename, char *cmode, int flags, mode_t mode) --- 26,31 ---- #define MODULE_NAME "dhcp-files" ! #include "dhcp-local.h" ! #include "dhcp-libutil.h" static FILE *file_open_proc(const char *filename, char *cmode, int flags, mode_t mode) Index: dhcp-local.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-local.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** dhcp-local.h 3 Nov 2002 16:34:55 -0000 1.1 --- dhcp-local.h 9 Nov 2002 16:59:15 -0000 1.2 *************** *** 37,51 **** #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/time.h> #include <string.h> #include <unistd.h> #include <syslog.h> #include <signal.h> ! #include <stdarg.h> ! #include <inttypes.h> #include <dnet.h> #include <pcap.h> --- 37,59 ---- #include <stdlib.h> #include <stdio.h> + #include <stdarg.h> #include <sys/types.h> + #include <sys/stat.h> #include <sys/time.h> + #include <sys/ioctl.h> + #include <sys/fcntl.h> + #include <sys/uio.h> + #include <inttypes.h> + #include <errno.h> #include <string.h> #include <unistd.h> #include <syslog.h> #include <signal.h> ! #include <time.h> ! #include <ctype.h> + #include <net/bpf.h> #include <dnet.h> #include <pcap.h> Index: dhcp-log.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-log.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dhcp-log.c 3 Nov 2002 16:34:55 -0000 1.3 --- dhcp-log.c 9 Nov 2002 16:59:15 -0000 1.4 *************** *** 46,50 **** } ! void info_log(const char *msg) { syslog(INFO_LEVEL, "%s", msg); --- 46,50 ---- } ! void info_log(const char *msg) { syslog(INFO_LEVEL, "%s", msg); Index: dhcp-parser.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-parser.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dhcp-parser.c 29 Oct 2002 17:11:27 -0000 1.1.1.1 --- dhcp-parser.c 9 Nov 2002 16:59:15 -0000 1.2 *************** *** 20,34 **** * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Parser driver. Here we can build custom parsers by plugging in - * the applicable functions for each single character token. A - * default parser with a 0 for a character is used as a fallback - * (and to mark the end of the parser driver) - * - * This parser will b0rk on something that's not printable and not even - * call the parse function. - * - * We build from the parser utility routines or we can pass our - * own. * */ --- 20,23 ---- *************** *** 36,45 **** #define MODULE_NAME "dhcp-parser" ! #include <dhcp-agent.h> ! #include <dhcp-util.h> ! #include <dhcp-stringbuffer.h> ! #include <dhcp-files.h> ! #include <dhcp-parser.h> static int is_valid_string_char(int c) { --- 25,34 ---- #define MODULE_NAME "dhcp-parser" ! #include "dhcp-local.h" ! #include "dhcp-libutil.h" ! ! #include "dhcp-parser.h" + /* is a valid string character. */ static int is_valid_string_char(int c) { *************** *** 53,56 **** --- 42,46 ---- } + /* the stream is EOF or an error occured. */ static token_t check_eof(parser_t *input) { *************** *** 84,87 **** --- 74,78 ---- } + /* read a quoted string. */ static token_t parse_get_quoted_string(parser_t *input) { *************** *** 130,133 **** --- 121,125 ---- } + /* read a string. */ static token_t parse_get_string(parser_t *input) { *************** *** 167,170 **** --- 159,163 ---- } + /* get the next atom. */ atom_t get_next_atom(parser_t *input) { *************** *** 246,249 **** --- 239,243 ---- } + /* create a parser instance. */ parser_t *create_parser(const char *filename) { Index: dhcp-parser.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-parser.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dhcp-parser.h 29 Oct 2002 17:11:33 -0000 1.1.1.1 --- dhcp-parser.h 9 Nov 2002 16:59:15 -0000 1.2 *************** *** 28,31 **** --- 28,41 ---- #define DHCP_PARSER_H + typedef uint8_t token_t; + typedef uint8_t atom_t; + + extern void destroy_parser(parser_t *parser); + extern parser_t *create_parser(const char *filename); + extern atom_t get_next_atom(parser_t *input); + extern const char *parser_get_data(parser_t *input); + extern int parser_get_line_no(parser_t *parser); + + /* parser return values. */ #define PARSER_TOKEN_ERROR 0 #define PARSER_TOKEN_NEWLINE 1 *************** *** 41,58 **** #define PARSER_ATOM_EOF 4 ! typedef uint8_t token_t; ! typedef uint8_t atom_t; ! ! typedef struct { ! FILE *fp; ! int line_no; ! stringbuffer *data_buff; ! } parser_t; ! ! extern void destroy_parser(parser_t *parser); ! extern parser_t *create_parser(const char *filename); ! extern atom_t get_next_atom(parser_t *input); ! extern const char *parser_get_data(parser_t *input); ! extern int parser_get_line_no(parser_t *parser); #endif /* DHCP_PARSER_H */ --- 51,57 ---- #define PARSER_ATOM_EOF 4 ! /* Parse types. */ ! #define PARSE_SINGLE_STRING 1 ! #define PARSE_DOUBLE_STRINGS 2 #endif /* DHCP_PARSER_H */ Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-util.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-util.c 3 Nov 2002 16:34:55 -0000 1.4 --- dhcp-util.c 9 Nov 2002 16:59:15 -0000 1.5 *************** *** 30,33 **** --- 30,35 ---- #include "dhcp-libutil.h" + #include "dhcp-log.h" + static uint8_t interactive = 1; static int verbosity_level = DEBUG_VERBOSITY_LEVEL; Index: dhcp-varfile.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-varfile.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** dhcp-varfile.c 29 Oct 2002 17:11:31 -0000 1.1.1.1 --- dhcp-varfile.c 9 Nov 2002 16:59:15 -0000 1.2 *************** *** 26,34 **** #define MODULE_NAME "dhcp-varfile" ! #include <dhcp-agent.h> ! #include <dhcp-util.h> ! #include <dhcp-files.h> ! #include <dhcp-parser.h> ! #include <dhcp-varfile.h> const char *varfile_get_name(varfile_t *varfile) --- 26,33 ---- #define MODULE_NAME "dhcp-varfile" ! #include "dhcp-local.h" ! #include "dhcp-libutil.h" ! ! #include "dhcp-parser.h" const char *varfile_get_name(varfile_t *varfile) |