Update DDNS with RouterTech 2.94

All about firmwares for routers. Support for RouterTech firmwares is here too.
User avatar
thechief
RouterTech Team
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

Post by thechief » Mon Dec 06, 2010 9:46 am

TafnaSM wrote:
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.
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.
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).
The Chief: :afro: 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.
mstombs
RouterTech Team
RouterTech Team
Posts: 3753
Joined: Wed Jan 10, 2007 11:54 pm

Re: Update DDNS with RouterTech 2.94

Post by mstombs » Mon Dec 06, 2010 8:56 pm

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"

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);
}
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?
User avatar
thechief
RouterTech Team
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

Post by thechief » Mon Dec 06, 2010 11:38 pm

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: :afro: 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.
User avatar
thechief
RouterTech Team
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

Post by thechief » Tue Dec 07, 2010 12:43 am

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: :afro: 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.
User avatar
TafnaSM
Regular
Regular
Posts: 40
Joined: Sat Apr 10, 2010 4:16 pm
Location: Cairns, QLD, Australia

Re: Update DDNS with RouterTech 2.94

Post by TafnaSM » Tue Dec 07, 2010 12:43 am

mstombs wrote:Its pretty 'expensive' to lookup a hostname using {ping, grep, sed, sed} but I've seen other similar functions using traceroute and awk.
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.
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?
You mean nslookup?

MfG Stefan Froehlich
42 ;-)
User avatar
TafnaSM
Regular
Regular
Posts: 40
Joined: Sat Apr 10, 2010 4:16 pm
Location: Cairns, QLD, Australia

Re: Update DDNS with RouterTech 2.94

Post by TafnaSM » Tue Dec 07, 2010 12:50 am

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.
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?

MfG Stefan Froehlich
42 ;-)
User avatar
thechief
RouterTech Team
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

Post by thechief » Tue Dec 07, 2010 1:03 am

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: :afro: 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.
mstombs
RouterTech Team
RouterTech Team
Posts: 3753
Joined: Wed Jan 10, 2007 11:54 pm

Re: Update DDNS with RouterTech 2.94

Post by mstombs » Tue Dec 07, 2010 10:12 am

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.
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.
You mean nslookup?
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.
User avatar
thechief
RouterTech Team
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

Post by thechief » Tue Dec 07, 2010 11:00 am

mstombs wrote:The script function will be the smallest No of bytes as a script function.
Indeed. But I think we can cope with the 512 bytes that a stand-alone ipaddr adds to the toolbox binary. :)
The Chief: :afro: 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.
Post Reply