summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2010-08-13 11:09:09 +0200
committerKai Blin <kai@samba.org>2010-10-04 20:59:59 +0200
commit65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453 (patch)
tree185e1a6ab71e87b623df7e86cabaab14d3c0909a /librpc
parentda21f78099884ce425dfbb99c8c246f6fcd98a3a (diff)
downloadsamba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.tar.gz
samba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.tar.bz2
samba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.zip
dnsp: Parse TXT records
Diffstat (limited to 'librpc')
-rw-r--r--librpc/idl/dnsp.idl2
-rw-r--r--librpc/ndr/ndr_dnsp.c52
-rw-r--r--librpc/ndr/ndr_dnsp.h4
3 files changed, 58 insertions, 0 deletions
diff --git a/librpc/idl/dnsp.idl b/librpc/idl/dnsp.idl
index a4a175aea4..af904d09c1 100644
--- a/librpc/idl/dnsp.idl
+++ b/librpc/idl/dnsp.idl
@@ -40,6 +40,7 @@ interface dnsp
DNS_TYPE_HINFO = 0xD,
DNS_TYPE_MINFO = 0xE,
DNS_TYPE_MX = 0xF,
+ DNS_TYPE_TXT = 0x10,
DNS_TYPE_RP = 0x11,
DNS_TYPE_AFSDB = 0x12,
DNS_TYPE_X25 = 0x13,
@@ -92,6 +93,7 @@ interface dnsp
[case(DNS_TYPE_CNAME)] dnsp_name cname;
[case(DNS_TYPE_SOA)] [flag(NDR_BIG_ENDIAN)] dnsp_soa soa;
[case(DNS_TYPE_MX)] [flag(NDR_BIG_ENDIAN)] dnsp_mx mx;
+ [case(DNS_TYPE_TXT)] dnsp_string txt;
[case(DNS_TYPE_PTR)] dnsp_name ptr;
[case(DNS_TYPE_AAAA)] ipv6address ip;
[case(DNS_TYPE_SRV)] [flag(NDR_BIG_ENDIAN)] dnsp_srv srv;
diff --git a/librpc/ndr/ndr_dnsp.c b/librpc/ndr/ndr_dnsp.c
index f777591f25..256638aed3 100644
--- a/librpc/ndr/ndr_dnsp.c
+++ b/librpc/ndr/ndr_dnsp.c
@@ -98,3 +98,55 @@ enum ndr_err_code ndr_push_dnsp_name(struct ndr_push *ndr, int ndr_flags, const
return NDR_ERR_SUCCESS;
}
+
+/*
+ print a dnsp_string
+*/
+_PUBLIC_ void ndr_print_dnsp_string(struct ndr_print *ndr, const char *name,
+ const char *dns_string)
+{
+ ndr->print(ndr, "%-25s: %s", name, dns_string);
+}
+
+/*
+ pull a dnsp_string
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_dnsp_string(struct ndr_pull *ndr, int ndr_flags, const char **string)
+{
+ uint8_t len;
+ uint32_t total_len;
+ char *ret;
+
+ NDR_CHECK(ndr_pull_uint8(ndr, ndr_flags, &len));
+
+ ret = talloc_strdup(ndr->current_mem_ctx, "");
+ if (!ret) {
+ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp");
+ }
+ total_len = 1;
+ ret = talloc_zero_array(ndr->current_mem_ctx, char, len+1);
+ if (!ret) {
+ return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Failed to pull dnsp");
+ }
+ NDR_CHECK(ndr_pull_bytes(ndr, (uint8_t *)&ret[total_len-1], len));
+ total_len = len;
+
+ (*string) = ret;
+ NDR_PULL_ALIGN(ndr, 1);
+ return NDR_ERR_SUCCESS;
+}
+
+enum ndr_err_code ndr_push_dnsp_string(struct ndr_push *ndr, int ndr_flags, const char *string)
+{
+ int total_len;
+ total_len = strlen(string) + 1;
+ if (total_len > 255) {
+ return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
+ "dns_name of length %d larger than 255", total_len);
+ }
+ NDR_CHECK(ndr_push_uint8(ndr, ndr_flags, (uint8_t)total_len));
+ NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)string, total_len - 1));
+ NDR_PUSH_ALIGN(ndr, 1);
+
+ return NDR_ERR_SUCCESS;
+}
diff --git a/librpc/ndr/ndr_dnsp.h b/librpc/ndr/ndr_dnsp.h
index 07952cb8ce..67f952ccb3 100644
--- a/librpc/ndr/ndr_dnsp.h
+++ b/librpc/ndr/ndr_dnsp.h
@@ -23,3 +23,7 @@ void ndr_print_dnsp_name(struct ndr_print *ndr, const char *name,
const char *dns_name);
enum ndr_err_code ndr_pull_dnsp_name(struct ndr_pull *ndr, int ndr_flags, const char **name);
enum ndr_err_code ndr_push_dnsp_name(struct ndr_push *ndr, int ndr_flags, const char *name);
+void ndr_print_dnsp_string(struct ndr_print *ndr, const char *name,
+ const char *dns_string);
+enum ndr_err_code ndr_pull_dnsp_string(struct ndr_pull *ndr, int ndr_flags, const char **string);
+enum ndr_err_code ndr_push_dnsp_string(struct ndr_push *ndr, int ndr_flags, const char *string);