Another Patch
Steve G <[email protected]> Sun, 8 Feb 2004 12:21:50 -0800 (PST)
| Newsgroups | gmane.network.zeroconf.workers |
|---|---|
| Message-ID | <[email protected]> |
Hi, I would normally break this into separate patches, but I am running short on time today. This patch is a combination of const fixups, signed unsigned fixes, and corrections for the spec file, init scripts, and the init.d makefiles. The spec file now works correctly assuming that tmdns.conf & tmdns.services are in the top of the tarball. There is also one area that needs attention. The patch labels it with a FIXME. The MAXDNAME is 1025 and its compared with an unsigned char. The unsigned char can only be 255 so the comparison will always fail. Best Regards, Steve Grubb __________________________________ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html
tmdns-patch9.txt
(text/plain, 35.5 KB)
diff -ur tmdns/init.d/init.REDHAT tmdns.c/init.d/init.REDHAT
--- tmdns/init.d/init.REDHAT 2004-02-08 01:46:20.000000000 -0500
+++ tmdns.c/init.d/init.REDHAT 2004-02-08 12:25:11.000000000 -0500
@@ -37,7 +37,7 @@
prog="tmdns"
start() {
- echo -n "Starting: " $prog
+ echo -n $"Starting: " $prog
daemon $prog "$EXTRAOPTIONS"
RETVAL=$?
echo
diff -ur tmdns/init.d/Makefile.am tmdns.c/init.d/Makefile.am
--- tmdns/init.d/Makefile.am 2004-02-01 09:10:24.000000000 -0500
+++ tmdns.c/init.d/Makefile.am 2004-02-08 13:33:30.000000000 -0500
@@ -1,7 +1,8 @@
-EXTRA_DIST= init.DEBIAN init.PYNIX
+EXTRA_DIST= init.DEBIAN init.PYNIX init.REDHAT
CLEANFILES= initscript
+initscript: all
all:
@if [ -f "init.$(DISTRIB)" ] ;\
then \
@@ -21,7 +22,7 @@
fi
-install:
+install: initscript
if [ -f initscript ] ;\
then \
if [ ! -d "$(DESTDIR)$(INIT_DIR)" ] ;\
diff -ur tmdns/init.d/Makefile.in tmdns.c/init.d/Makefile.in
--- tmdns/init.d/Makefile.in 2004-02-01 09:10:24.000000000 -0500
+++ tmdns.c/init.d/Makefile.in 2004-02-08 13:48:22.000000000 -0500
@@ -114,7 +114,7 @@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-EXTRA_DIST = init.DEBIAN init.PYNIX
+EXTRA_DIST = init.DEBIAN init.PYNIX init.REDHAT
CLEANFILES = initscript
subdir = init.d
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -254,7 +254,7 @@
mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am
-
+initscript: all
all:
@if [ -f "init.$(DISTRIB)" ] ;\
then \
@@ -273,7 +273,7 @@
echo ;\
fi
-install:
+install: initscript
if [ -f initscript ] ;\
then \
if [ ! -d "$(DESTDIR)$(INIT_DIR)" ] ;\
diff -ur tmdns/server/conf.c tmdns.c/server/conf.c
--- tmdns/server/conf.c 2004-02-08 09:00:41.000000000 -0500
+++ tmdns.c/server/conf.c 2004-02-08 14:05:30.000000000 -0500
@@ -61,30 +61,30 @@
dynamic_service_file: DYNAMIC_SERVICE_FILE_DEFAULT,
};
-static void conf_cmdparse(char *cmd, char *arg1);
-static void copy_bool(char *, void *);
-static void print_bool(FILE * fd , void * value ) ;
-static void init_int(char *, void *);
-static void copy_int(char *, void *);
-static void print_int(FILE * fd , void * value ) ;
-static void copy_string(char *, void *);
-static void print_string(FILE * fd , void * value ) ;
-
-static void init_string_array(char *, void *);
-static void copy_string_array(char *, char **, int);
-static void print_string_array(FILE * fd , void * value ) ;
+static void conf_cmdparse(const char *cmd, const char *arg1);
+static void copy_bool(const char *, void *);
+static void print_bool(FILE * fd , const void * value ) ;
+static void init_int(const char *, void *);
+static void copy_int(const char *, void *);
+static void print_int(FILE * fd , const void * value ) ;
+static void copy_string(const char *, void *);
+static void print_string(FILE * fd , const void * value ) ;
+
+static void init_string_array(const char *, void *);
+static void copy_string_array(const char *, char **, int);
+static void print_string_array(FILE * fd , const void * value ) ;
-static void copy_interfaces(char *str, void * val) {
+static void copy_interfaces(const char *str, void * val) {
copy_string_array(str,(char **)val, MAX_IF );
}
-static void copy_also_local(char *str, void * val) {
+static void copy_also_local(const char *str, void * val) {
copy_string_array(str,(char **)val, MAX_ALSO_LOCAL );
}
/* dummy functions */
-static void copy_dummy(char * str, void * val) {}
-static void print_dummy(FILE * fd, void * value ) {}
+static void copy_dummy(const char * str, void * val) {}
+static void print_dummy(FILE * fd, const void * value ) {}
static config_param config_params[] = {
@@ -298,14 +298,12 @@
perror("no config file");
return 0;
}
- } else {
- strcpy(config.config_file, conf_file);
- if (config.config_file != conf_file)
- strcpy(config.config_file, conf_file);
+ } else if (config.config_file != conf_file) {
+ strcpy(config.config_file, conf_file);
}
while (fgets(line, 1024 , fp)) {
if (!(line[0]=='#')) { /* skip lines with comment */
- int idx = 0;
+ size_t idx = 0;
line[strlen(line) - 1] = 0; /* kill '\n' */
cmd = strtok( line, " =" );
arg1 = strtok( NULL, "=");
@@ -332,7 +330,7 @@
return 0;
}
/*****************************************************************************/
-static void conf_cmdparse(char *cmd, char *arg1)
+static void conf_cmdparse(const char *cmd, const char *arg1)
{
int i = 0;
@@ -367,7 +365,7 @@
* value.
* @param value - points to the place where to store the value.
************************************************************************/
-static void copy_bool (char *str, void * val)
+static void copy_bool (const char *str, void * val)
{
if ( !strcmp(str, "1") ||
!strcasecmp(str, "yes") ||
@@ -378,14 +376,14 @@
*((int *)val) = 0;
}
}
-static void copy_int(char *str, void * val) {
+static void copy_int(const char *str, void * val) {
*((int *)val) = atoi(str);
}
-static void copy_string(char *str, void * val) {
+static void copy_string(const char *str, void * val) {
strncpy((char *)val, str , CONF_PATH_LEN );
}
-static void init_int(char *str, void * val) {
- *((int *)val) = *((int *)str);
+static void init_int(const char *str, void * val) {
+ *((int *)val) = *((const int *)str);
}
@@ -402,18 +400,18 @@
* @param fd - File descriptor for output.
* @param value - pointer to the config value.
************************************************************************/
-static void print_bool(FILE * fd , void * value ) {
- if( *((int *)value) ) {
+static void print_bool(FILE * fd , const void * value ) {
+ if( *((const int *)value) ) {
fprintf(fd,"yes");
} else {
fprintf(fd,"no");
}
}
-static void print_int(FILE * fd , void * value ) {
- fprintf(fd,"%d", *((int *) value) );
+static void print_int(FILE * fd , const void * value ) {
+ fprintf(fd,"%d", *((const int *) value) );
}
-static void print_string(FILE * fd, void * value) {
- fprintf(fd,"%s", ((char *)value) );
+static void print_string(FILE * fd, const void * value) {
+ fprintf(fd,"%s", ((const char *)value) );
}
/************************************************************************
@@ -423,16 +421,16 @@
* change the values in place !
*
***********************************************************************/
-static void init_string_array(char *str, void * val) {
+static void init_string_array(const char *str, void * val) {
int idx = 0;
- while( ((char **)str)[idx] != NULL ) {
+ while( ((const char **)str)[idx] != NULL ) {
/* free old value */
if( (((char **)val)[idx]) != NULL )
free( ((char **)val)[idx] );
- ((char **)val)[idx] = strdup(((char **)str)[idx]);
+ ((char **)val)[idx] = strdup(((const char **)str)[idx]);
idx ++;
}
@@ -448,8 +446,8 @@
* i.e we can not pass an array size to it. You need to write a wrapper
* for your array.
*/
-static void copy_string_array(char *str, char ** val, int size ) {
- char * now = str;
+static void copy_string_array(const char *str, char ** val, int size ) {
+ const char * now = str;
char * tok = NULL;
int idx = 0;
@@ -470,13 +468,12 @@
idx ++;
if( idx >= size ) break;
}
-
}
-static void print_string_array(FILE * fd, void * value) {
+static void print_string_array(FILE * fd, const void * value) {
int idx = 0;
- while( ((char **)value)[idx] != NULL ) {
- fprintf(fd," %s", ((char **)value)[idx] );
+ while( ((const char **)value)[idx] != NULL ) {
+ fprintf(fd," %s", ((const char **)value)[idx] );
idx ++;
}
}
@@ -493,8 +490,8 @@
fprintf(fd,"# config for %s version %s\n", PACKAGE, VERSION);
fprintf(fd,"#\n");
while( config_params[i].param_name != NULL ) {
- if( (config_params[i].print == NULL) ||
- (config_params[i].print == print_dummy))
+ if( ((void *)config_params[i].print == NULL) ||
+ ((void *)config_params[i].print == (void *)print_dummy))
{
fprintf(fd, "%s", config_params[i].comment);
} else {
@@ -549,7 +546,7 @@
* 0 otherwise.
*
****************************************************************************/
-int is_excluded_interface( char * ifname ) {
+int is_excluded_interface( const char * ifname ) {
char ** cfname = NULL;
diff -ur tmdns/server/conf.h tmdns.c/server/conf.h
--- tmdns/server/conf.h 2004-02-08 09:00:41.000000000 -0500
+++ tmdns.c/server/conf.h 2004-02-08 11:53:12.000000000 -0500
@@ -49,8 +49,8 @@
/**
* typedef for a param copy function.
*/
-typedef void (* conf_copy_func)(char *, void *) ;
-typedef void (* conf_print_func)(FILE * fp, void *);
+typedef void (* conf_copy_func)(const char *, void *) ;
+typedef void (* conf_print_func)(FILE * fp, const void *);
/**
* description for parameters in the config file
@@ -72,6 +72,6 @@
extern void conf_print(void);
-extern int is_excluded_interface( char * ifname );
+extern int is_excluded_interface( const char * ifname );
#endif /* CONF_H */
diff -ur tmdns/server/debug.c tmdns.c/server/debug.c
--- tmdns/server/debug.c 2004-02-07 09:11:48.000000000 -0500
+++ tmdns.c/server/debug.c 2004-02-08 14:07:54.000000000 -0500
@@ -84,7 +84,7 @@
* @param msg extra message for this packet.
* @param dnsdata pointer to a dns packet.
****************************************************************************/
-void f_debug_dns(const char * msg , void * dnsdata) {
+void f_debug_dns(const char * msg , const void * dnsdata) {
FILE * fp;
if((fp = open_log()) != NULL){
diff -ur tmdns/server/debug.h tmdns.c/server/debug.h
--- tmdns/server/debug.h 2004-02-07 09:11:48.000000000 -0500
+++ tmdns.c/server/debug.h 2004-02-08 14:08:10.000000000 -0500
@@ -34,7 +34,7 @@
;
#endif
-extern void f_debug_dns(const char * , void *);
+extern void f_debug_dns(const char * , const void *);
extern const char * debug_errmsg( int );
#else
diff -ur tmdns/server/dns.c tmdns.c/server/dns.c
--- tmdns/server/dns.c 2004-02-08 09:00:42.000000000 -0500
+++ tmdns.c/server/dns.c 2004-02-08 14:46:11.000000000 -0500
@@ -25,7 +25,7 @@
*
* @param pkt a pointer to a dns package structure.
****************************************************************************/
-size_t dns_get_len( dns_t * pkt ) {
+size_t dns_get_len( const dns_t * pkt ) {
return (pkt->data - pkt->u.raw);
}
/****************************************************************************
@@ -52,7 +52,7 @@
* @param include_query true when the query records should be put into the
* new answer packet.
****************************************************************************/
-int dns_init_answer( dns_t * pkt, dns_query * query, int include_query ) {
+int dns_init_answer( dns_t * pkt, const dns_query * query, int include_query ) {
/** initialize header fields */
if( query && query->inverse ) {
@@ -88,7 +88,7 @@
/** add the queries to the response packet */
if( query && include_query && (! query->inverse) ) {
- int n = 0;
+ unsigned int n = 0;
size_t bytes = 0;
for( n = 0; n < query->nquest; n ++ ) {
@@ -148,7 +148,7 @@
*
* @return length of this RR or -1 on error.
****************************************************************************/
-int dns_add_qr( dns_t * pkt , char * domain,
+int dns_add_qr( dns_t * pkt , const char * domain,
u_int16_t type, u_int16_t class )
{
int count = 0;
@@ -175,7 +175,7 @@
****************************************************************************/
int dns_add_raw_rr( dns_t * pkt, const char * domain,
u_int16_t type , u_int16_t class, u_int32_t ttl ,
- size_t rr_len, u_char * rr_data )
+ size_t rr_len, const u_char * rr_data )
{
int count = 0;
u_char * old_data = pkt->data;
diff -ur tmdns/server/dns.h tmdns.c/server/dns.h
--- tmdns/server/dns.h 2004-02-08 09:00:42.000000000 -0500
+++ tmdns.c/server/dns.h 2004-02-08 14:45:55.000000000 -0500
@@ -155,19 +155,19 @@
void dns_init( dns_t * );
-int dns_init_answer( dns_t * , dns_query * , int );
+int dns_init_answer( dns_t * , const dns_query * , int );
int dns_add_ar( dns_t * pkt, dns_rr * rr );
int dns_add_ns( dns_t * pkt, dns_rr * rr );
int dns_add_rr( dns_t * pkt , dns_rr * rr );
-int dns_add_qr( dns_t * pkt , char * domain,
+int dns_add_qr( dns_t * pkt , const char * domain,
u_int16_t type, u_int16_t class);
int dns_add_raw_rr( dns_t * pkt, const char * domain,
u_int16_t type , u_int16_t class, u_int32_t ttl ,
- size_t rr_len, u_char * rr_data );
+ size_t rr_len, const u_char * rr_data );
-size_t dns_get_len(dns_t *);
+size_t dns_get_len(const dns_t *);
int udp_is_bridgesock( int fd );
diff -ur tmdns/server/info.c tmdns.c/server/info.c
--- tmdns/server/info.c 2004-02-08 09:00:44.000000000 -0500
+++ tmdns.c/server/info.c 2004-02-08 14:52:37.000000000 -0500
@@ -36,7 +36,7 @@
static list_t * records;
static dns_rr * newLocalHinfoRec( const char * domain );
-static dns_rr * newARec( const char * domain , struct in_addr * ip );
+static dns_rr * newARec( const char * domain , const struct in_addr * ip );
static const char escaped_space[]="\\032";
/*****************************************************************************
@@ -106,16 +106,16 @@
free(rr);
}
-void debug_rr(dns_rr * rr) {
+void debug_rr(const dns_rr * rr) {
debug(" domain=%s, type=%u, class=%u, ttl=%u, auth=%d\n",
rr->domain, rr->type, rr->class, rr->ttl, rr->auth );
}
-static int cmpNone(dns_rr * a, dns_rr * b) {
+static int cmpNone(const dns_rr * a, const dns_rr * b) {
return 0;
}
-static dns_rr * clone_rr( dns_rr * src ) {
+static dns_rr * clone_rr( const dns_rr * src ) {
dns_rr * copy = NULL;
if( (copy = (dns_rr *)malloc( sizeof(dns_rr))) == NULL )
@@ -198,7 +198,7 @@
free_rr(hinfo);
}
-static int compareHinfoRec(dns_rr * a, dns_rr * b) {
+static int compareHinfoRec(const dns_rr * a, const dns_rr * b) {
int result = 0;
debug("in compareHinfoRec\n");
@@ -210,13 +210,13 @@
return result;
}
-static void debugHinfoRec(dns_rr * hinfo) {
+static void debugHinfoRec(const dns_rr * hinfo) {
debug_rr(hinfo);
debug(" hinfo: cpu=%s, os=%s\n" ,
hinfo->rr.hinfo.cpu_type , hinfo->rr.hinfo.os_name );
}
-static dns_rr * cloneHinfoRec(dns_rr * src) {
+static dns_rr * cloneHinfoRec(const dns_rr * src) {
dns_rr * copy = NULL;
if( (copy = clone_rr(src)) == NULL )
@@ -279,12 +279,12 @@
* Constructor function for ipv4 address resource records.
*
*****************************************************************************/
-static int compareARec(dns_rr * a, dns_rr * b) {
+static int compareARec(const dns_rr * a, const dns_rr * b) {
debug("in compareARec\n");
return memcmp(&(a->rr.a), &(b->rr.a),sizeof(struct in_addr));
}
-static dns_rr * cloneARec(dns_rr * src) {
+static dns_rr * cloneARec(const dns_rr * src) {
dns_rr * copy = NULL;
if( (copy = clone_rr(src)) == NULL )
@@ -295,7 +295,7 @@
return copy;
}
-static dns_rr * newARec( const char * domain , struct in_addr * ip ) {
+static dns_rr * newARec( const char * domain , const struct in_addr * ip ) {
dns_rr * aRec = NULL;
aRec = (dns_rr *)malloc( sizeof(dns_rr) );
@@ -315,12 +315,12 @@
* Constructor function for ipv4 address resource records.
*
*****************************************************************************/
-static int compareAAAARec(dns_rr * a, dns_rr * b) {
+static int compareAAAARec(const dns_rr * a, const dns_rr * b) {
debug("in compareARec\n");
return memcmp(&(a->rr.aaaa), &(b->rr.aaaa),sizeof(struct in6_addr));
}
-static dns_rr * cloneAAAARec(dns_rr * src) {
+static dns_rr * cloneAAAARec(const dns_rr * src) {
dns_rr * copy = NULL;
if( (copy = clone_rr(src)) == NULL )
@@ -331,7 +331,7 @@
return copy;
}
-static dns_rr * newAAAARec( const char * domain , struct in6_addr * ip ) {
+static dns_rr * newAAAARec( const char * domain , const struct in6_addr * ip ) {
dns_rr * aRec = NULL;
aRec = (dns_rr *)malloc( sizeof(dns_rr) );
@@ -355,13 +355,13 @@
free_rr(rr);
}
-static int comparePtrRec(dns_rr * a, dns_rr * b) {
+static int comparePtrRec(const dns_rr * a, const dns_rr * b) {
debug("in comparePtrRec\n");
return strncasecmp(a->rr.dn,b->rr.dn, MAXDNAME);
}
-static void debugPtrRec(dns_rr * ptrRec ) {
- char * typeStr = "????";
+static void debugPtrRec(const dns_rr * ptrRec ) {
+ const char * typeStr = "????";
switch (ptrRec->type) {
case T_NS: typeStr = "ns"; break;
@@ -379,7 +379,7 @@
debug(" %s: %s\n" , typeStr, ptrRec->rr.dn );
}
-static dns_rr * clonePtrRec(dns_rr * src) {
+static dns_rr * clonePtrRec(const dns_rr * src) {
dns_rr * copy = NULL;
if( (copy = clone_rr(src)) == NULL )
@@ -395,7 +395,7 @@
}
-static dns_rr * newPtrRec( const char * domain , char * dn ) {
+static dns_rr * newPtrRec( const char * domain , const char * dn ) {
dns_rr * ptrRec = NULL;
ptrRec = (dns_rr *)malloc( sizeof(dns_rr) );
@@ -422,7 +422,7 @@
free_rr(rr);
}
-static int compareSrvRec(dns_rr * a, dns_rr * b) {
+static int compareSrvRec(const dns_rr * a, const dns_rr * b) {
int result = 0;
@@ -439,13 +439,13 @@
return result;
}
-static void debugSrvRec(dns_rr * rr) {
+static void debugSrvRec(const dns_rr * rr) {
debug_rr(rr);
debug(" srv: prio=%u, weight=%u port=%u target=%s\n" ,
rr->rr.srv.priority , rr->rr.srv.weight, rr->rr.srv.port, rr->rr.srv.target);
}
-static dns_rr * cloneSrvRec(dns_rr * src) {
+static dns_rr * cloneSrvRec(const dns_rr * src) {
dns_rr * copy = NULL;
if( (copy = clone_rr(src)) == NULL )
@@ -468,7 +468,7 @@
u_int16_t priority,
u_int16_t weight,
u_int16_t port,
- char * target )
+ const char * target )
{
dns_rr * srvRec = NULL;
@@ -512,7 +512,7 @@
free_rr(rr);
}
-static int compareTxtRec(dns_rr * a, dns_rr * b) {
+static int compareTxtRec(const dns_rr * a, const dns_rr * b) {
ll_entry_t * ela;
ll_entry_t * elb;
@@ -544,7 +544,7 @@
return 0;
}
-static void debugTxtRec(dns_rr * rr) {
+static void debugTxtRec(const dns_rr * rr) {
ll_entry_t * el;
debug_rr(rr);
foreach(el,rr->rr.txt.strings) {
@@ -552,7 +552,7 @@
}
}
-static int txtRecAddString( dns_rr * rr , const char * str ) {
+static int txtRecAddString( const dns_rr * rr , const char * str ) {
char * copy = NULL;
@@ -573,7 +573,7 @@
}
-static dns_rr * cloneTxtRec(dns_rr * src) {
+static dns_rr * cloneTxtRec(const dns_rr * src) {
dns_rr * copy = NULL;
ll_entry_t * el;
@@ -622,7 +622,8 @@
*
*****************************************************************************/
#define LINE_LEN 1024
-static void info_read_serviceconf( char * service_file , char * fqdn, char * hostname) {
+static void info_read_serviceconf( char * service_file , const char * fqdn,
+ char * hostname) {
FILE *fp;
char line[LINE_LEN];
@@ -934,7 +935,7 @@
*
*
*****************************************************************************/
-void info_init_search( search_state * state, char * query, int type ) {
+void info_init_search( search_state * state, const char * query, int type ) {
assert(state != NULL);
@@ -1066,7 +1067,7 @@
u_int16_t type, u_int16_t class, u_int32_t ttl,
size_t rr_len ,u_char * rr_data,
void * user_data ,
- void * buf_start, void * buf_end )
+ const void * buf_start, const void * buf_end )
{
decoded_message_t * msg = (decoded_message_t *)user_data;
@@ -1143,14 +1144,16 @@
memset(cpu,0,sizeof(cpu));
memset(os,0,sizeof(os));
- /* comparison of distinct pointer types lacks a cast */
+ /* comparison of distinct pointer types lacks a cast */
/* vvvvv - ???? */
+ // FIXME: MAXDNAME is 1025, now can only be 255 maximum
if( (*now <= MAXDNAME) && ( (void *)(now + 1 + *now) < buf_end) ) {
memcpy(cpu, now + 1, *now );
now += *now;
now += 1;
+ // FIXME: MAXDNAME is 1025, now can only be 255 maximum
if( (*now <= MAXDNAME) && ( (void*)(now + 1 + *now) < buf_end)) {
memcpy(os, now + 1, *now );
@@ -1240,7 +1243,7 @@
return 0;
}
-void info_debug_rr_list( list_t * list ) {
+void info_debug_rr_list( const list_t * list ) {
ll_entry_t * el;
foreach(el,list) {
@@ -1263,8 +1266,8 @@
return q;
}
-
-static void debug_question_list( list_t * list ) {
+#ifdef DEBUG
+static void debug_question_list( const list_t * list ) {
ll_entry_t * el = NULL;
foreach(el,list) {
@@ -1277,8 +1280,11 @@
}
}
}
+#else
+#define debug_question_list(l)
+#endif
-void info_debug_message( decoded_message_t * msg ) {
+void info_debug_message( const decoded_message_t * msg ) {
debug("Questions:\n");
debug_question_list(msg->questions);
debug("Answers:\n");
@@ -1383,12 +1389,14 @@
return result;
}
-void info_copy_questions( decoded_message_t * src, decoded_message_t * dst) {
+void info_copy_questions( const decoded_message_t * src,
+ const decoded_message_t * dst) {
+ ll_entry_t * el;
if( src == NULL ) return;
if( dst == NULL ) return;
- ll_entry_t * el = NULL;
+ el = NULL;
foreach(el,src->questions) {
dns_question * s = (dns_question *)el->data;
dns_question * q = info_new_question(s->query_arg,s->query_type,s->query_class);
diff -ur tmdns/server/info.h tmdns.c/server/info.h
--- tmdns/server/info.h 2004-02-08 09:00:44.000000000 -0500
+++ tmdns.c/server/info.h 2004-02-08 14:56:44.000000000 -0500
@@ -42,25 +42,24 @@
void info_init(void);
void info_destroy(void);
-void info_init_search( search_state * state, char * query, int type );
+void info_init_search( search_state * state, const char * query, int type );
int info_search( search_state * state );
void info_drop_record(search_state * s);
-void debug_rr( dns_rr * src );
+void debug_rr( const dns_rr * src );
int info_compare_rr(dns_rr * a, dns_rr * b);
dns_rr * info_clone_rr( dns_rr * src );
decoded_message_t * info_new_message(void);
decoded_message_t * info_decode_packet( struct udp_packet *udp_pkt );
-void info_free_decoded_message( decoded_message_t * message );
-void info_debug_message( decoded_message_t * msg );
-
-dns_question * info_new_question(const char * domain, u_int16_t type, u_int16_t class);
-void info_copy_questions( decoded_message_t * src, decoded_message_t * dst);
+dns_question * info_new_question(const char * domain, u_int16_t type,
+ u_int16_t class);
+void info_copy_questions( const decoded_message_t * src,
+ const decoded_message_t * dst);
-void info_debug_rr_list( list_t * list );
-void info_debug_message( decoded_message_t * msg );
+void info_debug_rr_list( const list_t * list );
+void info_debug_message( const decoded_message_t * msg );
void info_free_decoded_message( decoded_message_t * message );
diff -ur tmdns/server/llist.c tmdns.c/server/llist.c
--- tmdns/server/llist.c 2004-02-07 09:11:50.000000000 -0500
+++ tmdns.c/server/llist.c 2004-02-08 14:29:49.000000000 -0500
@@ -110,7 +110,7 @@
@param control The controlling linked list structure as created by ll_new
@return A pointer to the first entry in the linked list, or NULL on error
************************************************/
-ll_entry_t *ll_first(list_t *control)
+ll_entry_t *ll_first(const list_t *control)
{
if(control==NULL){
debug("ll_entry_t: NULL parameter passed in\n");
@@ -126,7 +126,7 @@
@param element A list element to be used to obtain the next element
@return A pointer to the next element or NULL on error
**********************************************/
-ll_entry_t *ll_next(ll_entry_t *element)
+ll_entry_t *ll_next(const ll_entry_t *element)
{
if(element==NULL){
debug("ll_entry_t: NULL parameter passed in\n");
diff -ur tmdns/server/llist.h tmdns.c/server/llist.h
--- tmdns/server/llist.h 2004-02-08 09:00:44.000000000 -0500
+++ tmdns.c/server/llist.h 2004-02-08 14:30:14.000000000 -0500
@@ -40,8 +40,8 @@
/*... an iterator ... */
-extern ll_entry_t *ll_first(list_t *);
-extern ll_entry_t *ll_next(ll_entry_t *);
+extern ll_entry_t *ll_first(const list_t *);
+extern ll_entry_t *ll_next(const ll_entry_t *);
/*... element destructor ... */
diff -ur tmdns/server/serv_udp.c tmdns.c/server/serv_udp.c
--- tmdns/server/serv_udp.c 2004-02-08 09:00:44.000000000 -0500
+++ tmdns.c/server/serv_udp.c 2004-02-08 15:00:21.000000000 -0500
@@ -41,12 +41,12 @@
static struct sockaddr mcast_v4_sa;
#ifdef DEBUG
-static const char * udp_answerdst2str(dns_t * answer);
+static const char * udp_answerdst2str(const dns_t * answer);
#endif
static int udp_sock_open( int mcast ,
- struct sockaddr * sock,
- char * ifname );
-static const char * udp_sockaddr_str( struct sockaddr * addr );
+ const struct sockaddr * sock,
+ const char * ifname );
+static const char * udp_sockaddr_str( const struct sockaddr * addr );
static struct ifaddrs * interfaces = NULL;
@@ -203,7 +203,7 @@
}
if( n_mcast > 0 ) {
- int i = 0;
+ unsigned int i = 0;
unsigned int mcastidx = 0;
const char * seen = "";
@@ -309,8 +309,8 @@
*
****************************************************************************/
static int udp_sock_open( int mcast ,
- struct sockaddr * sock ,
- char * ifname )
+ const struct sockaddr * sock ,
+ const char * ifname )
{
int fd;
unsigned int yes = 1;
@@ -497,7 +497,7 @@
/*****************************************************************************
* Send packet to the multicast address.
*****************************************************************************/
-void udp_send_mcast_dnsmsg( dns_t * pkt ) {
+void udp_send_mcast_dnsmsg( const dns_t * pkt ) {
if( pkt->to_mcast ) {
int i = 0;
@@ -520,8 +520,8 @@
*****************************************************************************/
void udp_send_dnsmsg_to(
int sockfd,
- struct sockaddr * dst_address , socklen_t dst_len ,
- dns_t * pkt )
+ const struct sockaddr * dst_address , socklen_t dst_len ,
+ const dns_t * pkt )
{
if( sockfd >= 0 ) {
@@ -538,7 +538,7 @@
/*****************************************************************************
* Send packet to an unicast address. (old)
*****************************************************************************/
-void udp_send_dnsmsg( int sockfd, dns_t * pkt ) {
+void udp_send_dnsmsg( int sockfd, const dns_t * pkt ) {
if( sockfd >= 0 ) {
@@ -566,7 +566,7 @@
* Copy address from an incomming udp_packet to an answer packet.
*
*****************************************************************************/
-void udp_copy_answer_address(dns_t * answer, struct udp_packet * udp_pkt) {
+void udp_copy_answer_address(dns_t * answer,const struct udp_packet * udp_pkt) {
memcpy( (void *)&(answer->dst_address),
(void *)&(udp_pkt->src_address),
@@ -587,7 +587,7 @@
#define INET6_ADDRSTRLEN 256
#endif
#define PORT_LEN 7
-static const char * udp_sockaddr_str( struct sockaddr * addr ) {
+static const char * udp_sockaddr_str( const struct sockaddr * addr ) {
static char result[INET6_ADDRSTRLEN+PORT_LEN+2];
int addr_port;
@@ -614,12 +614,12 @@
}
#ifdef DEBUG
-static const char * udp_answerdst2str(dns_t * answer) {
+static const char * udp_answerdst2str(const dns_t * answer) {
return udp_sockaddr_str( &(answer->dst_address) );
}
#endif
-const char * udp_pktsrc2str(struct udp_packet * udp_pkt) {
+const char * udp_pktsrc2str(const struct udp_packet * udp_pkt) {
return udp_sockaddr_str( &(udp_pkt->src_address) );
}
diff -ur tmdns/server/serv_udp.h tmdns.c/server/serv_udp.h
--- tmdns/server/serv_udp.h 2004-02-08 09:00:44.000000000 -0500
+++ tmdns.c/server/serv_udp.h 2004-02-08 15:00:16.000000000 -0500
@@ -7,18 +7,18 @@
extern int udp_packet_read(int sockfd, struct udp_packet *udp_pkt);
extern int udp_open_sockets( int * sockets );
-extern void udp_send_dnsmsg(int, dns_t * );
+extern void udp_send_dnsmsg(int, const dns_t * );
extern void udp_send_dnsmsg_to(
int sockfd,
- struct sockaddr * dst_address , socklen_t dst_len ,
- dns_t * pkt);
+ const struct sockaddr * dst_address , socklen_t dst_len ,
+ const dns_t * pkt);
-extern void udp_send_mcast_dnsmsg(dns_t * );
+extern void udp_send_mcast_dnsmsg(const dns_t * );
-void udp_copy_answer_address(dns_t * answer, struct udp_packet * udp_pkt);
+void udp_copy_answer_address(dns_t * answer, const struct udp_packet * udp_pkt);
-const char * udp_pktsrc2str(struct udp_packet * udp_pkt);
+const char * udp_pktsrc2str(const struct udp_packet * udp_pkt);
#endif /*SERV_UDP_H*/
diff -ur tmdns/server/tmdns.8 tmdns.c/server/tmdns.8
--- tmdns/server/tmdns.8 2004-01-31 12:03:39.000000000 -0500
+++ tmdns.c/server/tmdns.8 2004-02-08 13:51:19.000000000 -0500
@@ -21,7 +21,7 @@
.PP
The
.I tmdns
-programm accepts the following options:
+program accepts the following options:
.TP
.B \-b
disable dns bridge mode for local queries.
@@ -39,7 +39,7 @@
\fB\-p\ \fIport\fR
Listen on port
.I port
-instead on the dfault multicast dns port 5353.
+instead on the default multicast dns port 5353.
.TP
.B \-P
Print current configuration to
@@ -68,7 +68,7 @@
.I dns bridge
mode is enabled (default), it also listens on the unicast DNS port
(port 53) for unicast DNS queries and forwards them to the mDNS
-multicast group. It gathers responses responses from other mDNS
+multicast group. It gathers responses from other mDNS
responders and routes them back to the querier as unicast DNS
response.
.SH FILES
diff -ur tmdns/server/tmdns.c tmdns.c/server/tmdns.c
--- tmdns/server/tmdns.c 2004-02-08 09:00:46.000000000 -0500
+++ tmdns.c/server/tmdns.c 2004-02-08 15:06:24.000000000 -0500
@@ -90,7 +90,7 @@
* with return code 0.
*
*****************************************************************************/
-static int get_options( int argc, char ** argv ) {
+static int get_options( int argc, const char ** argv ) {
char c = 0;
int dns_bridge = 0;
@@ -98,7 +98,7 @@
int want_printout = 0;
int want_version = 0;
int debug_port = 0;
- char * progname = argv[0];
+ const char * progname = argv[0];
const char * confname = NULL;
conf_defaults();
@@ -512,7 +512,7 @@
answer->u.hdr.id = 0;
}
-static void send_mcast_response( decoded_message_t * response ) {
+static void send_mcast_response( const decoded_message_t * response ) {
int answer_count = 0;
dns_t answer;
@@ -534,7 +534,7 @@
}
if( answer_count > 0 ) {
- debug_dns("answer to client", &(answer.u.raw) );
+ debug_dns("answer to client", answer.u.raw );
udp_send_mcast_dnsmsg( &answer );
}
}
@@ -555,7 +555,7 @@
answer->u.hdr.qr = 0;
}
-static void send_mcast_query( decoded_message_t * response ) {
+static void send_mcast_query( const decoded_message_t * response ) {
dns_t answer;
ll_entry_t * el = NULL;
@@ -607,8 +607,8 @@
*****************************************************************************/
static void send_ucast_response(
int sock ,
- struct sockaddr * dst_address , socklen_t dst_len ,
- decoded_message_t * response )
+ const struct sockaddr * dst_address , socklen_t dst_len ,
+ const decoded_message_t * response )
{
int answer_count = 0;
@@ -647,7 +647,7 @@
}
if( (answer_count > 0) || (response->rcode != 0) ) {
- debug_dns("answer to client", &(answer.u.raw) );
+ debug_dns("answer to client", answer.u.raw );
udp_send_dnsmsg_to( sock , dst_address , dst_len , &answer );
}
}
@@ -675,7 +675,7 @@
ll_entry_t * el = NULL;
- debug_dns("multicast query ", &(udp_pkt->buf));
+ debug_dns("multicast query ", udp_pkt->buf);
debug("decode query ...\n");
@@ -767,7 +767,8 @@
*
* @return number of answers placed in the answer list.
*****************************************************************************/
-static int find_answers( decoded_message_t * query , decoded_message_t * response ) {
+static int find_answers( const decoded_message_t * query ,
+ const decoded_message_t * response ) {
ll_entry_t * el = NULL;
dns_rr * srv_rr = NULL;
@@ -786,10 +787,10 @@
while( info_search(&s) > 0 ) {
- debug("found\n");
-
dns_rr * clone = NULL;
+ debug("found\n");
+
clone = info_clone_rr(s.data);
if( clone != NULL ) {
@@ -874,7 +875,7 @@
decoded_message_t * query = NULL;
decoded_message_t * response = NULL;
- debug_dns("unicast query from client", &(udp_pkt->buf));
+ debug_dns("unicast query from client", udp_pkt->buf);
debug("decode query ...\n");
if( (query = info_decode_packet(udp_pkt)) == NULL ) {
@@ -932,7 +933,7 @@
decoded_message_t * query = NULL;
decoded_message_t * response = NULL;
- debug_dns("unicast query from client", &(udp_pkt->buf));
+ debug_dns("unicast query from client", udp_pkt->buf);
debug("decode query ...\n");
if( (query = info_decode_packet(udp_pkt)) == NULL ) {
@@ -979,6 +980,7 @@
response->sock = sock;
response->timeout = time(NULL) + config.gather_delay;
+ // FIXME: answer_count is not used. delete ?
answer_count = find_answers( query , response );
ll_add(query_list, response);
diff -ur tmdns/server/tmdns.conf.5 tmdns.c/server/tmdns.conf.5
--- tmdns/server/tmdns.conf.5 2004-01-31 12:03:39.000000000 -0500
+++ tmdns.c/server/tmdns.conf.5 2004-02-08 13:51:52.000000000 -0500
@@ -12,7 +12,7 @@
Run
.I tmdns \-P
to get a template configuration file.
-That template is documented and shows alle known parameters and
+That template is documented and shows all known parameters and
default values for each parameter.
.SH "SEE ALSO"
tmdns(8),
diff -ur tmdns/server/tmdns.services.5 tmdns.c/server/tmdns.services.5
--- tmdns/server/tmdns.services.5 2004-02-07 09:11:52.000000000 -0500
+++ tmdns.c/server/tmdns.services.5 2004-02-08 13:55:04.000000000 -0500
@@ -47,7 +47,7 @@
with the lowest priority value on the network.
.TP
.B weight
-Clients should prefer the highest wighted service record they get.
+Clients should prefer the highest weighted service record they get.
.TP
.B name
A name given to this service. This field may be left empty,
@@ -58,18 +58,18 @@
In both cases a pointer record is advertised under the name
.I _<sevice>._<proto>.local.
to allow clients to find all services of a specific type
-whithin the local network.
+within the local network.
.PP
All strings in
.I text
-lines and The content of the name field must be encoded as UTF8 when
-you whish to include non-ascii characters. Dots, spaces and backslashes
+lines and the content of the name field must be encoded as UTF8 when
+you wish to include non-ascii characters. Dots, spaces and backslashes
are escaped as needed. The name may not exceed 63 characters, escaped
characters count as two chars.
.PP
You may use the
.I iconv
-utility to en- and decode the name fields to and from <our local charset.
+utility to en- and decode the name fields to and from your local charset.
.SH EXAMPLES
.TP
Advertise a DNS server
diff -ur tmdns/tmdns.spec tmdns.c/tmdns.spec
--- tmdns/tmdns.spec 2004-02-08 01:46:20.000000000 -0500
+++ tmdns.c/tmdns.spec 2004-02-08 13:43:50.000000000 -0500
@@ -64,7 +64,6 @@
%post
if [ "$1" = "1" ]; then
/sbin/chkconfig --add tmdns
- /sbin/service tmdns condrestart > /dev/null 2>&1
fi
%preun
@@ -79,9 +78,10 @@
fi
%files
-%defattr(0644,root,root,0755)
+%defattr(-,root,root)
%doc %{_docdir}/%{name}-%{version}/*
%attr(0755,root,root) %{_sbindir}/tmdns
+%attr(0755,root,root) %{_sbindir}/update-resolvrdv
%attr(0755,root,root) %{_sbindir}/register-service
%attr(755,root,root) %{_initrddir}/%{name}
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/tmdns.conf