The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
andns.h
Go to the documentation of this file.
1  /**************************************
2  * AUTHOR: Federico Tomassini *
3  * Copyright (C) Federico Tomassini *
4  * Contact effetom@gmail.com *
5  ***********************************************
6  ******* BEGIN 3/2006 ********
7 *************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 ************************************************************************/
20 #ifndef ANDNS_H
21 #define ANDNS_H
22 
23 #include <stdio.h>
24 #include <sys/socket.h>
25 #include <netdb.h>
26 #include "dnslib.h"
27 #include "andns_lib.h"
28 #include "inet.h"
29 
30 #define ANDNS_TIMEOUT 15
31 
32 #define MAXNSSERVERS 3
33 #define DNS_REPLY_TIMEOUT 10 /* seconds */
34 
35 #define DNS_PORT 53
36 #define DNS_PORT_STR "53"
37 
38 /* PREFIX TO QUERY THE INET REALM */
39 #define INET_REALM_PREFIX ".INT"
40 #define NTK_REALM_PREFIX ".NTK"
41 #define PTR_INET_REALM_PREFIX "INT."
42 #define PTR_NTK_REALM_PREFIX "NTK."
43 #define REALM_PREFIX_LEN 4
44 
45 #define DNS_PROTO 0
46 #define ANDNS_PROTO 1
47 
48 #define NK_DNS 0
49 #define NK_NTK 1
50 #define NK_INET 2
51 #define GET_NK_BIT(msg) (*((msg+3))>>4)&0x03
52 
53 #define RCODE_NOERR 0
54 #define RCODE_EINTRPRT 1
55 #define RCODE_ESRVFAIL 2
56 #define RCODE_ENSDMN 3
57 #define RCODE_ENIMPL 4
58 #define RCODE_ERFSD 5
59 
60 
61 
62  /* FUNCTIONS */
63 
64 int store_ns(char *ns);
65 int collect_resolv_conf(char *resolve_conf);
66 void reset_andns_ns(void);
67 int andns_init(int restricted, char *resolv_conf,int family);
68 void andns_close(void);
69 int ns_general_send(char *msg,int msglen,char *answer,int anslen);
70 void dpktacpy(dns_pkt *dst,dns_pkt *src,const char *prefix);
71 dns_pkt* dpktcpy(dns_pkt *src,const char *prefix);
72 char* rm_realm_prefix(char *from,char *dst,int type);
74 int andns_gethostbyname(char *hname, inet_prefix *ip);
75 int andns_realm(dns_pkt_qst *dpq,int *prefixed);
76 int is_prefixed(dns_pkt *dp);
77 int dns_forward(dns_pkt *dp,char *msg,int msglen,char* answer);
78 int inet_rslv(dns_pkt *dp,char *msg,int msglen,char *answer);
79 int nk_rslv(andns_pkt *ap,char *msg,int msglen,char *answer);
80 int qtype_a_to_d(andns_pkt *ap);
81 int apqsttodpqst(andns_pkt *ap,dns_pkt **dpsrc);
82 int dpanswtoapansw(dns_pkt *dp,andns_pkt *ap);
83 int nk_forward(andns_pkt *ap,char *msg,int msglen,char *answer);
84 char *andns_rslv(char *msg, int msglen,char *answer, int *answ_len);
85 
86 #endif /* ANDNS_H */
int dpanswtoapansw(dns_pkt *dp, andns_pkt *ap)
Definition: andns.c:496
int apqsttodpqst(andns_pkt *ap, dns_pkt **dpsrc)
Definition: andns.c:440
int collect_resolv_conf(char *resolve_conf)
Definition: andns.c:121
int qtype_a_to_d(andns_pkt *ap)
Definition: andns.c:424
int is_prefixed(dns_pkt *dp)
Definition: andns.c:412
void reset_andns_ns(void)
Definition: andns.c:159
int andns_init(int restricted, char *resolv_conf, int family)
Definition: andns.c:175
Definition: dnslib.h:89
void andns_close(void)
Definition: andns.c:228
int nk_forward(andns_pkt *ap, char *msg, int msglen, char *answer)
Definition: andns.c:851
Definition: inet.h:73
int type
Definition: krnl_route.c:49
dns_pkt * dpktcpy(dns_pkt *src, const char *prefix)
Definition: andns.c:304
int store_ns(char *ns)
Definition: andns.c:96
void dpktacpy(dns_pkt *dst, dns_pkt *src, const char *prefix)
Definition: andns.c:257
char * rm_realm_prefix(char *from, char *dst, int type)
Definition: andns.c:331
Definition: dnslib.h:111
int andns_gethostbyname(char *hname, inet_prefix *ip)
Definition: andns.c:570
int dns_forward(dns_pkt *dp, char *msg, int msglen, char *answer)
Definition: andns.c:627
char * andns_rslv(char *msg, int msglen, char *answer, int *answ_len)
Definition: andns.c:910
int ns_general_send(char *msg, int msglen, char *answer, int anslen)
Definition: andns.c:236
int andns_realm(dns_pkt_qst *dpq, int *prefixed)
Definition: andns.c:369
int nk_rslv(andns_pkt *ap, char *msg, int msglen, char *answer)
Definition: andns.c:761
int inet_rslv(dns_pkt *dp, char *msg, int msglen, char *answer)
Definition: andns.c:694
int family
Definition: if.c:34
dns_pkt * dpktcpy_rm_pref(dns_pkt *src)
Definition: andns.c:357
Definition: andns_lib.h:64