EmuProxyZA / tdnsip.c
From TivoZA
Back to emuProxyZA.
Download source (You will need to rename it to: tdnsip.c)
To update the below source file, select Upload file and upload your new tdnsip.c file (there is no need to upload it as a .txt). If you do upload a new version, please add a brief description to the change log at the bottom of this page indicating what changes you made and why.
[edit]
Source
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> #include "tivodns.h" #define RESOLVCONF_FILE "./resolv.conf" char nameserver[] = "nameserver 192.168.1.1\n"; int main( int argc, char **argv ) { struct in_addr *result; char *hostname; int fd; int b; int lookup = 1; if ( argc < 2 ) { fprintf( stderr, "usage: %s -f /tmp/resolv.conf <hostname|ipAddress>\n", argv[ 0 ] ); return 2; } if ( strcmp( argv[ 1 ], "-f" ) != 0 ) { fd = open( RESOLVCONF_FILE, O_WRONLY | O_CREAT, 0666 ); if ( fd < 0 ) { perror( "open resolv.conf" ); exit( 1 ); } write( fd, nameserver, sizeof( nameserver ) ); close( fd ); tivodns_init( RESOLVCONF_FILE ); } else { lookup = 3; fd = open( argv[ 2 ], O_RDONLY ); if ( fd < 0 ) { perror( "open resolv.conf" ); exit( 1 ); } tivodns_init( argv[ 2 ] ); } if ( sscanf( argv[ lookup ], "%d.%d.%d.%d", &b, &b, &b, &b ) == 4 ) { // printf( "Reverse\n" ); result = tivodns_aton4( argv[ lookup ] ); hostname = tivodns_resolvename4( result ); if ( hostname ) { return 0; } } else { // printf( "Forward\n" ); result = tivodns_resolveip4( argv[ lookup ] ); if (result) { return 0; } } return 1; }
[edit]
Change Log
13 Oct 2005 - TivoZA: Uploaded the file


