]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
work on versioning; new log_fn function
authorNick Mathewson <nickm@torproject.org>
Fri, 9 May 2003 02:25:37 +0000 (02:25 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 9 May 2003 02:25:37 +0000 (02:25 +0000)
svn:r288

src/common/fakepoll.h
src/common/log.h
src/or/directory.c
src/or/main.c
src/or/or.h
src/or/routers.c

index 533ee3f9849833beb4483325f3c51522c2879028..ca7f44a4ea2d6d4a24815dc94aaaf184a7cde898 100644 (file)
@@ -9,6 +9,9 @@
 /*
  * Changes :
  * $Log$
+ * Revision 1.2  2003/05/09 02:25:37  nickm
+ * work on versioning; new log_fn function
+ *
  * Revision 1.1  2002/09/03 18:43:50  nickm
  * Add function to fake a poll call using select
  *
@@ -17,7 +20,6 @@
 #define __FAKEPOLL_H
 
 #include "orconfig.h"
-#undef VERSION
 
 #ifndef HAVE_POLL_H
 #ifndef HAVE_SYS_POLL_H
index e70aa2f5bdb5438cd8864d85c230a79753c56e4f..7e24ae0a15fce16ebeb2adcffbfcc8a4aa32f1fe 100644 (file)
@@ -8,8 +8,11 @@
 /*
  * Changes :
  * $Log$
- * Revision 1.1  2002/06/26 22:45:50  arma
- * Initial revision
+ * Revision 1.2  2003/05/09 02:25:37  nickm
+ * work on versioning; new log_fn function
+ *
+ * Revision 1.1.1.1  2002/06/26 22:45:50  arma
+ * initial commit: current code
  *
  * Revision 1.5  2002/01/26 18:52:00  mp292
  * Reviewed according to Secure-Programs-HOWTO.
 /* Outputs a message to stdout and also logs the same message using syslog. */
 void log(int severity, const char *format, ...);
 
+#ifdef __GNUCC__
+#define log_fn(severity, format, args...) \
+  log((severity), __PRETTY_FUNCTION__ # "(): " # format, ##args)
+#else
+#define log_fn log
+#endif
+
 # define __LOG_H
 #endif
index 49a85e95dcad6cae62bfa85f3f477cdb68bf31d5..bba51eb8b4f0f9b3fdfa645d966d302f9dd05b46 100644 (file)
@@ -157,7 +157,7 @@ int connection_dir_process_inbuf(connection_t *conn) {
       log(LOG_DEBUG,"connection_dir_process_inbuf(): and got a %s directory; updated routers.", 
           conn->pkey ? "authenticated" : "unauthenticated");
     }
-    
+
     if(options.ORPort) { /* connect to them all */
       router_retry_connections();
     }
index 9724f121f5b0c81e1c9e160563e917b9b3e35910..1e8f428277d6d4c52ffd8afd8de1b357456b4679 100644 (file)
@@ -708,8 +708,7 @@ dump_signed_directory_to_string_impl(char *s, int maxlen, directory_t *dir,
   eos = s+maxlen;
   strncpy(s, 
           "signed-directory\n"
-          "client-software x y z\n" /* XXX make this real */
-          "server-software a b c\n\n" /* XXX make this real */
+          "recommended-software 0.0.2pre4,0.0.2pre5,0.0.2pre6\n" /* XXX make this real */
           , maxlen);
   
   i = strlen(s);
index e2f3a885ec7d09ff169645c6bc15b64d7978d329..d140aaf2a62c62064c1a487ec7c52aec43981ac3 100644 (file)
@@ -330,6 +330,7 @@ typedef struct {
 typedef struct {
   routerinfo_t **routers;
   int n_routers;
+  char *software_versions;
 } directory_t;
 
 struct crypt_path_t { 
index 66971d1f167e3443723da0cc13c318b32a34e67d..93dc3367b9860a681379eec5ae2e333d378a3801 100644 (file)
@@ -44,20 +44,20 @@ int learn_my_address(struct sockaddr_in *me) {
 
   /* obtain local host information */
   if(gethostname(localhostname,512) < 0) {
-    log(LOG_ERR,"Error obtaining local hostname.");
+    log_fn(LOG_ERR,"Error obtaining local hostname.");
     return -1;
   }
-  log(LOG_DEBUG,"learn_my_address(): localhostname is '%s'.",localhostname);
+  log_fn(LOG_DEBUG,"localhostname is '%s'.",localhostname);
   localhost = gethostbyname(localhostname);
   if (!localhost) {
-    log(LOG_ERR,"Error obtaining local host info.");
+    log_fn(LOG_ERR,"Error obtaining local host info.");
     return -1;
   }
   memset(me,0,sizeof(struct sockaddr_in));
   me->sin_family = AF_INET;
   memcpy((void *)&me->sin_addr,(void *)localhost->h_addr,sizeof(struct in_addr));
   me->sin_port = htons(options.ORPort);
-  log(LOG_DEBUG,"learn_my_address(): chose address as '%s'.",inet_ntoa(me->sin_addr));
+  log_fn(LOG_DEBUG,"chose address as '%s'.",inet_ntoa(me->sin_addr));
 
   return 0;
 }
@@ -69,7 +69,7 @@ void router_retry_connections(void) {
   for (i=0;i<directory->n_routers;i++) {
     router = directory->routers[i];
     if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
-      log(LOG_DEBUG,"retry_all_connections(): connecting to OR %s:%u.",router->address,router->or_port);
+      log_fn(LOG_DEBUG,"connecting to OR %s:%u.",router->address,router->or_port);
       connection_or_connect_as_or(router);
     }
   }
@@ -199,19 +199,19 @@ int router_get_list_from_file(char *routerfile)
   assert(routerfile);
   
   if (strcspn(routerfile,CONFIG_LEGAL_FILENAME_CHARACTERS) != 0) {
-    log(LOG_ERR,"router_get_list_from_file(): Filename %s contains illegal characters.",routerfile);
+    log_fn(LOG_ERR,"Filename %s contains illegal characters.",routerfile);
     return -1;
   }
   
   if(stat(routerfile, &statbuf) < 0) {
-    log(LOG_ERR,"router_get_list_from_file(): Could not stat %s.",routerfile);
+    log_fn(LOG_ERR,"Could not stat %s.",routerfile);
     return -1;
   }
 
   /* open the router list */
   fd = open(routerfile,O_RDONLY,0);
   if (fd<0) {
-    log(LOG_ERR,"router_get_list_from_file(): Could not open %s.",routerfile);
+    log_fn(LOG_ERR,"Could not open %s.",routerfile);
     return -1;
   }
 
@@ -244,11 +244,10 @@ int router_get_list_from_file(char *routerfile)
 
 typedef enum {
   K_ACCEPT,
-  K_CLIENT_SOFTWARE, 
   K_DIRECTORY_SIGNATURE,
+  K_RECOMMENDED_SOFTWARE,
   K_REJECT, 
   K_ROUTER, 
-  K_SERVER_SOFTWARE,
   K_SIGNED_DIRECTORY,
   K_SIGNING_KEY,
   _SIGNATURE, 
@@ -261,11 +260,10 @@ struct token_table_ent { char *t; int v; };
 
 static struct token_table_ent token_table[] = {
   { "accept", K_ACCEPT },
-  { "client-software", K_CLIENT_SOFTWARE },
   { "directory-signature", K_DIRECTORY_SIGNATURE },
   { "reject", K_REJECT },
   { "router", K_ROUTER },
-  { "server-software", K_SERVER_SOFTWARE },
+  { "recommended-software", K_RECOMMENDED_SOFTWARE },
   { "signed-directory", K_SIGNED_DIRECTORY },
   { "signing-key", K_SIGNING_KEY },
   { NULL, -1 }
@@ -395,11 +393,10 @@ router_dump_token(directory_token_t *tok) {
       puts("EOF");
       return;
     case K_ACCEPT: printf("Accept"); break;
-    case K_CLIENT_SOFTWARE: printf("Client-Software"); break;
     case K_DIRECTORY_SIGNATURE: printf("Directory-Signature"); break;
     case K_REJECT: printf("Reject"); break;
+    case K_RECOMMENDED_SOFTWARE: printf("Server-Software"); break;
     case K_ROUTER: printf("Router"); break;
-    case K_SERVER_SOFTWARE: printf("Server-Software"); break;
     case K_SIGNED_DIRECTORY: printf("Signed-Directory"); break;
     case K_SIGNING_KEY: printf("Signing-Key"); break;
     default:
@@ -518,6 +515,7 @@ int router_get_dir_from_string(char *s, crypto_pk_env_t *pkey)
     log(LOG_ERR, "Error resolving directory");
     return -1;
   }
+  /* XXXX Check version number */
   return 0;
 }
 
@@ -528,6 +526,7 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
   char digest[20];
   char signed_digest[128];
   directory_t *new_dir = NULL;
+  char *versions;
   
 #define NEXT_TOK()                                                      \
   do {                                                                  \
@@ -551,16 +550,19 @@ int router_get_dir_from_string_impl(char *s, directory_t **dest,
   TOK_IS(K_SIGNED_DIRECTORY, "signed-directory");
 
   NEXT_TOK();
-  TOK_IS(K_CLIENT_SOFTWARE, "client-software");
-
-  NEXT_TOK();
-  TOK_IS(K_SERVER_SOFTWARE, "server-software");
+  TOK_IS(K_RECOMMENDED_SOFTWARE, "recommended-software");
+  if (tok.val.cmd.n_args != 1) {
+    log(LOG_ERR, "Invalid recommded-software line");
+    return -1;
+  }
+  versions = strdup(tok.val.cmd.args[0]);
   
   NEXT_TOK();
   if (router_get_list_from_string_tok(&s, &new_dir, &tok)) {
     log(LOG_ERR, "Error reading routers from directory");
     return -1;
   }
+  new_dir->software_versions = versions;
   
   TOK_IS(K_DIRECTORY_SIGNATURE, "directory-signature");
   NEXT_TOK();