You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

andns.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include <stdio.h>
  23. #include <sys/socket.h>
  24. #include <netdb.h>
  25. #include "dnslib.h"
  26. #include "andns_lib.h"
  27. #include "inet.h"
  28. #define ANDNS_TIMEOUT 15
  29. #define MAXNSSERVERS 3
  30. #define DNS_REPLY_TIMEOUT 10 /* seconds */
  31. #define DNS_PORT 53
  32. #define DNS_PORT_STR "53"
  33. /* PREFIX TO QUERY THE INET REALM */
  34. #define INET_REALM_PREFIX ".INT"
  35. #define NTK_REALM_PREFIX ".NTK"
  36. #define PTR_INET_REALM_PREFIX "INT."
  37. #define PTR_NTK_REALM_PREFIX "NTK."
  38. #define REALM_PREFIX_LEN 4
  39. #define DNS_PROTO 0
  40. #define ANDNS_PROTO 1
  41. #define NK_DNS 0
  42. #define NK_NTK 1
  43. #define NK_INET 2
  44. #define GET_NK_BIT(msg) (*((msg+3))>>4)&0x03
  45. #define RCODE_NOERR 0
  46. #define RCODE_EINTRPRT 1
  47. #define RCODE_ESRVFAIL 2
  48. #define RCODE_ENSDMN 3
  49. #define RCODE_ENIMPL 4
  50. #define RCODE_ERFSD 5
  51. /* FUNCTIONS */
  52. int store_ns(char *ns);
  53. int collect_resolv_conf(char *resolve_conf);
  54. void reset_andns_ns(void);
  55. int andns_init(int restricted, char *resolv_conf, int family);
  56. void andns_close(void);
  57. int ns_general_send(char *msg, int msglen, char *answer, int anslen);
  58. void dpktacpy(dns_pkt * dst, dns_pkt * src, const char *prefix);
  59. dns_pkt *dpktcpy(dns_pkt * src, const char *prefix);
  60. char *rm_realm_prefix(char *from, char *dst, int type);
  61. dns_pkt *dpktcpy_rm_pref(dns_pkt * src);
  62. int andns_gethostbyname(char *hname, inet_prefix * ip);
  63. int andns_realm(dns_pkt_qst * dpq, int *prefixed);
  64. int is_prefixed(dns_pkt * dp);
  65. int dns_forward(dns_pkt * dp, char *msg, int msglen, char *answer);
  66. int inet_rslv(dns_pkt * dp, char *msg, int msglen, char *answer);
  67. int nk_rslv(andns_pkt * ap, char *msg, int msglen, char *answer);
  68. int qtype_a_to_d(andns_pkt * ap);
  69. int apqsttodpqst(andns_pkt * ap, dns_pkt ** dpsrc);
  70. int dpanswtoapansw(dns_pkt * dp, andns_pkt * ap);
  71. int nk_forward(andns_pkt * ap, char *msg, int msglen, char *answer);
  72. char *andns_rslv(char *msg, int msglen, char *answer, int *answ_len);
  73. #endif /* ANDNS_H */