Browse Source

inet/resolv: add ns_{put,get}{16,32}

This patch introduces a new config directive
'UCLIBC_HAS_RESOLVER_SUPPORT' and adds the new symbols conditionally.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Daniel Mack 12 years ago
parent
commit
466f11015f
4 changed files with 46 additions and 0 deletions
  1. 10 0
      extra/Configs/Config.in
  2. 2 0
      libc/inet/Makefile.in
  3. 8 0
      libc/inet/ns_netint.c
  4. 26 0
      libc/inet/resolv.c

+ 10 - 0
extra/Configs/Config.in

@@ -1276,6 +1276,16 @@ config UCLIBC_HAS_EXTRA_COMPAT_RES_STATE
 	  Answer Y if selecting UCLIBC_HAS_COMPAT_RES_STATE is not enough.
 	  As far as I can say, this should never be needed.
 
+config UCLIBC_HAS_RESOLVER_SUPPORT
+	bool "DNS resolver functions"
+	select UCLIBC_HAS_COMPAT_RES_STATE
+	help
+	  Provide implementations for DNS resolver functions.
+	  In particular, the following functions will be added to the
+	  library:
+
+	  ns_get16, ns_get32, ns_put16, ns_put32
+
 config UCLIBC_HAS_LIBRESOLV_STUB
 	bool "Provide libresolv stub"
 	help

+ 2 - 0
libc/inet/Makefile.in

@@ -40,6 +40,8 @@ CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
 CSRC-$(findstring y,$(UCLIBC_HAS_IPV4)$(UCLIBC_HAS_IPV6)) += \
 	res_init.c res_query.c res_comp.c ns_name.c \
 	_res_state.c
+CSRC-$(findstring y,$(UCLIBC_HAS_RESOLVER_SUPPORT)) += \
+	ns_netint.c
 ## # unused ATM
 ## CSRC-y += encodep.c decodep.c formquery.c
 

+ 8 - 0
libc/inet/ns_netint.c

@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ns_netint
+#include RESOLVER

+ 26 - 0
libc/inet/resolv.c

@@ -3326,6 +3326,32 @@ int res_querydomain(const char *name, const char *domain, int class, int type,
 libc_hidden_def(res_querydomain)
 #endif /* L_res_query */
 
+#ifdef L_ns_netint
+unsigned int ns_get16(const unsigned char *src)
+{
+	unsigned int dst;
+	NS_GET16(dst, src);
+	return dst;
+}
+
+unsigned long ns_get32(const unsigned char *src)
+{
+	unsigned long dst;
+	NS_GET32(dst, src);
+	return dst;
+}
+
+void ns_put16(unsigned int src, unsigned char *dst)
+{
+	NS_PUT16(src, dst);
+}
+
+void ns_put32(unsigned long src, unsigned char *dst)
+{
+	NS_PUT32(src, dst);
+}
+#endif /* L_ns_netint */
+
 /* Unimplemented: */
 /* res_mkquery */
 /* res_send */