Linux HAM/Amateur Radio development
 help / color / mirror / Atom feed
* ax25-apps/-tools: clarification about the project status
@ 2009-01-26 17:31 IT2 Stuart Blake Tener, USNR
  2009-10-23 13:06 ` [PATCH] ax25ipd : added provision for dynamic dns hosts Bernard Pidoux
  0 siblings, 1 reply; 6+ messages in thread
From: IT2 Stuart Blake Tener, USNR @ 2009-01-26 17:31 UTC (permalink / raw)
  To: linux-hams

To whom it shall concern:

    There are many reasons why it seems the project looks dead to most hams
that might otherwise derive interest in using AX.25 based software within
the Linux environment (I am speaking for how I see it myself, and some hams
I know that are into Linux).

    I read this list, and have a rather busy lifestyle (as many people do),
this ought be the place where issues concerning AX.25 development are to be
discussed. It makes easy and convenient the capability to assert some level
of participation by a greater cross section of interested parties, and will
cause more interest to blossom.

    Moreover, many of us look at the wiki and see there has been no news or
updates in what appears to be well over two years. In the open source world
this says "dead". It may not be the case, but, it is the manner by which an
observer of casual interest might see it.

    Indeed I downloaded recently the "Linux Amateur Radio AX.25 How to", and
it is dated "19 September 2001"!! This says, project dead, and configuration
instructions for an olde kernel. Not even going to waste my time to try this
since its olde and inapplicable to the current kernel.

    Are these proper presumptions? Maybe not, but they put a face on ax.25
that instigates disinterest.

    A popular response in the open source world is "great suggestion! Let us
know when you have gotten work on it and gotten it implemented, here take
the lead on that..." I am sorry, but I do not have the time to implement the
totality of my suggestions, but they are proffered in an effort to define an
accurate review of how some us see the project.

    Here are some things that I think would help invigorate the project and
pronounce a more interesting posture and façade of its status.

    1) Update the wiki, place news, show dates that it was updated, create
the hype that the developers are not leaving their name attached and are in
the mood to take an active interest in the project.

    2) Update documentation, at least give the appearance that is has been
reviewed in light of today's kernels and distributions.

    3) Use the mailing list to solicit help and discuss issues and other
concerns with the community.

    4) Publish some kind of monthly status or update on where the project is
via the mailing list.

    If these things were done you would connect with more people, you would
present the façade of an actively engaged development of this technology. I
even think people might start to get more interested in playing with it.

    Remember, Linux has a lot of code in the kernel that is olde and is not
getting removed for "legacy purposes", and that perception of AX.25 has for
sure to change if it is not true (who knows?).
 

-- 

Very Respectfully,

IT2 Stuart Blake Tener, USNR
Las Vegas, NV / Beverly Hills, CA / Philadelphia, PA / Washington, DC
Amateur Radio Call Sign: N3GWG (Extra) / Marine Radio Operator Permit (MROP)
email: teners@bh90210.net (also carbon copies to my Blackberry)
phone: +(1) 310.358.0202 (Beverly Hills, CA, forwards to mobile phone)
phone: +(1) 215.338.6005 (Philadelphia, PA, voice mail only)
E-Fax: +(1) 928.437.4505 (Telecopier, fax to email gateway)

Military emails (checked monthly until remote NMCI access is secured)
NIPRNET: stuart.tener@navy.mil
NIPRNET: stuart.b.tener@us.army.mil
NRO:     teners@nro.mil
TS/SCI:  tenerstu@nro.ic.gov (GWAN)

Confidentiality Notice: This e-mail message, including any attachments, is
for the sole use of the intended recipient(s) and may contain confidential
and/or privileged information, though strictly at the UNCLASSIFIED level.
Any unauthorized review, use, disclosure or distribution is prohibited. If
you are not the intended recipient, please contact the sender by reply
e-mail and destroy all copies of the originate message.




--
To unsubscribe from this list: send the line "unsubscribe linux-hams" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ax25ipd : added provision for dynamic dns hosts
  2009-01-26 17:31 ax25-apps/-tools: clarification about the project status IT2 Stuart Blake Tener, USNR
@ 2009-10-23 13:06 ` Bernard Pidoux
  2009-11-02 17:22   ` Thomas Osterried
  2009-11-03 13:33   ` Bernard Pidoux
  0 siblings, 2 replies; 6+ messages in thread
From: Bernard Pidoux @ 2009-10-23 13:06 UTC (permalink / raw)
  To: linux-hams; +Cc: Ralf Baechle DL5RB, ax25

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

Hi All,

The following patch 
 
+/*
+* added provision for dynamic dns hosts
+  Steve Fraser vk5asf, June 2005
+*/

is still not included into "official" 
http://www.linux-ax25.org/pub/ax25-apps/ax25-apps-0.0.8-rc2.tar.gz

despite the fact that it has been used since 2005 by FPAC packet
switch nodes and that it looks very usefull in maintaining nodes
connected through ROSE network with dynamic IP changes.

Thus, I resend this patch in the hope that it will be
added in ax25-apps-0.0.8.

73 de Bernard, f6bvp



