Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
cli-fn: updated to match dimgrav/samba
Browse files Browse the repository at this point in the history
  • Loading branch information
dimgrav committed Aug 22, 2017
1 parent 76e1bd2 commit 85f5abe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
16 changes: 8 additions & 8 deletions cli-fn/client_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "libcli/util/ntstatus.h"
#include "auth/auth.h"
#include "auth/gensec/gensec.h"
#include "gss-tsig/libtsig.h"
#include "libcli/dns/libtsig.h"

#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DNS
Expand Down Expand Up @@ -59,8 +59,8 @@ static WERROR dns_empty_tsig(TALLOC_CTX *mem_ctx,
}

/* identify tkey in record */
struct dns_client_tkey *dns_find_tkey(struct dns_client_tkey_store *store,
const char *name)
struct dns_client_tkey *dns_find_cli_tkey(struct dns_client_tkey_store *store,
const char *name)
{
struct dns_client_tkey *tkey = NULL;
uint16_t i = 0;
Expand All @@ -86,9 +86,9 @@ struct dns_client_tkey *dns_find_tkey(struct dns_client_tkey_store *store,
/* generate signature and rebuild packet with TSIG */
static WERROR dns_cli_generate_tsig(struct dns_client *dns,
TALLOC_CTX *mem_ctx,
struct dns_request_state *state,
struct dns_name_packet *packet,
DATA_BLOB *in)
struct dns_request_cli_state *state,
struct dns_name_packet *packet,
DATA_BLOB *in)
{
int tsig_flag = 0;
struct dns_client_tkey *tkey = NULL;
Expand Down Expand Up @@ -120,7 +120,7 @@ static WERROR dns_cli_generate_tsig(struct dns_client *dns,
}

/* save the keyname from the TSIG request to add MAC later */
tkey = dns_find_tkey(dns->tkeys, state->tsig->name);
tkey = dns_find_cli_tkey(dns->tkeys, state->tsig->name);
if (tkey == NULL) {
state->key_name = talloc_strdup(state->mem_ctx,
state->tsig->name);
Expand Down Expand Up @@ -198,4 +198,4 @@ static WERROR dns_cli_generate_tsig(struct dns_client *dns,
packet->arcount++;

return WERR_OK;
}
}
33 changes: 19 additions & 14 deletions cli-fn/dns_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
#include "system/network.h"
#include <tevent.h>
#include "lib/tsocket/tsocket.h"
#include "udp-cli/libudp.h"
#include "libcli/dns/libudp.h"
#include "lib/util/tevent_unix.h"
#include "lib/util/samba_util.h"
#include "libcli/util/error.h"
#include "librpc/gen_ndr/dns.h"
#include "tcp-cli/libtcp.h"
#include "libcli/dns/libtcp.h"

#define DNS_REQUEST_TIMEOUT 2

/* callbacks */
static void dns_tcp_req_recv_reply(struct tevent_req *subreq);
static void dns_tcp_req_done(struct tevent_req *subreq);
void dns_tcp_req_recv_reply(struct tevent_req *subreq);
void dns_tcp_req_done(struct tevent_req *subreq);

/* terminate tcp conn with server */
static void dns_tcp_terminate_connection(struct dns_tcp_connection *dns_conn,
void dns_tcp_terminate_connection(struct dns_tcp_connection *dns_conn,
const char *reason)
{
stream_terminate_connection(dns_conn->conn, reason);
Expand All @@ -56,7 +56,7 @@ struct tevent_req *dns_tcp_req_send(TALLOC_CTX *mem_ctx,
struct dns_tcp_request_state *state;
struct tsocket_address *local_addr, *server_addr;
struct tstream_context *stream;
int req_ret, soc_ret, err = 0;
int req_ret, *soc_ret, *err;

req = tevent_req_create(mem_ctx, &state, struct dns_tcp_request_state);
if (req == NULL) {
Expand All @@ -81,7 +81,7 @@ struct tevent_req *dns_tcp_req_send(TALLOC_CTX *mem_ctx,
}

/* must be reviewed! */
soc_ret = tstream_inet_tcp_connect_recv(socreq, err, mem_ctx, stream, NULL);
soc_ret = tstream_inet_tcp_connect_recv(socreq, *err, mem_ctx, stream, NULL);
TALLOC_FREE(socreq);
if (soc_ret == -1 && err != 0) {
tevent_req_error(socreq, err);
Expand All @@ -100,8 +100,8 @@ struct tevent_req *dns_tcp_req_send(TALLOC_CTX *mem_ctx,

/* not sure how dump_data() works with pointers
* followed source4/heimdal/lib/roken/dumpdata.c
* dump_data(10, vector, count);
*/
dump_data(10, vector, count);

subreq = tstream_writev_send(mem_ctx, ev, stream, vector, count);
if (tevent_req_nomem(subreq, req)) {
Expand All @@ -121,7 +121,7 @@ struct tevent_req *dns_tcp_req_send(TALLOC_CTX *mem_ctx,
}

/* get buffer and wait to receive server response */
static void dns_tcp_req_recv_reply(struct tevent_req *subreq)
void dns_tcp_req_recv_reply(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);
Expand All @@ -145,9 +145,9 @@ static void dns_tcp_req_recv_reply(struct tevent_req *subreq)
}

/* response loop */
struct dns_server *dns = dns_conn->dns_socket->dns; // uses the same iface with server
struct dns_tcp_connection *dns_conn = tevent_req_callback_data(subreq,
struct dns_tcp_connection);
struct dns_client *dns = dns_conn->dns_socket->dns; // uses server iface
struct dns_tcp_call *call;

call = talloc(dns_conn, struct dns_tcp_call);
Expand All @@ -162,7 +162,7 @@ static void dns_tcp_req_recv_reply(struct tevent_req *subreq)
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
dns_tcp_terminate_connection(dns_conn,
"tstream_read_pdu_blob_recv(): error %s", nt_errstr(status));
("tstream_read_pdu_blob_recv(): error %s", nt_errstr(status)));
return;
}

Expand All @@ -185,10 +185,15 @@ static void dns_tcp_req_recv_reply(struct tevent_req *subreq)
}

/* callback status */
static void dns_tcp_req_done(struct tevent_req *subreq)
void dns_tcp_req_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req);
WERROR err = dns_process_recv(subreq, call, &call->out);
struct dns_tcp_connection *dns_conn = tevent_req_callback_data(subreq,
struct dns_tcp_connection);
struct dns_tcp_call *call;
WERROR err;
err = dns_process_recv(subreq, call, &call->out);

TALLOC_FREE(subreq);

if (!W_ERROR_IS_OK(err)) {
Expand Down Expand Up @@ -222,4 +227,4 @@ int dns_tcp_req_recv(struct tevent_req *req,
tevent_req_received(req);

return 0;
}
}
4 changes: 2 additions & 2 deletions cli-fn/dns_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "system/network.h"
#include <tevent.h>
#include "lib/tsocket/tsocket.h"
#include "udp-cli/libudp.h"
#include "libcli/dns/libudp.h"
#include "lib/util/tevent_unix.h"
#include "lib/util/samba_util.h"
#include "libcli/util/error.h"
Expand Down Expand Up @@ -175,4 +175,4 @@ int dns_udp_request_recv(struct tevent_req *req,
tevent_req_received(req);

return 0;
}
}

0 comments on commit 85f5abe

Please sign in to comment.