Quick thinking! It is there. I will have a look at whether it can easily be retrieved (not everything in the config is readily retrievable by "cm_cli_ex" - which is the only way to manipulate output from the config).TafnaSM wrote:That is good. But isn't it possible to retrieve it from the router's configuration area instead of defining an other environment variable? It must be already there.thechief wrote:This allows you to specify the host in an environment variable ("myddns_host"), dispensing with the need to provide a command-line argument.
Update DDNS with RouterTech 2.94
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Update DDNS with RouterTech 2.94
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
Re: Update DDNS with RouterTech 2.94
Its pretty 'expensive' to lookup a hostname using {ping, grep, sed, sed} but I've seen other similar functions using traceroute and awk.
Its really easy to lookup an ipaddress from a hostname in c with library calls - I wrote this a while ago "ipaddr.c"
As a standalone binary it will take 5-10k, but there's already a similar function inside BusyBox ... or is there another binary it could be added to?
Its really easy to lookup an ipaddress from a hostname in c with library calls - I wrote this a while ago "ipaddr.c"
Code: Select all
#include <netdb.h>
#include <stdio.h>
#include <arpa/inet.h>
int main(int argc, char **argv) {
if (argc < 2) {
printf ("Usage: %s hostname\n", argv[0]);
return (-1);
}
struct hostent *hp = gethostbyname (argv[1]);
if (hp == NULL) {
printf("\n");
return (-1);
}
printf( "%s\n", inet_ntoa ( *(struct in_addr*)hp->h_addr) );
return (0);
}
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Update DDNS with RouterTech 2.94
It compiles to 3k here, which is small enough. There is, as you say, a similar busybox applet. At the moment, busybox is not compiling with that enabled. I'll see how it goes, but might use this stand-alone version instead.
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Update DDNS with RouterTech 2.94
Busybox gets too big (an extra 40kb). But when the standalone source is added to our "toolbox" binary, it only grows by about 512 bytes, so that will be the route.
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
Re: Update DDNS with RouterTech 2.94
It is fast enough for the intended purpose. With no other tools available (nslookup or dig...) that was the simpliest solution for me. Because themstombs wrote:Its pretty 'expensive' to lookup a hostname using {ping, grep, sed, sed} but I've seen other similar functions using traceroute and awk.
w=$(WaitForSync 10 24 1)
is slow there was no reason to make that resolve fast.
You mean nslookup?mstombs wrote:As a standalone binary it will take 5-10k, but there's already a similar function inside BusyBox ... or is there another binary it could be added to?
MfG Stefan Froehlich
42
Re: Update DDNS with RouterTech 2.94
Isn't it possible to enable the nslookup command in busybox? This is a standard command and is in my opinion the best way to do this. Or is that the option that prevents busybox from compiling?thechief wrote:Busybox gets too big (an extra 40kb). But when the standalone source is added to our "toolbox" binary, it only grows by about 512 bytes, so that will be the route.
MfG Stefan Froehlich
42
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Update DDNS with RouterTech 2.94
The problem was the ipaddr applet in busybox - but it was easy to fix. However, it (and all the other stuff that it requires) added 40kb to the size of busybox (actually I managed to trim it down to 20kb, but that is still too much). nslookup adds 1kb, but gives output that needs to be parsed. So, for present purposes, the standalone ipaddr sources posted above seems like the best bet.
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
Re: Update DDNS with RouterTech 2.94
Agreed - no criticism, just reminded me that I'd come across the dns lookup from script problem before, lots of functions must use the same library lookup - i.e. the first ping - but they don't expose the result in a simple way to scripts. Only going to be an issue inside a loop - should someone need to validate a long list of hostnames for example. The script function will be the smallest No of bytes as a script function.TafnaSM wrote:It is fast enough for the intended purpose. With no other tools available (nslookup or dig...) that was the simpliest solution for me. Because the
w=$(WaitForSync 10 24 1)
is slow there was no reason to make that resolve fast.
I actually meant the c subroutine to do the lookup, nslookup or ipcalc are still verbose, xgethostbyname (?) - in line with other Linux OS tools there isn't a simple script accessible interface.You mean nslookup?
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Re: Update DDNS with RouterTech 2.94
Indeed. But I think we can cope with the 512 bytes that a stand-alone ipaddr adds to the toolbox binary.mstombs wrote:The script function will be the smallest No of bytes as a script function.
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.