[-- Attachment #2: ax25ipd-0.0.8-rc2.patch --]
[-- Type: text/plain, Size: 5484 bytes --]

--- ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-06-14 10:11:48.000000000 +0200
+++ ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-10-20 19:41:41.307206002 +0200
@@ -25,6 +25,10 @@
  * Terry Dawson, VK2KTJ, September 2001.
  */
 
+/*
+* added provision for dynamic dns hosts
+  Steve Fraser vk5asf, June 2005
+*/
 /* Define the current version number
  *
  * The first digit represents the major release (0 is a prototype release)
@@ -133,12 +137,13 @@
 
 /* routing.c */
 void route_init(void);
-void route_add(unsigned char *, unsigned char *, int, unsigned int);
+void route_add(unsigned char *, unsigned char *, unsigned char *, int, unsigned int);
 void bcast_add(unsigned char *);
 unsigned char *call_to_ip(unsigned char *);
 int is_call_bcast(unsigned char *);
 void send_broadcast(unsigned char *, int);
 void dump_routes(void);
+void update_dns(void);
 
 /* config.c */
 void config_init(void);
--- ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-06-14 10:07:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-10-20 15:36:29.896354012 +0200
@@ -154,7 +154,7 @@
 int parse_line(char *buf)
 {
 	char *p, *q;
-	unsigned char tcall[7], tip[4];
+	unsigned char tcall[7], tip[4], thost [256];
 	struct hostent *he;
 	int i, j, uport;
 	unsigned int flags;
@@ -305,14 +305,20 @@
 		q = strtok(NULL, " \t\n\r");
 		if (q == NULL)
 			return -1;
-		he = gethostbyname(q);
-		if (he != NULL) {
+
+		j = inet_addr(q);
+                if (j != -1) {
+                   memcpy(tip, (char *) &j, 4);
+                   thost[0]=0;
+                }else{
+                   he = gethostbyname(q);
+		   if (he != NULL){
 			memcpy(tip, he->h_addr_list[0], 4);
-		} else {	/* maybe user specified a numeric addr? */
-			j = inet_addr(q);
-			if (j == -1)
-				return -5;	/* if -1, bad deal! */
-			memcpy(tip, (char *) &j, 4);
+                        strncpy(thost,q,255);
+                        thost[255]=0;
+                   } else {
+			fprintf(stderr,"ax25ipd: %s host IP address unknown - will probe it again later\n",q);
+		   }
 		}
 
 		while ((q = strtok(NULL, " \t\n\r")) != NULL) {
@@ -336,7 +342,7 @@
 				}
 			}
 		}
-		route_add(tip, tcall, uport, flags);
+		route_add(thost,tip, tcall, uport, flags);
 		return 0;
 
 	} else if (strcmp(p, "broadcast") == 0) {
--- ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-06-14 17:42:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-10-20 19:45:45.959215067 +0200
@@ -15,7 +15,6 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -67,8 +66,7 @@
 struct sockaddr_in from;
 socklen_t fromlen;
 
-time_t last_bc_time;
-
+time_t last_bc_time, last_dns_time;
 int ttyfd_bpq = 0;
 
 /*
@@ -134,6 +132,8 @@
 
 	bzero((char *) &udpbind, sizeof(struct sockaddr));
 	udpbind.sin_family = AF_INET;
+
+        last_dns_time = time(NULL);
 }
 
 /*
@@ -599,8 +599,9 @@
 			perror("reading from raw ip socket");
 			exit(2);
 		} else if (mode == UDP_MODE) {
-			perror("reading from udp socket");
+/*			perror("reading from udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			perror("reading from tty device");
 			exit(2);
@@ -645,8 +646,9 @@
 				usleep(100000);	/* sleep a bit */
 				return 1;	/* and retry */
 			}
-			perror("writing to udp socket");
+/*			perror("writing to udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			if (errno == EWOULDBLOCK) {
 				LOGL4("write to tty would block, sleeping and retrying!\n");
--- ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-06-14 10:07:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-10-20 19:31:34.835219662 +0200
@@ -10,8 +10,11 @@
 #include "ax25ipd.h"
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <sys/socket.h>
+#include <netdb.h> 
 #include <memory.h>
 #include <syslog.h>
+#include <string.h>
 
 /* The routing table structure is not visible outside this module. */
 
@@ -23,6 +26,7 @@
 	unsigned char pad1;
 	unsigned char pad2;
 	unsigned int flags;	/* route flags */
+	unsigned char hostnm[256]; /* host name or null */
 	struct route_table_entry *next;
 };
 
@@ -47,7 +51,7 @@
 }
 
 /* Add a new route entry */
