diff options
author | Kai Blin <kai@samba.org> | 2010-08-13 11:09:09 +0200 |
---|---|---|
committer | Kai Blin <kai@samba.org> | 2010-10-04 20:59:59 +0200 |
commit | 65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453 (patch) | |
tree | 185e1a6ab71e87b623df7e86cabaab14d3c0909a | |
parent | da21f78099884ce425dfbb99c8c246f6fcd98a3a (diff) | |
download | samba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.tar.gz samba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.tar.bz2 samba-65d2cfdcf1517b2e99df0556eb5bcfbc0c49a453.zip |
dnsp: Parse TXT records
-rw-r--r-- | librpc/idl/dnsp.idl | 2 | ||||
-rw-r--r-- | librpc/ndr/ndr_dnsp.c | 52 | ||||
-rw-r--r-- | librpc/ndr/ndr_dnsp.h | 4 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/NDR.pm | 3 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 5 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Typelist.pm | 1 |
6 files changed, 66 insertions, 1 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); diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm index 4961cda99e..b5dd2aaf9c 100644 --- a/pidl/lib/Parse/Pidl/NDR.pm +++ b/pidl/lib/Parse/Pidl/NDR.pm @@ -76,7 +76,8 @@ my $scalar_alignment = { 'wrepl_nbt_name' => 4, 'ipv4address' => 4, 'ipv6address' => 4, #16? - 'dnsp_name' => 1 + 'dnsp_name' => 1, + 'dnsp_string' => 1 }; sub GetElementLevelTable($$) diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 3318229f0e..cf554f5c0c 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -931,6 +931,10 @@ sub ConvertObjectFromPythonData($$$$$$;$) return; } + if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "dnsp_string") { + $self->pidl("$target = PyString_AS_STRING($cvar);"); + return; + } if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") { $self->pidl("$target = NT_STATUS(PyInt_AsLong($cvar));"); @@ -1095,6 +1099,7 @@ sub ConvertScalarToPython($$$) if ($ctypename eq "ipv4address") { return "PyString_FromString_check_null($cvar)"; } if ($ctypename eq "ipv6address") { return "PyString_FromString_check_null($cvar)"; } if ($ctypename eq "dnsp_name") { return "PyString_FromString_check_null($cvar)"; } + if ($ctypename eq "dnsp_string") { return "PyString_FromString_check_null($cvar)"; } if ($ctypename eq "pointer") { return "PyCObject_FromTallocPtr($cvar)"; } diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm index b841e62209..00204a3cfc 100644 --- a/pidl/lib/Parse/Pidl/Typelist.pm +++ b/pidl/lib/Parse/Pidl/Typelist.pm @@ -59,6 +59,7 @@ my %scalars = ( "ipv4address" => "const char *", "ipv6address" => "const char *", "dnsp_name" => "const char *", + "dnsp_string" => "const char *", ); my %aliases = ( |