The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
ntkresolv.h File Reference
#include <errno.h>
#include <netdb.h>
#include <strings.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include "andns_lib.h"
Include dependency graph for ntkresolv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ntkresolv_opts
 

Macros

#define VERSION   "0.3.3"
 
#define NTK_RESOLV_MAIL_BUGS   "https://github.com/Netsukuku/netsukuku/issues"
 
#define NTKRESOLV_PORT   53
 
#define NTKRESOLV_PORT_STR   "53"
 
#define MAX_NS   3
 
#define LOCALHOST   "localhost"
 
#define NTK_RESOLV_TIMEOUT   15
 
#define MAX_HOSTNAME_LEN   512
 
#define NTKRESOLV_MAX_OBJ_LEN   512
 
#define min(x, y)   (x)<(y)?(x):(y)
 
#define REALM_NTK   0+1
 
#define REALM_INT   1+1
 
#define REALM_NTK_STR   "ntk"
 
#define REALM_INT_STR   "inet"
 
#define QTYPE_A   AT_A
 
#define QTYPE_PTR   AT_PTR
 
#define QTYPE_G   AT_G
 
#define QTYPE_MX   3
 
#define QTYPE_A_STR   "snsd"
 
#define QTYPE_PTR_STR   "ptr"
 
#define QTYPE_G_STR   "global"
 
#define QTYPE_MX_STR   "mx"
 
#define SNSD_PROTO_TCP   0
 
#define SNSD_PROTO_UDP   1
 
#define SNSD_PROTO_TCP_STR   "tcp"
 
#define SNSD_PROTO_UDP_STR   "udp"
 
#define SNSD_PROTO_DEFAULT   SNSD_PROTO_TCP
 
#define SNSD_SERVICE_DEFAULT   0
 
#define NK_DNS   0
 
#define NK_NTK   1
 
#define NK_INET   2
 
#define TIME_SCALE   1000000.0
 
#define HELP_STR   "help"
 
#define QTFROMPREF(s)
 
#define REALMFROMPREF(s)
 
#define PROTOFROMPREF(s)
 
#define NTKRESOLV_OPTS_SZ   sizeof(ntkresolv_opts)
 
#define QR_STR(ap)   ((ap)->qr==0)?"QUERY":"ANSWER"
 
#define QTYPE_STR(ap)
 
#define NK_STR(ap)
 
#define RCODE_STR(ap)
 
#define IPV_STR(ap)
 
#define MAX_INT_STR   10
 
#define SERVICE_STR(ap)
 
#define PROTO_STR(ap)
 
#define GET_OPT_REALM   (globopts.realm==REALM_NTK)?"NTK":"INET"
 
#define GOP   (globopts)
 
#define AMISILENT   (GOP.silent)
 
#define GQT   (GOP.q)
 
#define say   printf
 
#define bye   if (!AMISILENT) say("\tBye!\n");
 
#define COMPUTE_TIME   diff_time(time_start,time_stop)
 
#define time_report
 
#define G_ALIGN(len)
 
#define G_SETQST_A(s)
 
#define NTK_RESOLV_HASH_STR(s, d)
 
#define NTK_RESOLV_STR_HASH(s, d)
 
#define NTK_RESOLV_IP_SYMBOL   "~"
 
#define NTK_RESOLV_HNAME_SYMBOL   "-"
 
#define NTK_RESOLV_SYMBOL(apd)
 

Typedefs

typedef struct ntkresolv_opts ntkresolv_opts
 

Functions

void version (void)
 
void usage (void)
 
void qt_usage (char *arg)
 
void realm_usage (char *arg)
 
void proto_usage (char *arg)
 
void service_and_proto_usage (char *arg)
 
double diff_time (struct timeval a, struct timeval b)
 
void opts_init (void)
 
void opts_set_silent (void)
 
void opts_set_port (char *arg)
 
void opts_set_ns (char *arg)
 
void opts_set_qt (char *arg)
 
void opts_set_realm (char *arg)
 
void opts_set_service_and_proto (char *arg)
 
void opts_set_proto (char *arg)
 
void opts_set_recursion (void)
 
void opts_set_hash (void)
 