-void route_add(unsigned char *ip, unsigned char *call, int udpport,
+void route_add(unsigned char *host, unsigned char *ip, unsigned char *call, int udpport, 
 	unsigned int flags)
 {
 	struct route_table_entry *rl, *rn;
@@ -75,6 +79,7 @@
 		rn->callsign[i] = call[i] & 0xfe;
 	rn->callsign[6] = (call[6] & 0x1e) | 0x60;
 	rn->padcall = 0;
+	strncpy(rn->hostnm,host,255);
 	memcpy(rn->ip_addr, ip, 4);
 	rn->udp_port = htons(udpport);
 	rn->pad1 = 0;
@@ -242,12 +247,31 @@
 
 	rp = route_tbl;
 	while (rp) {
-		LOGL1("  %s\t%s\t%s\t%d\t%d\n",
+		LOGL1("  %s %s %s %d %d %s\n",
 		      call_to_a(rp->callsign),
 		      (char *) inet_ntoa(*(struct in_addr *) rp->ip_addr),
 		      rp->udp_port ? "udp" : "ip",
-		      ntohs(rp->udp_port), rp->flags);
+		      ntohs(rp->udp_port), rp->flags,
+                      rp->hostnm);
 		rp = rp->next;
 	}
 	fflush(stdout);
 }
+/*update DNS entries of routes */
+void update_dns(void)
+{
+        struct hostent *he;
+	struct route_table_entry *rp;
+	int i;
+
+	rp = route_tbl;
+	while (rp) {
+           if (strlen(rp->hostnm) > 0) {
+              he = gethostbyname(rp->hostnm);
+                if (he != NULL) {
+                        memcpy(rp->ip_addr, he->h_addr_list[0], 4);
+                }
+           }
+	rp = rp->next;
+	}
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ax25ipd : added provision for dynamic dns hosts
  2009-10-23 13:06 ` [PATCH] ax25ipd : added provision for dynamic dns hosts Bernard Pidoux
@ 2009-11-02 17:22   ` Thomas Osterried
  2009-11-03 13:46     ` Pidoux
  2009-11-03 13:33   ` Bernard Pidoux
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Osterried @ 2009-11-02 17:22 UTC (permalink / raw)
  To: Bernard Pidoux; +Cc: linux-hams, Ralf Baechle DL5RB, ax25

Hello Bernard,

On 2009-10-23 15:06:52 +0200, Bernard Pidoux <bernard.pidoux@upmc.fr>
wrote in <4AE1AA6C.9040500@upmc.fr>:
> Hi All,
>
> The following patch 
>
> +/*
> +* added provision for dynamic dns hosts
> +  Steve Fraser vk5asf, June 2005
> +*/
>
> is still not included into "official"  
> http://www.linux-ax25.org/pub/ax25-apps/ax25-apps-0.0.8-rc2.tar.gz

You're right. I admit I was not very happy about the code. I remember I
tried to minimize unnecessary DNS requests, but I did not like my solution
neither.

> despite the fact that it has been used since 2005 by FPAC packet
> switch nodes and that it looks very usefull in maintaining nodes
> connected through ROSE network with dynamic IP changes.
>
> Thus, I resend this patch in the hope that it will be
> added in ax25-apps-0.0.8.

I try to comment my problems with the patch between the lines below.
>
> 73 de Bernard, f6bvp
>
>

> --- ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-06-14 10:11:48.000000000 +0200
> +++ ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-10-20 19:41:41.307206002 +0200
> @@ -25,6 +25,10 @@
>   * Terry Dawson, VK2KTJ, September 2001.
>   */
>  
> +/*
> +* added provision for dynamic dns hosts
> +  Steve Fraser vk5asf, June 2005
> +*/
>  /* Define the current version number
>   *
>   * The first digit represents the major release (0 is a prototype release)
> @@ -133,12 +137,13 @@
>  
>  /* routing.c */
>  void route_init(void);
> -void route_add(unsigned char *, unsigned char *, int, unsigned int);
> +void route_add(unsigned char *, unsigned char *, unsigned char *, int, unsigned int);
>  void bcast_add(unsigned char *);
>  unsigned char *call_to_ip(unsigned char *);
>  int is_call_bcast(unsigned char *);
>  void send_broadcast(unsigned char *, int);
>  void dump_routes(void);
> +void update_dns(void);

update_dns() is never called in this patch.

>  
>  /* config.c */
>  void config_init(void);
> --- ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-06-14 10:07:11.000000000 +0200
> +++ ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-10-20 15:36:29.896354012 +0200
> @@ -154,7 +154,7 @@
>  int parse_line(char *buf)
>  {
>  	char *p, *q;
> -	unsigned char tcall[7], tip[4];
> +	unsigned char tcall[7], tip[4], thost [256];
>  	struct hostent *he;
>  	int i, j, uport;
>  	unsigned int flags;
> @@ -305,14 +305,20 @@
>  		q = strtok(NULL, " \t\n\r");
>  		if (q == NULL)
>  			return -1;
> -		he = gethostbyname(q);
> -		if (he != NULL) {
> +
> +		j = inet_addr(q);
> +                if (j != -1) {
> +                   memcpy(tip, (char *) &j, 4);
> +                   thost[0]=0;
> +                }else{
> +                   he = gethostbyname(q);
> +		   if (he != NULL){
>  			memcpy(tip, he->h_addr_list[0], 4);
> -		} else {	/* maybe user specified a numeric addr? */
> -			j = inet_addr(q);
> -			if (j == -1)
> -				return -5;	/* if -1, bad deal! */
> -			memcpy(tip, (char *) &j, 4);
> +                        strncpy(thost,q,255);
> +                        thost[255]=0;

I'd prefer sizeof() instead of raw values like 255, because it's always
a point of failure.

> +                   } else {
> +			fprintf(stderr,"ax25ipd: %s host IP address unknown - will probe it again later\n",q);

thost has random data. We'll not be able to resolve q (thost) because we did
not store it.

> +		   }
>  		}
>  
>  		while ((q = strtok(NULL, " \t\n\r")) != NULL) {
> @@ -336,7 +342,7 @@
>  				}
>  			}
>  		}
> -		route_add(tip, tcall, uport, flags);
> +		route_add(thost,tip, tcall, uport, flags);
>  		return 0;
>  
>  	} else if (strcmp(p, "broadcast") == 0) {
> --- ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-06-14 17:42:11.000000000 +0200
> +++ ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-10-20 19:45:45.959215067 +0200
> @@ -15,7 +15,6 @@
>  
>  #include <sys/types.h>
>  #include <sys/time.h>
> -#include <time.h>
>  #include <sys/socket.h>
>  #include <netinet/in.h>
>  #include <netinet/in_systm.h>
> @@ -67,8 +66,7 @@
>  struct sockaddr_in from;
>  socklen_t fromlen;
>  
> -time_t last_bc_time;
> -
> +time_t last_bc_time, last_dns_time;
>  int ttyfd_bpq = 0;
>  
>  /*
> @@ -134,6 +132,8 @@
>  
>  	bzero((char *) &udpbind, sizeof(struct sockaddr));
>  	udpbind.sin_family = AF_INET;
> +
> +        last_dns_time = time(NULL);
>  }
>  
>  /*
> @@ -599,8 +599,9 @@
>  			perror("reading from raw ip socket");
>  			exit(2);
>  		} else if (mode == UDP_MODE) {
> -			perror("reading from udp socket");
> +/*			perror("reading from udp socket");
>  			exit(2);
> +*/

why?

>  		} else if (mode == TTY_MODE) {
>  			perror("reading from tty device");
>  			exit(2);
> @@ -645,8 +646,9 @@
>  				usleep(100000);	/* sleep a bit */
>  				return 1;	/* and retry */
>  			}
> -			perror("writing to udp socket");
> +/*			perror("writing to udp socket");
>  			exit(2);
> +*/

why?

>  		} else if (mode == TTY_MODE) {
>  			if (errno == EWOULDBLOCK) {
>  				LOGL4("write to tty would block, sleeping and retrying!\n");
> --- ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-06-14 10:07:11.000000000 +0200
> +++ ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-10-20 19:31:34.835219662 +0200
> @@ -10,8 +10,11 @@
>  #include "ax25ipd.h"
>  #include <sys/types.h>
>  #include <netinet/in.h>
> +#include <sys/socket.h>
> +#include <netdb.h> 
>  #include <memory.h>
>  #include <syslog.h>
> +#include <string.h>
>  
>  /* The routing table structure is not visible outside this module. */
>  
> @@ -23,6 +26,7 @@
>  	unsigned char pad1;
>  	unsigned char pad2;
>  	unsigned int flags;	/* route flags */
> +	unsigned char hostnm[256]; /* host name or null */
>  	struct route_table_entry *next;
>  };
>  
> @@ -47,7 +51,7 @@
>  }
>  
>  /* Add a new route entry */
> -void route_add(unsigned char *ip, unsigned char *call, int udpport,
> +void route_add(unsigned char *host, unsigned char *ip, unsigned char *call, int udpport, 
>  	unsigned int flags)
>  {
>  	struct route_table_entry *rl, *rn;
> @@ -75,6 +79,7 @@
>  		rn->callsign[i] = call[i] & 0xfe;
>  	rn->callsign[6] = (call[6] & 0x1e) | 0x60;
>  	rn->padcall = 0;
> +	strncpy(rn->hostnm,host,255);

In route_add we do rn = malloc(...)
rn->hostnm contains random data.
strncpy(rn->hostnm,host,255) copies 255 bytes to the 256 bytes array hostnm.
If host ist 255 characters long, then it contains a most probably a string
with a hostname and a non-null-character which results in a not-terminated
string.

>  	memcpy(rn->ip_addr, ip, 4);
>  	rn->udp_port = htons(udpport);
>  	rn->pad1 = 0;
> @@ -242,12 +247,31 @@
>  
>  	rp = route_tbl;
>  	while (rp) {
> -		LOGL1("  %s\t%s\t%s\t%d\t%d\n",
> +		LOGL1("  %s %s %s %d %d %s\n",
>  		      call_to_a(rp->callsign),
>  		      (char *) inet_ntoa(*(struct in_addr *) rp->ip_addr),
>  		      rp->udp_port ? "udp" : "ip",
> -		      ntohs(rp->udp_port), rp->flags);
> +		      ntohs(rp->udp_port), rp->flags,
> +                      rp->hostnm);
>  		rp = rp->next;
>  	}
>  	fflush(stdout);
>  }
> +/*update DNS entries of routes */
> +void update_dns(void)
> +{
> +        struct hostent *he;
> +	struct route_table_entry *rp;
> +	int i;
> +
> +	rp = route_tbl;
> +	while (rp) {
> +           if (strlen(rp->hostnm) > 0) {
> +              he = gethostbyname(rp->hostnm);
> +                if (he != NULL) {
> +                        memcpy(rp->ip_addr, he->h_addr_list[0], 4);
> +                }
> +           }
> +	rp = rp->next;
> +	}
> +}

update_dns() is not called in the patch. If it would, on a periodical
basis:
If internet is not available or the dns-server for rp->hostnm is not
available, then we may wait n seconds for dns timeout. In dependence of
how frequently update_dns() is called, ax25ipd gets blocked quite often -
n * m for each host which does not resolve.
rp should store the unsuccessful lookups, do lookups on an an exponential
basis, and in worse cases should do the lookup only i.E. once an hour.
Or even better: do update_dns() in a posix thread.


73,
	- Thomas  dl9sau

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ax25ipd : added provision for dynamic dns hosts
  2009-10-23 13:06 ` [PATCH] ax25ipd : added provision for dynamic dns hosts Bernard Pidoux
  2009-11-02 17:22   ` Thomas Osterried
@ 2009-11-03 13:33   ` Bernard Pidoux
  1 sibling, 0 replies; 6+ messages in thread
From: Bernard Pidoux @ 2009-11-03 13:33 UTC (permalink / raw)
  To: linux-hams; +Cc: Ralf Baechle DL5RB, ax25

[-- Attachment #1: Type: text/plain, Size: 117 bytes --]

In the submitted patch io.c patch was malformed.

Here is a corrected patch for ax25ipd/io.c

73 de Bernard, f6bvp



[-- Attachment #2: ax25ipd-0.0.8-rc2_io.patch --]
[-- Type: text/plain, Size: 1915 bytes --]

--- ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-06-14 17:42:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-11-03 14:03:40.890816311 +0100
@@ -15,7 +15,6 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -67,8 +66,7 @@
 struct sockaddr_in from;
 socklen_t fromlen;
 
-time_t last_bc_time;
-
+time_t last_bc_time, last_dns_time;
 int ttyfd_bpq = 0;
 
 /*
@@ -134,6 +132,8 @@
 
 	bzero((char *) &udpbind, sizeof(struct sockaddr));
 	udpbind.sin_family = AF_INET;
+
+        last_dns_time = time(NULL);
 }
 
 /*
@@ -378,9 +378,19 @@
 		if (nb == 0) {
 			fflush(stdout);
 			fflush(stderr);
+/*                      do we need to check hostname->ip mappings? */
+                        if (time(NULL) > last_dns_time + 300) {
+                           update_dns();
+                           last_dns_time = time(NULL); 
+                        }
 			/* just so we go back to the top of the loop! */
 			continue;
 		}
+/*              just in case we've been too busy......... */
+                if (time(NULL) > last_dns_time + 900) {
+                   update_dns();
+                   last_dns_time = time(NULL); 
+                }
 
 		if (FD_ISSET(ttyfd, &readfds)) {
 			do {
@@ -599,8 +609,9 @@
 			perror("reading from raw ip socket");
 			exit(2);
 		} else if (mode == UDP_MODE) {
-			perror("reading from udp socket");
+/*			perror("reading from udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			perror("reading from tty device");
 			exit(2);
@@ -645,8 +656,9 @@
 				usleep(100000);	/* sleep a bit */
 				return 1;	/* and retry */
 			}
-			perror("writing to udp socket");
+/*			perror("writing to udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			if (errno == EWOULDBLOCK) {
 				LOGL4("write to tty would block, sleeping and retrying!\n");

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ax25ipd : added provision for dynamic dns hosts
  2009-11-02 17:22   ` Thomas Osterried
@ 2009-11-03 13:46     ` Pidoux
  2009-11-06 22:43       ` Bernard Pidoux
  0 siblings, 1 reply; 6+ messages in thread
From: Pidoux @ 2009-11-03 13:46 UTC (permalink / raw)
  To: Thomas Osterried; +Cc: Bernard Pidoux, linux-hams, Ralf Baechle DL5RB, ax25

Hi Thomas,

You are absolutely right.
There was a part of the code missing in io.c patch.
I have just sent a patch including the call to update_dns().

I agree with you about the use of sizeof() instead of a fixed value.

I removed exit() when the progam detects an UDP failure for it aborts
unecessarily ax25ipd daemon.

UDP socket could not be set when remote station is not on line at the time
ax25ipd tries to resolve a dynamic IP address.
This is usually corrected by a later call to update_dns().

73 de Bernard, f6bvp



Thomas Osterried a écrit :
> Hello Bernard,
> 
> On 2009-10-23 15:06:52 +0200, Bernard Pidoux <bernard.pidoux@upmc.fr>
> wrote in <4AE1AA6C.9040500@upmc.fr>:
>> Hi All,
>>
>> The following patch 
>>
>> +/*
>> +* added provision for dynamic dns hosts
>> +  Steve Fraser vk5asf, June 2005
>> +*/
>>
>> is still not included into "official"  
>> http://www.linux-ax25.org/pub/ax25-apps/ax25-apps-0.0.8-rc2.tar.gz
> 
> You're right. I admit I was not very happy about the code. I remember I
> tried to minimize unnecessary DNS requests, but I did not like my solution
> neither.
> 
>> despite the fact that it has been used since 2005 by FPAC packet
>> switch nodes and that it looks very usefull in maintaining nodes
>> connected through ROSE network with dynamic IP changes.
>>
>> Thus, I resend this patch in the hope that it will be
>> added in ax25-apps-0.0.8.
> 
> I try to comment my problems with the patch between the lines below.
>> 73 de Bernard, f6bvp
>>
>>
> 
>> --- ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-06-14 10:11:48.000000000 +0200
>> +++ ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-10-20 19:41:41.307206002 +0200
>> @@ -25,6 +25,10 @@
>>   * Terry Dawson, VK2KTJ, September 2001.
>>   */
>>  
>> +/*
>> +* added provision for dynamic dns hosts
>> +  Steve Fraser vk5asf, June 2005
>> +*/
>>  /* Define the current version number
>>   *
>>   * The first digit represents the major release (0 is a prototype release)
>> @@ -133,12 +137,13 @@
>>  
>>  /* routing.c */
>>  void route_init(void);
>> -void route_add(unsigned char *, unsigned char *, int, unsigned int);
>> +void route_add(unsigned char *, unsigned char *, unsigned char *, int, unsigned int);
>>  void bcast_add(unsigned char *);
>>  unsigned char *call_to_ip(unsigned char *);
>>  int is_call_bcast(unsigned char *);
>>  void send_broadcast(unsigned char *, int);
>>  void dump_routes(void);
>> +void update_dns(void);
> 
> update_dns() is never called in this patch.
> 
>>  
>>  /* config.c */
>>  void config_init(void);
>> --- ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-06-14 10:07:11.000000000 +0200
>> +++ ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-10-20 15:36:29.896354012 +0200
>> @@ -154,7 +154,7 @@
>>  int parse_line(char *buf)
>>  {
>>  	char *p, *q;
>> -	unsigned char tcall[7], tip[4];
>> +	unsigned char tcall[7], tip[4], thost [256];
>>  	struct hostent *he;
>>  	int i, j, uport;
>>  	unsigned int flags;
>> @@ -305,14 +305,20 @@
>>  		q = strtok(NULL, " \t\n\r");
>>  		if (q == NULL)
>>  			return -1;
>> -		he = gethostbyname(q);
>> -		if (he != NULL) {
>> +
>> +		j = inet_addr(q);
>> +                if (j != -1) {
>> +                   memcpy(tip, (char *) &j, 4);
>> +                   thost[0]=0;
>> +                }else{
>> +                   he = gethostbyname(q);
>> +		   if (he != NULL){
>>  			memcpy(tip, he->h_addr_list[0], 4);
>> -		} else {	/* maybe user specified a numeric addr? */
>> -			j = inet_addr(q);
>> -			if (j == -1)
>> -				return -5;	/* if -1, bad deal! */
>> -			memcpy(tip, (char *) &j, 4);
>> +                        strncpy(thost,q,255);
>> +                        thost[255]=0;
> 
> I'd prefer sizeof() instead of raw values like 255, because it's always
> a point of failure.
> 
>> +                   } else {
>> +			fprintf(stderr,"ax25ipd: %s host IP address unknown - will probe it again later\n",q);
> 
> thost has random data. We'll not be able to resolve q (thost) because we did
> not store it.
> 
>> +		   }
>>  		}
>>  
>>  		while ((q = strtok(NULL, " \t\n\r")) != NULL) {
>> @@ -336,7 +342,7 @@
>>  				}
>>  			}
>>  		}
>> -		route_add(tip, tcall, uport, flags);
>> +		route_add(thost,tip, tcall, uport, flags);
>>  		return 0;
>>  
>>  	} else if (strcmp(p, "broadcast") == 0) {
>> --- ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-06-14 17:42:11.000000000 +0200
>> +++ ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-10-20 19:45:45.959215067 +0200
>> @@ -15,7 +15,6 @@
>>  
>>  #include <sys/types.h>
>>  #include <sys/time.h>
>> -#include <time.h>
>>  #include <sys/socket.h>
>>  #include <netinet/in.h>
>>  #include <netinet/in_systm.h>
>> @@ -67,8 +66,7 @@
>>  struct sockaddr_in from;
>>  socklen_t fromlen;
>>  
>> -time_t last_bc_time;
>> -
>> +time_t last_bc_time, last_dns_time;
>>  int ttyfd_bpq = 0;
>>  
>>  /*
>> @@ -134,6 +132,8 @@
>>  
>>  	bzero((char *) &udpbind, sizeof(struct sockaddr));
>>  	udpbind.sin_family = AF_INET;
>> +
>> +        last_dns_time = time(NULL);
>>  }
>>  
>>  /*
>> @@ -599,8 +599,9 @@
>>  			perror("reading from raw ip socket");
>>  			exit(2);
>>  		} else if (mode == UDP_MODE) {
>> -			perror("reading from udp socket");
>> +/*			perror("reading from udp socket");
>>  			exit(2);
>> +*/
> 
> why?
> 
>>  		} else if (mode == TTY_MODE) {
>>  			perror("reading from tty device");
>>  			exit(2);
>> @@ -645,8 +646,9 @@
>>  				usleep(100000);	/* sleep a bit */
>>  				return 1;	/* and retry */
>>  			}
>> -			perror("writing to udp socket");
>> +/*			perror("writing to udp socket");
>>  			exit(2);
>> +*/
> 
> why?
> 
>>  		} else if (mode == TTY_MODE) {
>>  			if (errno == EWOULDBLOCK) {
>>  				LOGL4("write to tty would block, sleeping and retrying!\n");
>> --- ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-06-14 10:07:11.000000000 +0200
>> +++ ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-10-20 19:31:34.835219662 +0200
>> @@ -10,8 +10,11 @@
>>  #include "ax25ipd.h"
>>  #include <sys/types.h>
>>  #include <netinet/in.h>
>> +#include <sys/socket.h>
>> +#include <netdb.h> 
>>  #include <memory.h>
>>  #include <syslog.h>
>> +#include <string.h>
>>  
>>  /* The routing table structure is not visible outside this module. */
>>  
>> @@ -23,6 +26,7 @@
>>  	unsigned char pad1;
>>  	unsigned char pad2;
>>  	unsigned int flags;	/* route flags */
>> +	unsigned char hostnm[256]; /* host name or null */
>>  	struct route_table_entry *next;
>>  };
>>  
>> @@ -47,7 +51,7 @@
>>  }
>>  
>>  /* Add a new route entry */
>> -void route_add(unsigned char *ip, unsigned char *call, int udpport,
>> +void route_add(unsigned char *host, unsigned char *ip, unsigned char *call, int udpport, 
>>  	unsigned int flags)
>>  {
>>  	struct route_table_entry *rl, *rn;
>> @@ -75,6 +79,7 @@
>>  		rn->callsign[i] = call[i] & 0xfe;
>>  	rn->callsign[6] = (call[6] & 0x1e) | 0x60;
>>  	rn->padcall = 0;
>> +	strncpy(rn->hostnm,host,255);
> 
> In route_add we do rn = malloc(...)
> rn->hostnm contains random data.
> strncpy(rn->hostnm,host,255) copies 255 bytes to the 256 bytes array hostnm.
> If host ist 255 characters long, then it contains a most probably a string
> with a hostname and a non-null-character which results in a not-terminated
> string.
> 
>>  	memcpy(rn->ip_addr, ip, 4);
>>  	rn->udp_port = htons(udpport);
>>  	rn->pad1 = 0;
>> @@ -242,12 +247,31 @@
>>  
>>  	rp = route_tbl;
>>  	while (rp) {
>> -		LOGL1("  %s\t%s\t%s\t%d\t%d\n",
>> +		LOGL1("  %s %s %s %d %d %s\n",
>>  		      call_to_a(rp->callsign),
>>  		      (char *) inet_ntoa(*(struct in_addr *) rp->ip_addr),
>>  		      rp->udp_port ? "udp" : "ip",
>> -		      ntohs(rp->udp_port), rp->flags);
>> +		      ntohs(rp->udp_port), rp->flags,
>> +                      rp->hostnm);
>>  		rp = rp->next;
>>  	}
>>  	fflush(stdout);
>>  }
>> +/*update DNS entries of routes */
>> +void update_dns(void)
>> +{
>> +        struct hostent *he;
>> +	struct route_table_entry *rp;
>> +	int i;
>> +
>> +	rp = route_tbl;
>> +	while (rp) {
>> +           if (strlen(rp->hostnm) > 0) {
>> +              he = gethostbyname(rp->hostnm);
>> +                if (he != NULL) {
>> +                        memcpy(rp->ip_addr, he->h_addr_list[0], 4);
>> +                }
>> +           }
>> +	rp = rp->next;
>> +	}
>> +}
> 
> update_dns() is not called in the patch. If it would, on a periodical
> basis:
> If internet is not available or the dns-server for rp->hostnm is not
> available, then we may wait n seconds for dns timeout. In dependence of
> how frequently update_dns() is called, ax25ipd gets blocked quite often -
> n * m for each host which does not resolve.
> rp should store the unsuccessful lookups, do lookups on an an exponential
> basis, and in worse cases should do the lookup only i.E. once an hour.
> Or even better: do update_dns() in a posix thread.
> 
> 
> 73,
> 	- Thomas  dl9sau
> 



--
To unsubscribe from this list: send the line "unsubscribe linux-hams" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ax25ipd : added provision for dynamic dns hosts
  2009-11-03 13:46     ` Pidoux
@ 2009-11-06 22:43       ` Bernard Pidoux
  0 siblings, 0 replies; 6+ messages in thread
From: Bernard Pidoux @ 2009-11-06 22:43 UTC (permalink / raw)
  To: Thomas Osterried; +Cc: linux-hams, Ralf Baechle DL5RB, ax25

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

Hi All,

I resend the complete ax25ipd patch, taking into account Thomas remarks
about fixed array values.
However sizeof() was not appropriate and I put strnlen() instead. 

73 de Bernard, f6bvp



Pidoux wrote :
> Hi Thomas,
> 
> You are absolutely right.
> There was a part of the code missing in io.c patch.
> I have just sent a patch including the call to update_dns().
> 
> I agree with you about the use of sizeof() instead of a fixed value.
> 
> I removed exit() when the progam detects an UDP failure for it aborts
> unecessarily ax25ipd daemon.
> 
> UDP socket could not be set when remote station is not on line at the time
> ax25ipd tries to resolve a dynamic IP address.
> This is usually corrected by a later call to update_dns().
> 
> 73 de Bernard, f6bvp
> 
> 
> 
> Thomas Osterried wrote :
>> Hello Bernard,
>>
>> On 2009-10-23 15:06:52 +0200, Bernard Pidoux <bernard.pidoux@upmc.fr>
>> wrote in <4AE1AA6C.9040500@upmc.fr>:
...
>>
>> You're right. I admit I was not very happy about the code. I remember I
>> tried to minimize unnecessary DNS requests, but I did not like my 
>> solution
>> neither.
>>


 

[-- Attachment #2: ax25ipd-0.0.8-rc2.new.patch --]
[-- Type: text/plain, Size: 7043 bytes --]

diff -ruN ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h ax25-apps-0.0.8-rc2-new/ax25ipd/ax25ipd.h
--- ax25-apps-0.0.8-rc2/ax25ipd/ax25ipd.h	2009-06-14 10:11:48.000000000 +0200
+++ ax25-apps-0.0.8-rc2-new/ax25ipd/ax25ipd.h	2009-11-03 15:31:33.178816102 +0100
@@ -25,6 +25,10 @@
  * Terry Dawson, VK2KTJ, September 2001.
  */
 
+/*
+* added provision for dynamic dns hosts
+  Steve Fraser vk5asf, June 2005
+*/
 /* Define the current version number
  *
  * The first digit represents the major release (0 is a prototype release)
@@ -133,12 +137,13 @@
 
 /* routing.c */
 void route_init(void);
-void route_add(unsigned char *, unsigned char *, int, unsigned int);
+void route_add(unsigned char *, unsigned char *, unsigned char *, int, unsigned int);
 void bcast_add(unsigned char *);
 unsigned char *call_to_ip(unsigned char *);
 int is_call_bcast(unsigned char *);
 void send_broadcast(unsigned char *, int);
 void dump_routes(void);
+void update_dns(void);
 
 /* config.c */
 void config_init(void);
diff -ruN ax25-apps-0.0.8-rc2/ax25ipd/config.c ax25-apps-0.0.8-rc2-new/ax25ipd/config.c
--- ax25-apps-0.0.8-rc2/ax25ipd/config.c	2009-06-14 10:07:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2-new/ax25ipd/config.c	2009-11-06 23:28:00.062795762 +0100
@@ -154,7 +154,7 @@
 int parse_line(char *buf)
 {
 	char *p, *q;
-	unsigned char tcall[7], tip[4];
+	unsigned char tcall[7], tip[4], thost [256];
 	struct hostent *he;
 	int i, j, uport;
 	unsigned int flags;
@@ -212,8 +212,7 @@
 		q = strtok(NULL, " \t\n\r");
 		if (q == NULL)
 			return -1;
-		strncpy(ttydevice, q, sizeof(ttydevice)-1);
-		ttydevice[sizeof(ttydevice)-1] = 0;
+		strcpy(ttydevice, q);
 		return 0;
 
 	} else if (strcmp(p, "mode") == 0) {
@@ -280,8 +279,7 @@
 		if (strlen(q) > sizeof(bc_text))
 			return -7;
 		q[strlen(q) - 1] = '\0';
-		strncpy(bc_text, q, sizeof(bc_text)-1);
-		bc_text[sizeof(bc_text)-1] = 0;
+		strcpy(bc_text, q);
 		return 0;
 
 	} else if (strcmp(p, "loglevel") == 0) {
@@ -305,14 +303,20 @@
 		q = strtok(NULL, " \t\n\r");
 		if (q == NULL)
 			return -1;
-		he = gethostbyname(q);
-		if (he != NULL) {
+
+		j = inet_addr(q);
+                if (j != -1) {
+                   memcpy(tip, (char *) &j, 4);
+                   thost[0]=0;
+                } else {
+                   he = gethostbyname(q);
+		   if (he != NULL){
 			memcpy(tip, he->h_addr_list[0], 4);
-		} else {	/* maybe user specified a numeric addr? */
-			j = inet_addr(q);
-			if (j == -1)
-				return -5;	/* if -1, bad deal! */
-			memcpy(tip, (char *) &j, 4);
+                        strncpy(thost, q, strlen(q));
+                        thost[strlen(q)] = 0;
+		   } else {
+			fprintf(stderr,"ax25ipd: %s host IP address unknown - will probe it again later\n",q);
+		   }
 		}
 
 		while ((q = strtok(NULL, " \t\n\r")) != NULL) {
@@ -336,7 +340,7 @@
 				}
 			}
 		}
-		route_add(tip, tcall, uport, flags);
+		route_add(thost,tip, tcall, uport, flags);
 		return 0;
 
 	} else if (strcmp(p, "broadcast") == 0) {
diff -ruN ax25-apps-0.0.8-rc2/ax25ipd/io.c ax25-apps-0.0.8-rc2-new/ax25ipd/io.c
--- ax25-apps-0.0.8-rc2/ax25ipd/io.c	2009-06-14 17:42:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2-new/ax25ipd/io.c	2009-11-03 15:31:33.178816102 +0100
@@ -15,7 +15,6 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
-#include <time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -67,8 +66,7 @@
 struct sockaddr_in from;
 socklen_t fromlen;
 
-time_t last_bc_time;
-
+time_t last_bc_time, last_dns_time;
 int ttyfd_bpq = 0;
 
 /*
@@ -134,6 +132,8 @@
 
 	bzero((char *) &udpbind, sizeof(struct sockaddr));
 	udpbind.sin_family = AF_INET;
+
+        last_dns_time = time(NULL);
 }
 
 /*
@@ -378,9 +378,19 @@
 		if (nb == 0) {
 			fflush(stdout);
 			fflush(stderr);
+/*                      do we need to check hostname->ip mappings? */
+                        if (time(NULL) > last_dns_time + 300) {
+                           update_dns();
+                           last_dns_time = time(NULL); 
+                        }
 			/* just so we go back to the top of the loop! */
 			continue;
 		}
+/*              just in case we've been too busy......... */
+                if (time(NULL) > last_dns_time + 900) {
+                   update_dns();
+                   last_dns_time = time(NULL); 
+                }
 
 		if (FD_ISSET(ttyfd, &readfds)) {
 			do {
@@ -599,8 +609,9 @@
 			perror("reading from raw ip socket");
 			exit(2);
 		} else if (mode == UDP_MODE) {
-			perror("reading from udp socket");
+/*			perror("reading from udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			perror("reading from tty device");
 			exit(2);
@@ -645,8 +656,9 @@
 				usleep(100000);	/* sleep a bit */
 				return 1;	/* and retry */
 			}
-			perror("writing to udp socket");
+/*			perror("writing to udp socket");
 			exit(2);
+*/
 		} else if (mode == TTY_MODE) {
 			if (errno == EWOULDBLOCK) {
 				LOGL4("write to tty would block, sleeping and retrying!\n");
diff -ruN ax25-apps-0.0.8-rc2/ax25ipd/routing.c ax25-apps-0.0.8-rc2-new/ax25ipd/routing.c
--- ax25-apps-0.0.8-rc2/ax25ipd/routing.c	2009-06-14 10:07:11.000000000 +0200
+++ ax25-apps-0.0.8-rc2-new/ax25ipd/routing.c	2009-11-06 23:28:53.082799117 +0100
@@ -10,8 +10,11 @@
 #include "ax25ipd.h"
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <sys/socket.h>
+#include <netdb.h> 
 #include <memory.h>
 #include <syslog.h>
+#include <string.h>
 
 /* The routing table structure is not visible outside this module. */
 
@@ -23,6 +26,7 @@
 	unsigned char pad1;
 	unsigned char pad2;
 	unsigned int flags;	/* route flags */
+	unsigned char hostnm[256]; /* host name or null */
 	struct route_table_entry *next;
 };
 
@@ -47,7 +51,7 @@
 }
 
 /* Add a new route entry */
-void route_add(unsigned char *ip, unsigned char *call, int udpport,
+void route_add(unsigned char *host, unsigned char *ip, unsigned char *call, int udpport, 
 	unsigned int flags)
 {
 	struct route_table_entry *rl, *rn;
@@ -75,6 +79,7 @@
 		rn->callsign[i] = call[i] & 0xfe;
 	rn->callsign[6] = (call[6] & 0x1e) | 0x60;
 	rn->padcall = 0;
+	strncpy(rn->hostnm, host, strlen(host));
 	memcpy(rn->ip_addr, ip, 4);
 	rn->udp_port = htons(udpport);
 	rn->pad1 = 0;
@@ -242,12 +247,30 @@
 
 	rp = route_tbl;
 	while (rp) {
-		LOGL1("  %s\t%s\t%s\t%d\t%d\n",
+		LOGL1("  %s %s %s %d %d %s\n",
 		      call_to_a(rp->callsign),
 		      (char *) inet_ntoa(*(struct in_addr *) rp->ip_addr),
 		      rp->udp_port ? "udp" : "ip",
-		      ntohs(rp->udp_port), rp->flags);
+		      ntohs(rp->udp_port), rp->flags,
+                      rp->hostnm);
 		rp = rp->next;
 	}
 	fflush(stdout);
 }
+/*update DNS entries of routes */
+void update_dns(void)
+{
+        struct hostent *he;
+	struct route_table_entry *rp;
+
+	rp = route_tbl;
+	while (rp) {
+           if (strlen(rp->hostnm) > 0) {
+              he = gethostbyname(rp->hostnm);
+                if (he != NULL) {
+                        memcpy(rp->ip_addr, he->h_addr_list[0], 4);
+                }
+           }
+	rp = rp->next;
+	}
+}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-06 22:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-26 17:31 ax25-apps/-tools: clarification about the project status IT2 Stuart Blake Tener, USNR
2009-10-23 13:06 ` [PATCH] ax25ipd : added provision for dynamic dns hosts Bernard Pidoux
2009-11-02 17:22   ` Thomas Osterried
2009-11-03 13:46     ` Pidoux
2009-11-06 22:43       ` Bernard Pidoux
2009-11-03 13:33   ` Bernard Pidoux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox