Nmap Development mailing list archives

Re: [PATCH] Make 15 functions static


From: Kris Katterjohn <kjak () ispwest com>
Date: Fri, 25 Aug 2006 22:45:28 -0500

Eddie Bell wrote:
hello kris,

I need get_initial_ttl_guess() for my imminent traceroute patch

thanks
- eddie

On 25/08/06, Kris Katterjohn <kjak () ispwest com> wrote:
This patch localizes these 15 symbols:

mac_prefix_init
connect_dns_servers
encoded_name_to_normal
put_dns_packet_on_wire
get_initial_ttl_guess
xml_sf_convert
end_svcprobe
servicescan_read_handler
parse_nmap_service_probes
servicescan_write_handler
servicescan_connect_handler
sendrawtcppingquery
sendrawudppingquery
sendrawtcpudppingqueries
get_connecttcpscan_results

.. in their respective files.


Okey-dokey, here's the updated patch. Anybody else working with one of
these?

Kris Katterjohn
--- x/MACLookup.cc      2006-03-05 18:00:03.000000000 -0600
+++ z/MACLookup.cc      2006-08-25 09:46:34.000000000 -0500
@@ -128,7 +128,7 @@ static inline int MACTableHash(int prefi
   return prefix % table_capacity;
 }
 
-void mac_prefix_init() {
+static void mac_prefix_init() {
   static int initialized = 0;
   if (initialized) return;
   initialized = 1;

--- x/nmap_dns.cc       2006-07-04 17:32:50.000000000 -0500
+++ z/nmap_dns.cc       2006-08-25 10:03:12.000000000 -0500
@@ -291,7 +291,7 @@ static ScanProgressMeter *SPM;
 
 //------------------- Prototypes and macros ---------------------
 
-void put_dns_packet_on_wire(request *req);
+static void put_dns_packet_on_wire(request *req);
 
 #define ACTION_FINISHED 0
 #define ACTION_CNAME_LIST 1
@@ -391,7 +391,7 @@ static void write_evt_handler(nsock_pool
 // Takes a DNS request structure and actually puts it on the wire
 // (calls nsock_write()). Does various other tasks like recording
 // the time for the timeout.
-void put_dns_packet_on_wire(request *req) {
+static void put_dns_packet_on_wire(request *req) {
   char packet[512];
   int plen=0;
   u32 ip;
@@ -593,7 +593,7 @@ static u32 parse_inaddr_arpa(unsigned ch
 // Turns a DNS packet encoded name (see the RFC) and turns it into
 // a normal decimal separated hostname.
 // ASSUMES NAME LENGTH/VALIDITY HAS ALREADY BEEN VERIFIED
-int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){
+static int encoded_name_to_normal(unsigned char *buf, char *output, int outputsize){
   while (buf[0]) {
     if (buf[0] >= outputsize-1) return -1;
     memcpy(output, buf+1, buf[0]);
@@ -833,7 +833,7 @@ void free_dns_servers() {
 
 
 // Creates a new nsi for each DNS server
-void connect_dns_servers() {
+static void connect_dns_servers() {
   std::list<dns_server *>::iterator serverI;
   dns_server *s;
 

--- x/output.cc 2006-06-28 17:04:17.000000000 -0500
+++ z/output.cc 2006-08-25 09:58:07.000000000 -0500
@@ -156,6 +156,37 @@ static void skid_output(char *s)
       }
 }
 
+/* Remove all "\nSF:" from fingerprints */
+static char* xml_sf_convert (const char* str) {
+  char *temp = (char *) safe_malloc(strlen(str) + 1);
+  char *dst = temp, *src = (char *)str;
+  char *ampptr = 0;
+  int charcount = 0;
+
+  while(*src && charcount < 2035) { /* 2048 - 14 */
+    if (strncmp(src, "\nSF:", 4) == 0) {
+      src += 4;
+      continue;
+    }
+    /* Needed so "&something;" is not truncated midway */
+    if (*src == '&') {
+      ampptr = dst;
+    }
+    else if (*src == ';') {
+      ampptr = 0;
+    }
+    *dst++ = *src++;
+    charcount++;
+  }
+  if (ampptr != 0) {
+    *ampptr = '\0';
+  }
+  else {
+    *dst = '\0';
+  }
+  return temp;
+}
+
 
 // Creates an XML <service> element for the information given in
 // serviceDeduction.  It will be 0-length if none is neccessary.
@@ -741,37 +772,6 @@ void log_vwrite(int logt, const char *fm
   return;
 }
 
-/* Remove all "\nSF:" from fingerprints */
-char* xml_sf_convert (const char* str) {
-  char *temp = (char *) safe_malloc(strlen(str) + 1);
-  char *dst = temp, *src = (char *)str;
-  char *ampptr = 0;
-  int charcount = 0;
-
-  while(*src && charcount < 2035) { /* 2048 - 14 */
-    if (strncmp(src, "\nSF:", 4) == 0) {
-      src += 4;
-      continue;
-    }
-    /* Needed so "&something;" is not truncated midway */
-    if (*src == '&') {
-      ampptr = dst;
-    }
-    else if (*src == ';') {
-      ampptr = 0;
-    }
-    *dst++ = *src++;
-    charcount++;
-  }
-  if (ampptr != 0) {
-    *ampptr = '\0';
-  }
-  else {
-    *dst = '\0';
-  }
-  return temp;
-}
-
 /* Write some information (printf style args) to the given log stream(s).
  Remember to watch out for format string bugs.  */
 void log_write(int logt, const char *fmt, ...)

--- x/output.h  2006-04-22 18:03:01.000000000 -0500
+++ z/output.h  2006-08-25 09:58:12.000000000 -0500
@@ -203,5 +203,4 @@ void printStatusMessage();
 void printfinaloutput();
 
 char* xml_convert (const char* str);
-char* xml_sf_convert (const char* str);
 #endif /* OUTPUT_H */

--- x/service_scan.cc   2006-07-04 18:05:03.000000000 -0500
+++ z/service_scan.cc   2006-08-25 10:28:02.000000000 -0500
@@ -255,10 +255,10 @@ struct substargs {
 };
 
 /********************   PROTOTYPES *******************/
-void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata);
-void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata);
-void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata);
-void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod 
nsi);
+static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata);
+static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata);
+static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata);
+static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, 
nsock_iod nsi);
 
 ServiceProbeMatch::ServiceProbeMatch() {
   deflineno = -1;
@@ -1138,7 +1138,7 @@ void parse_nmap_service_probe_file(AllPr
 
 // Parses the nmap-service-probes file, and adds each probe to
 // the already-created 'probes' vector.
-void parse_nmap_service_probes(AllProbes *AP) {
+static void parse_nmap_service_probes(AllProbes *AP) {
   char filename[256];
 
   if (nmap_fetchfile(filename, sizeof(filename), "nmap-service-probes") == -1){
@@ -1893,7 +1893,7 @@ static void handleHostIfDone(ServiceGrou
 // A simple helper function to cancel further work on a service and
 // set it to the given probe_state pass NULL for nsi if you don't want
 // it to be deleted (for example, if you already have done so).
-void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, nsock_iod 
nsi) {
+static void end_svcprobe(nsock_pool nsp, enum serviceprobestate probe_state, ServiceGroup *SG, ServiceNFO *svc, 
nsock_iod nsi) {
   list<ServiceNFO *>::iterator member;
   Target *target = svc->target;
 
@@ -1982,7 +1982,7 @@ static int launchSomeServiceProbes(nsock
 }
 
 
-void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
+static void servicescan_connect_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
   nsock_iod nsi = nse_iod(nse);
   enum nse_status status = nse_status(nse);
   enum nse_type type = nse_type(nse);
@@ -2042,7 +2042,7 @@ void servicescan_connect_handler(nsock_p
   return;
 }
 
-void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
+static void servicescan_write_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
   enum nse_status status = nse_status(nse);
   nsock_iod nsi;
   ServiceNFO *svc = (ServiceNFO *)mydata;
@@ -2092,7 +2092,7 @@ void servicescan_write_handler(nsock_poo
   return;
 }
 
-void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
+static void servicescan_read_handler(nsock_pool nsp, nsock_event nse, void *mydata) {
   nsock_iod nsi = nse_iod(nse);
   enum nse_status status = nse_status(nse);
   enum nse_type type = nse_type(nse);

--- x/targets.cc        2006-07-04 18:05:03.000000000 -0500
+++ z/targets.cc        2006-08-25 10:06:19.000000000 -0500
@@ -887,8 +887,8 @@ static int sendconnecttcpqueries(Target 
   return 0;
 }
 
-int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port,
-                       u16 seq, struct timeval *time, struct pingtune *pt) {
+static int sendrawudppingquery(int rawsd, struct eth_nfo *eth, Target *target, u16 probe_port,
+                              u16 seq, struct timeval *time, struct pingtune *pt) {
 int trynum = 0;
 unsigned short sportbase;
 
@@ -906,8 +906,8 @@ else { 
  return 0;
 }
 
-int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port,
-                       u16 seq, struct timeval *time, struct pingtune *pt) {
+static int sendrawtcppingquery(int rawsd, struct eth_nfo *eth, Target *target, int pingtype, u16 probe_port,
+                              u16 seq, struct timeval *time, struct pingtune *pt) {
 int trynum = 0;
 int myseq;
 unsigned short sportbase;
@@ -934,8 +934,8 @@ else { 
  return 0;
 }
 
-int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, 
-                         struct timeval *time, struct pingtune *pt) {
+static int sendrawtcpudppingqueries(int rawsd, eth_t *ethsd, Target *target, int pingtype, u16 seq, 
+                                   struct timeval *time, struct pingtune *pt) {
   int i;
   struct eth_nfo eth;
   struct eth_nfo *ethptr = NULL;
@@ -1096,10 +1096,10 @@ static int sendpingqueries(int sd, int r
 }
 
 
-int get_connecttcpscan_results(struct tcpqueryinfo *tqi, 
-                              Target *hostbatch[], 
-                              struct timeval *time, struct pingtune *pt, 
-                              struct timeout_info *to) {
+static int get_connecttcpscan_results(struct tcpqueryinfo *tqi, 
+                                     Target *hostbatch[], 
+                                     struct timeval *time, struct pingtune *pt, 
+                                     struct timeout_info *to) {
 
 int res, res2;
 int tm;

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: