*/
struct cldap_socket {
/* the low level socket */
- struct tsocket_context *sock;
+ struct tdgram_context *sock;
/*
* Are we in connected mode, which means
static int cldap_socket_destructor(struct cldap_socket *c)
{
- tsocket_disconnect(c->sock);
-
while (c->searches.list) {
struct cldap_search_state *s = c->searches.list;
DLIST_REMOVE(c->searches.list, s);
return true;
}
- c->recv_subreq = tsocket_recvfrom_send(c->sock, c);
+ c->recv_subreq = tdgram_recvfrom_send(c, c->event.ctx, c->sock);
if (!c->recv_subreq) {
return false;
}
goto nomem;
}
- ret = tsocket_recvfrom_recv(subreq,
- &in->recv_errno,
- in,
- &in->buf,
- &in->src);
+ ret = tdgram_recvfrom_recv(subreq,
+ &in->recv_errno,
+ in,
+ &in->buf,
+ &in->src);
talloc_free(subreq);
subreq = NULL;
if (ret >= 0) {
c->event.ctx = ev;
if (!local_addr) {
- ret = tsocket_address_inet_from_strings(c, "ipv4",
+ ret = tsocket_address_inet_from_strings(c, "ip",
NULL, 0,
&any);
if (ret != 0) {
goto nomem;
}
- ret = tsocket_address_create_socket(local_addr,
- TSOCKET_TYPE_DGRAM,
- c, &c->sock);
+ ret = tdgram_inet_udp_socket(local_addr, remote_addr,
+ c, &c->sock);
if (ret != 0) {
status = map_nt_error_from_unix(errno);
goto nterror;
}
talloc_free(any);
- tsocket_set_event_context(c->sock, c->event.ctx);
-
if (remote_addr) {
- ret = tsocket_connect(c->sock, remote_addr);
- if (ret != 0) {
- status = map_nt_error_from_unix(errno);
- goto nterror;
- }
c->connected = true;
}
DATA_BLOB blob;
};
-static void cldap_reply_state_destroy(struct tevent_req *req);
+static void cldap_reply_state_destroy(struct tevent_req *subreq);
/*
queue a cldap reply for send
struct ldap_message *msg;
DATA_BLOB blob1, blob2;
NTSTATUS status;
- struct tevent_req *req;
+ struct tevent_req *subreq;
if (cldap->connected) {
return NT_STATUS_PIPE_CONNECTED;
data_blob_free(&blob1);
data_blob_free(&blob2);
- req = tsocket_sendto_queue_send(state,
- cldap->sock,
- cldap->send_queue,
- state->blob.data,
- state->blob.length,
- state->dest);
- if (!req) {
+ subreq = tdgram_sendto_queue_send(state,
+ cldap->event.ctx,
+ cldap->sock,
+ cldap->send_queue,
+ state->blob.data,
+ state->blob.length,
+ state->dest);
+ if (!subreq) {
goto nomem;
}
/* the callback will just free the state, as we don't need a result */
- tevent_req_set_callback(req, cldap_reply_state_destroy, state);
+ tevent_req_set_callback(subreq, cldap_reply_state_destroy, state);
return NT_STATUS_OK;
return status;
}
-static void cldap_reply_state_destroy(struct tevent_req *req)
+static void cldap_reply_state_destroy(struct tevent_req *subreq)
{
- struct cldap_reply_state *state = tevent_req_callback_data(req,
+ struct cldap_reply_state *state = tevent_req_callback_data(subreq,
struct cldap_reply_state);
/* we don't want to know the result here, we just free the state */
- talloc_free(req);
+ talloc_free(subreq);
talloc_free(state);
}
static int cldap_search_state_destructor(struct cldap_search_state *s)
{
if (s->caller.cldap) {
+ if (s->message_id != -1) {
+ idr_remove(s->caller.cldap->searches.idr, s->message_id);
+ s->message_id = -1;
+ }
DLIST_REMOVE(s->caller.cldap->searches.list, s);
cldap_recvfrom_stop(s->caller.cldap);
ZERO_STRUCT(s->caller);
if (!req) {
return NULL;
}
+ ZERO_STRUCTP(state);
state->req = req;
state->caller.cldap = cldap;
+ state->message_id = -1;
+
+ talloc_set_destructor(state, cldap_search_state_destructor);
if (io->in.dest_address) {
if (cldap->connected) {
goto post;
}
ret = tsocket_address_inet_from_strings(state,
- "ipv4",
+ "ip",
io->in.dest_address,
io->in.dest_port,
&state->request.dest);
goto post;
}
- subreq = tsocket_sendto_queue_send(state,
- state->caller.cldap->sock,
- state->caller.cldap->send_queue,
- state->request.blob.data,
- state->request.blob.length,
- state->request.dest);
+ subreq = tdgram_sendto_queue_send(state,
+ state->caller.cldap->event.ctx,
+ state->caller.cldap->sock,
+ state->caller.cldap->send_queue,
+ state->request.blob.data,
+ state->request.blob.length,
+ state->request.dest);
if (tevent_req_nomem(subreq, req)) {
goto post;
}
tevent_req_set_callback(subreq, cldap_search_state_queue_done, req);
DLIST_ADD_END(cldap->searches.list, state, struct cldap_search_state *);
- talloc_set_destructor(state, cldap_search_state_destructor);
return req;
int sys_errno = 0;
struct timeval next;
- ret = tsocket_sendto_queue_recv(subreq, &sys_errno);
+ ret = tdgram_sendto_queue_recv(subreq, &sys_errno);
talloc_free(subreq);
if (ret == -1) {
NTSTATUS status;
return;
}
- subreq = tsocket_sendto_queue_send(state,
- state->caller.cldap->sock,
- state->caller.cldap->send_queue,
- state->request.blob.data,
- state->request.blob.length,
- state->request.dest);
+ subreq = tdgram_sendto_queue_send(state,
+ state->caller.cldap->event.ctx,
+ state->caller.cldap->sock,
+ state->caller.cldap->send_queue,
+ state->request.blob.data,
+ state->request.blob.length,
+ state->request.dest);
if (tevent_req_nomem(subreq, req)) {
return;
}
receive a cldap netlogon reply
*/
NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
- struct smb_iconv_convenience *iconv_convenience,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io)
{
data = state->search.out.response->attributes[0].values;
status = pull_netlogon_samlogon_response(data, mem_ctx,
- iconv_convenience,
&io->out.netlogon);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
sync cldap netlogon search
*/
NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
- struct smb_iconv_convenience *iconv_convenience,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io)
{
return NT_STATUS_INTERNAL_ERROR;
}
- status = cldap_netlogon_recv(req, iconv_convenience, mem_ctx, io);
+ status = cldap_netlogon_recv(req, mem_ctx, io);
talloc_free(req);
return status;
send a netlogon reply
*/
NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
- struct smb_iconv_convenience *iconv_convenience,
uint32_t message_id,
struct tsocket_address *dest,
uint32_t version,
DATA_BLOB blob;
status = push_netlogon_samlogon_response(&blob, tmp_ctx,
- iconv_convenience,
netlogon);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);