void opts_set_compute_hash (void)
 
void opts_set_parsable_output (void)
 
void opts_set_question (char *arg)
 
void opts_finish (char *arg)
 
void print_headers ()
 
void print_question ()
 
void ip_bin_to_str (void *data, char *dst)
 
void answer_data_to_str (andns_pkt_data *apd, char *dst)
 
void print_answers ()
 
void print_parsable_answers (void)
 
void print_results (void)
 
void do_command (void)
 
void ntkresolv_exit (int i)
 
void ntkresolv_safe_exit (int i)
 
int main (int argc, char **argv)
 

Variables

char * QTYPE_STR_LIST [] ={ "snsd" , "ptr" , "global" , "mx" }
 
int QT_LEN =4
 

Macro Definition Documentation

#define AMISILENT   (GOP.silent)
#define bye   if (!AMISILENT) say("\tBye!\n");
#define COMPUTE_TIME   diff_time(time_start,time_stop)
#define G_ALIGN (   len)
Value:
GQT->qstlength=len;GQT->qstdata=(char*) \
xmalloc(len+1); \
if (!GQT->qstdata){say("Fatal malloc!\n"); \
exit(1);}
#define say
Definition: ntkresolv.h:237
void * xmalloc(size_t size)
Definition: xmalloc.c:44
#define GQT
Definition: ntkresolv.h:235
#define G_SETQST_A (   s)
Value:
G_ALIGN(strlen(s)+1);strcpy(GQT->qstdata,s); \
GQT->qstlength=strlen(s);
#define GQT
Definition: ntkresolv.h:235
#define G_ALIGN(len)
Definition: ntkresolv.h:245
#define GET_OPT_REALM   (globopts.realm==REALM_NTK)?"NTK":"INET"
#define GOP   (globopts)
#define GQT   (GOP.q)
#define HELP_STR   "help"
#define IPV_STR (   ap)
Value:
({ \
char *__f; \
switch((ap)->ipv) { \
case ANDNS_IPV4: \
__f="IPv4"; \
break; \
case ANDNS_IPV6: \
__f="IPv6"; \
break; \
default: \
__f="UNKNOW"; \
break; \
} \
__f;})
#define ANDNS_IPV6
Definition: andns_lib.h:114
#define ANDNS_IPV4
Definition: andns_lib.h:113
#define LOCALHOST   "localhost"
#define MAX_HOSTNAME_LEN   512
#define MAX_INT_STR   10
#define MAX_NS   3
#define min (   x,
 
)    (x)<(y)?(x):(y)
#define NK_DNS   0
#define NK_INET   2
#define NK_NTK   1
#define NK_STR (   ap)
Value:
({ \
char *__d; \
switch((ap)->nk) { \
case NK_DNS: \
__d="DNS"; \
break; \
case NK_NTK: \
__d="Ntk"; \
break; \
case NK_INET: \
__d="Inet"; \
break; \
default: \
__d="UNKNOW"; \
break; \
} \
__d;})
#define NK_DNS
Definition: ntkresolv.h:53
#define NK_NTK
Definition: ntkresolv.h:54
#define NK_INET
Definition: ntkresolv.h:55
#define NTK_RESOLV_HASH_STR (   s,
 
)
Value:
({ \
int __i; \
for (__i=0;__i<ANDNS_HASH_H;__i++) \
sprintf(d+2*__i,"%02x",((unsigned char*)(s))[__i]); \
d[2*ANDNS_HASH_H]=0;})
#define ANDNS_HASH_H
Definition: andns_lib.h:40
#define NTK_RESOLV_HNAME_SYMBOL   "-"
#define NTK_RESOLV_IP_SYMBOL   "~"
#define NTK_RESOLV_MAIL_BUGS   "https://github.com/Netsukuku/netsukuku/issues"
#define NTK_RESOLV_STR_HASH (   s,
 
)
Value:
({ \
int __i,__t; \
for (__i=0;__i<ANDNS_HASH_H;__i++) { \
sscanf(s+2*__i,"%02x",&__t); \
d[__i]=(unsigned char)(__t);}})
#define ANDNS_HASH_H
Definition: andns_lib.h:40
#define NTK_RESOLV_SYMBOL (   apd)
Value:
#define APD_IP
Definition: andns_lib.h:60
#define NTK_RESOLV_HNAME_SYMBOL
Definition: ntkresolv.h:267
#define NTK_RESOLV_IP_SYMBOL
Definition: ntkresolv.h:266
#define NTK_RESOLV_TIMEOUT   15
#define NTKRESOLV_MAX_OBJ_LEN   512
#define NTKRESOLV_OPTS_SZ   sizeof(ntkresolv_opts)
#define NTKRESOLV_PORT   53
#define NTKRESOLV_PORT_STR   "53"
#define PROTO_STR (   ap)
Value:
({ \
char *__h; \
switch((ap)->qtype) { \
case AT_G: \
__h="*"; \
break; \
case AT_PTR: \
__h="None"; \
break; \
case AT_A: \
if (!ap->service) \
__h="None"; \
else \
__h=ap->p==SNSD_PROTO_TCP? \
break; \
default: \
__h="UNKNOW"; \
break; \
} \
__h;})
#define AT_G
Definition: andns_lib.h:101
#define SNSD_PROTO_UDP_STR
Definition: ntkresolv.h:47
#define SNSD_PROTO_TCP
Definition: ntkresolv.h:44
#define AT_PTR
Definition: andns_lib.h:100
#define AT_A
Definition: andns_lib.h:99
#define SNSD_PROTO_TCP_STR
Definition: ntkresolv.h:46
#define PROTOFROMPREF (   s)
Value:
({ \
uint8_t __res=-1; \
if (!strncasecmp(SNSD_PROTO_UDP_STR,s,strlen(s))) \
__res=SNSD_PROTO_UDP; \
else if (!strncasecmp(SNSD_PROTO_TCP_STR,s,strlen(s))) \
__res=SNSD_PROTO_TCP; \
__res; })
#define SNSD_PROTO_UDP_STR
Definition: ntkresolv.h:47
#define SNSD_PROTO_TCP
Definition: ntkresolv.h:44
#define SNSD_PROTO_UDP
Definition: ntkresolv.h:45
#define SNSD_PROTO_TCP_STR
Definition: ntkresolv.h:46
#define QR_STR (   ap)    ((ap)->qr==0)?"QUERY":"ANSWER"
#define QTFROMPREF (   s)
Value:
({ \
int __n,__res=-1; \
for (__n=0;__n<QT_LEN;__n++) \
if (!strncasecmp(s,QTYPE_STR_LIST[__n],strlen(s))) \
{__res=__n;break;} \
__res; })
char * QTYPE_STR_LIST[]
Definition: ntkresolv.h:62
int QT_LEN
Definition: ntkresolv.h:63
#define QTYPE_A   AT_A
#define QTYPE_A_STR   "snsd"
#define QTYPE_G   AT_G
#define QTYPE_G_STR   "global"
#define QTYPE_MX   3
#define QTYPE_MX_STR   "mx"
#define QTYPE_PTR   AT_PTR
#define QTYPE_PTR_STR   "ptr"
#define QTYPE_STR (   ap)
Value:
({ \
char *__c; \
switch((ap)->qtype) { \
case AT_A: \
__c="Host2Ip"; \
break; \
case AT_PTR: \
__c="Ip2Host"; \
break; \
case AT_G: \
__c=" Global"; \
break; \
default: \
__c="Unknow"; \
break; \
} \
__c;})
#define AT_G
Definition: andns_lib.h:101
#define AT_PTR
Definition: andns_lib.h:100
#define AT_A
Definition: andns_lib.h:99
#define RCODE_STR (   ap)
Value:
({ \
char *__e; \
switch((ap)->rcode) { \
__e="NoError"; \
break; \
__e="InError"; \
break; \
__e="SrvFail"; \
break; \
__e="NoXHost"; \
break; \
__e="NotImpl"; \
break; \
__e="Refused"; \
break; \
default: \
__e="UNKNOW"; \
break; \
} \
__e;})
#define ANDNS_RCODE_ENIMPL
Definition: andns_lib.h:107
#define ANDNS_RCODE_NOERR
Definition: andns_lib.h:103
#define ANDNS_RCODE_ENSDMN
Definition: andns_lib.h:106
#define ANDNS_RCODE_ESRVFAIL
Definition: andns_lib.h:105
#define ANDNS_RCODE_EINTRPRT
Definition: andns_lib.h:104
#define ANDNS_RCODE_ERFSD
Definition: andns_lib.h:108
#define REALM_INT   1+1
#define REALM_INT_STR   "inet"
#define REALM_NTK   0+1
#define REALM_NTK_STR   "ntk"
#define REALMFROMPREF (   s)
Value:
({ \
uint8_t __res=0; \
if (!strncasecmp(REALM_NTK_STR,s,strlen(s))) \
__res=REALM_NTK; \
else if (!strncasecmp(REALM_INT_STR,s,strlen(s))) \
__res=REALM_INT; \
__res; })
#define REALM_NTK_STR
Definition: ntkresolv.h:32
#define REALM_INT
Definition: ntkresolv.h:31
#define REALM_INT_STR
Definition: ntkresolv.h:33
#define REALM_NTK
Definition: ntkresolv.h:30
#define say   printf
#define SERVICE_STR (   ap)
Value:
({ \
char *__g; \
char __t[MAX_INT_STR]; \
switch((ap)->qtype) { \
case AT_G: \
__g="*"; \
break; \
case AT_PTR: \
__g="None"; \
break; \
case AT_A: \
snprintf(__t,MAX_INT_STR,"%d", \
ap->service); \
__g=__t; \
break; \
default: \
__g="UNKNOW"; \
break; \
} \
__g;})
#define AT_G
Definition: andns_lib.h:101
#define MAX_INT_STR
Definition: ntkresolv.h:183
#define AT_PTR
Definition: andns_lib.h:100
#define AT_A
Definition: andns_lib.h:99
#define SNSD_PROTO_DEFAULT   SNSD_PROTO_TCP
#define SNSD_PROTO_TCP   0
#define SNSD_PROTO_TCP_STR   "tcp"
#define SNSD_PROTO_UDP   1
#define SNSD_PROTO_UDP_STR   "udp"
#define SNSD_SERVICE_DEFAULT   0
#define time_report
Value:
if (!AMISILENT){gettimeofday(&time_stop,NULL); \
say("Query time: %f seconds.\n" \
#define AMISILENT
Definition: ntkresolv.h:234
#define say
Definition: ntkresolv.h:237
static struct timeval time_start time_stop
Definition: ntkresolv.c:12
#define COMPUTE_TIME
Definition: ntkresolv.h:240
#define TIME_SCALE   1000000.0
#define VERSION   "0.3.3"

Typedef Documentation

Function Documentation

void answer_data_to_str ( andns_pkt_data apd,
char *  dst 
)

Here is the call graph for this function:

Here is the caller graph for this function:

double diff_time ( struct timeval  a,
struct timeval  b 
)
void do_command ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void ip_bin_to_str ( void *  data,
char *  dst 
)

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)
void ntkresolv_exit ( int  i)

Here is the caller graph for this function:

void ntkresolv_safe_exit ( int  i)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_finish ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_init ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_compute_hash ( void  )

Here is the caller graph for this function:

void opts_set_hash ( void  )

Here is the caller graph for this function:

void opts_set_ns ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_parsable_output ( void  )

Here is the caller graph for this function:

void opts_set_port ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_proto ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_qt ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_question ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_realm ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_recursion ( void  )

Here is the caller graph for this function:

void opts_set_service_and_proto ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void opts_set_silent ( void  )

Here is the caller graph for this function:

void print_answers ( )

Here is the call graph for this function:

Here is the caller graph for this function:

void print_headers ( )

Here is the caller graph for this function:

void print_parsable_answers ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void print_question ( )

Here is the caller graph for this function:

void print_results ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void proto_usage ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void qt_usage ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void realm_usage ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void service_and_proto_usage ( char *  arg)

Here is the call graph for this function:

Here is the caller graph for this function:

void usage ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

void version ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int QT_LEN =4
char* QTYPE_STR_LIST[] ={ "snsd" , "ptr" , "global" , "mx" }