diff options
Diffstat (limited to 'source4/libcli/dgram')
-rw-r--r-- | source4/libcli/dgram/browse.c | 9 | ||||
-rw-r--r-- | source4/libcli/dgram/dgramsocket.c | 28 | ||||
-rw-r--r-- | source4/libcli/dgram/libdgram.h | 22 | ||||
-rw-r--r-- | source4/libcli/dgram/mailslot.c | 12 | ||||
-rw-r--r-- | source4/libcli/dgram/netlogon.c | 10 | ||||
-rw-r--r-- | source4/libcli/dgram/ntlogon.c | 10 |
6 files changed, 45 insertions, 46 deletions
diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c index a304db9c9d..d6813b36b9 100644 --- a/source4/libcli/dgram/browse.c +++ b/source4/libcli/dgram/browse.c @@ -29,7 +29,7 @@ #include "librpc/gen_ndr/ndr_nbt.h" NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock, - struct nbt_name *dest_name, const char *dest_address, int dest_port, + struct nbt_name *dest_name, const struct nbt_peer_socket *dest, struct nbt_name *src_name, struct nbt_browse_packet *request) { NTSTATUS status; @@ -45,7 +45,7 @@ NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock, status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, NBT_MAILSLOT_BROWSE, - dest_name, dest_address, dest_port, + dest_name, dest, src_name, &blob); talloc_free(tmp_ctx); return status; @@ -59,6 +59,7 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock, DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; + struct nbt_peer_socket dest; status = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); @@ -69,10 +70,12 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock, make_nbt_name_client(&myname, lp_netbios_name()); + dest.port = request->src_port; + dest.addr = request->src_addr; status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, mailslot_name, &request->data.msg.source_name, - request->source, request->src_port, + &dest, &myname, &blob); talloc_free(tmp_ctx); return status; diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index e66e5ed52e..decbc0225c 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -35,8 +35,7 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) { TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); NTSTATUS status; - const char *src_addr; - int src_port; + struct nbt_peer_socket src; DATA_BLOB blob; size_t nread, dsize; struct nbt_dgram_packet *packet; @@ -55,16 +54,16 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) } status = socket_recvfrom(dgmsock->sock, blob.data, blob.length, &nread, 0, - &src_addr, &src_port); + &src.addr, &src.port); if (!NT_STATUS_IS_OK(status)) { talloc_free(tmp_ctx); return; } - talloc_steal(tmp_ctx, src_addr); + talloc_steal(tmp_ctx, src.addr); blob.length = nread; DEBUG(2,("Received dgram packet of length %d from %s:%d\n", - (int)blob.length, src_addr, src_port)); + (int)blob.length, src.addr, src.port)); packet = talloc(tmp_ctx, struct nbt_dgram_packet); if (packet == NULL) { @@ -88,14 +87,14 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) struct dgram_mailslot_handler *dgmslot; dgmslot = dgram_mailslot_find(dgmsock, mailslot_name); if (dgmslot) { - dgmslot->handler(dgmslot, packet, src_addr, src_port); + dgmslot->handler(dgmslot, packet, &src); } else { DEBUG(2,("No mailslot handler for '%s'\n", mailslot_name)); } } else { /* dispatch if there is a general handler */ if (dgmsock->incoming.handler) { - dgmsock->incoming.handler(dgmsock, packet, src_addr, src_port); + dgmsock->incoming.handler(dgmsock, packet, &src); } } @@ -116,10 +115,10 @@ static void dgm_socket_send(struct nbt_dgram_socket *dgmsock) len = req->encoded.length; status = socket_sendto(dgmsock->sock, &req->encoded, &len, 0, - req->dest_addr, req->dest_port); + req->dest.addr, req->dest.port); if (NT_STATUS_IS_ERR(status)) { DEBUG(3,("Failed to send datagram of length %u to %s:%d\n", - (unsigned)req->encoded.length, req->dest_addr, req->dest_port)); + (unsigned)req->encoded.length, req->dest.addr, req->dest.port)); DLIST_REMOVE(dgmsock->send_queue, req); talloc_free(req); continue; @@ -201,7 +200,7 @@ failed: NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, - const char *, int ), + const struct nbt_peer_socket *), void *private) { dgmsock->incoming.handler = handler; @@ -216,8 +215,7 @@ NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, */ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, struct nbt_dgram_packet *packet, - const char *dest_addr, - int dest_port) + const struct nbt_peer_socket *dest) { struct nbt_dgram_request *req; NTSTATUS status = NT_STATUS_NO_MEMORY; @@ -225,9 +223,9 @@ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, req = talloc(dgmsock, struct nbt_dgram_request); if (req == NULL) goto failed; - req->dest_addr = talloc_strdup(req, dest_addr); - if (req->dest_addr == NULL) goto failed; - req->dest_port = dest_port; + req->dest.port = dest->port; + req->dest.addr = talloc_strdup(req, dest->addr); + if (req->dest.addr == NULL) goto failed; status = ndr_push_struct_blob(&req->encoded, req, packet, (ndr_push_flags_fn_t)ndr_push_nbt_dgram_packet); diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h index 5bddd220d0..f913e90d88 100644 --- a/source4/libcli/dgram/libdgram.h +++ b/source4/libcli/dgram/libdgram.h @@ -22,7 +22,6 @@ #include "librpc/gen_ndr/ndr_nbt.h" - /* a datagram name request */ @@ -30,8 +29,7 @@ struct nbt_dgram_request { struct nbt_dgram_request *next, *prev; /* where to send the request */ - const char *dest_addr; - int dest_port; + struct nbt_peer_socket dest; /* the encoded request */ DATA_BLOB encoded; @@ -56,7 +54,7 @@ struct nbt_dgram_socket { /* what to do with incoming request packets */ struct { void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, - const char *, int ); + const struct nbt_peer_socket *src); void *private; } incoming; }; @@ -72,7 +70,7 @@ struct nbt_dgram_socket { typedef void (*dgram_mailslot_handler_t)(struct dgram_mailslot_handler *, struct nbt_dgram_packet *, - const char *, int ); + const struct nbt_peer_socket *src); struct dgram_mailslot_handler { struct dgram_mailslot_handler *next, *prev; @@ -88,12 +86,11 @@ struct dgram_mailslot_handler { /* prototypes */ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, struct nbt_dgram_packet *packet, - const char *dest_addr, - int dest_port); + const struct nbt_peer_socket *dest); NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock, void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *, - const char *, int ), + const struct nbt_peer_socket *), void *private); struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx); @@ -116,15 +113,13 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock, enum dgram_msg_type msg_type, const char *mailslot_name, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *dest, struct nbt_name *src_name, DATA_BLOB *request); NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *dest, struct nbt_name *src_name, struct nbt_netlogon_packet *request); NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, @@ -139,8 +134,7 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, enum dgram_msg_type msg_type, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *dest, struct nbt_name *src_name, struct nbt_ntlogon_packet *request); NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c index 14e7e49fc1..d521484422 100644 --- a/source4/libcli/dgram/mailslot.c +++ b/source4/libcli/dgram/mailslot.c @@ -152,27 +152,27 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock, enum dgram_msg_type msg_type, const char *mailslot_name, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *_dest, struct nbt_name *src_name, DATA_BLOB *request) { TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_dgram_packet packet; + struct nbt_peer_socket dest = *_dest; struct dgram_message *msg; struct dgram_smb_packet *smb; struct smb_trans_body *trans; NTSTATUS status; - if (dest_port == 0) { - dest_port = lp_dgram_port(); + if (dest.port == 0) { + dest.port = lp_dgram_port(); } ZERO_STRUCT(packet); packet.msg_type = msg_type; packet.flags = DGRAM_FLAG_FIRST | DGRAM_NODE_NBDD; packet.dgram_id = generate_random() % UINT16_MAX; - packet.source = socket_get_my_addr(dgmsock->sock, tmp_ctx); + packet.src_addr = socket_get_my_addr(dgmsock->sock, tmp_ctx); packet.src_port = socket_get_my_port(dgmsock->sock); msg = &packet.data.msg; @@ -199,7 +199,7 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock, trans->mailslot_name = mailslot_name; trans->data = *request; - status = nbt_dgram_send(dgmsock, &packet, dest_address, dest_port); + status = nbt_dgram_send(dgmsock, &packet, &dest); talloc_free(tmp_ctx); diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c index dda77689de..0627fe900c 100644 --- a/source4/libcli/dgram/netlogon.c +++ b/source4/libcli/dgram/netlogon.c @@ -33,8 +33,7 @@ */ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *dest, struct nbt_name *src_name, struct nbt_netlogon_packet *request) { @@ -52,7 +51,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, NBT_MAILSLOT_NETLOGON, - dest_name, dest_address, dest_port, + dest_name, dest, src_name, &blob); talloc_free(tmp_ctx); return status; @@ -71,6 +70,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; + struct nbt_peer_socket dest; status = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); @@ -81,10 +81,12 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, make_nbt_name_client(&myname, lp_netbios_name()); + dest.port = request->src_port; + dest.addr = request->src_addr; status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, mailslot_name, &request->data.msg.source_name, - request->source, request->src_port, + &dest, &myname, &blob); talloc_free(tmp_ctx); return status; diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c index efa5d4ab9e..2bdce6f853 100644 --- a/source4/libcli/dgram/ntlogon.c +++ b/source4/libcli/dgram/ntlogon.c @@ -34,8 +34,7 @@ NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, enum dgram_msg_type msg_type, struct nbt_name *dest_name, - const char *dest_address, - int dest_port, + const struct nbt_peer_socket *dest, struct nbt_name *src_name, struct nbt_ntlogon_packet *request) { @@ -53,7 +52,7 @@ NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, status = dgram_mailslot_send(dgmsock, msg_type, NBT_MAILSLOT_NTLOGON, - dest_name, dest_address, dest_port, + dest_name, dest, src_name, &blob); talloc_free(tmp_ctx); return status; @@ -72,6 +71,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; + struct nbt_peer_socket dest; status = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); @@ -82,10 +82,12 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, make_nbt_name_client(&myname, lp_netbios_name()); + dest.port = request->src_port; + dest.addr = request->src_addr; status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, mailslot_name, &request->data.msg.source_name, - request->source, request->src_port, + &dest, &myname, &blob); talloc_free(tmp_ctx); return status; |