r25026: Move param/param.h out of includes.h
[kai/samba.git] / source4 / libcli / cldap / cldap.c
index bd2ab630db2958182717524d4617b871d40b14b6..4c41e1301452bf45fe589045bf8acafc4b5d1713 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -40,6 +39,7 @@
 #include "lib/socket/socket.h"
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
+#include "param/param.h"
 
 /*
   destroy a pending request
@@ -100,7 +100,6 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
                talloc_free(tmp_ctx);
                return;
        }
-       talloc_steal(tmp_ctx, asn1->data);
 
        ldap_msg = talloc(tmp_ctx, struct ldap_message);
        if (ldap_msg == NULL) {
@@ -129,8 +128,7 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
                return;
        }
 
-       req->asn1 = asn1;
-       talloc_steal(req, asn1->data);
+       req->asn1 = talloc_steal(req, asn1);
        req->asn1->ofs = 0;
 
        req->state = CLDAP_REQUEST_DONE;
@@ -312,9 +310,14 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
        req->timeout     = io->in.timeout;
        req->num_retries = io->in.retries;
        req->is_reply    = False;
+       req->asn1        = asn1_init(req);
+       if (!req->asn1) {
+               goto failed;
+       }
 
        req->dest = socket_address_from_strings(req, cldap->sock->backend_name,
-                                               io->in.dest_address, lp_cldap_port());
+                                               io->in.dest_address, 
+                                               lp_cldap_port());
        if (!req->dest) goto failed;
 
        req->message_id = idr_get_new_random(cldap->idr, req, UINT16_MAX);
@@ -376,6 +379,10 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
        req->cldap       = cldap;
        req->state       = CLDAP_REQUEST_SEND;
        req->is_reply    = True;
+       req->asn1        = asn1_init(req);
+       if (!req->asn1) {
+               goto failed;
+       }
 
        req->dest        = io->dest;
        if (talloc_reference(req, io->dest) == NULL) goto failed;