summaryrefslogtreecommitdiff
path: root/source4/nbt_server/interfaces.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-04-03 04:32:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:11:24 -0500
commita47cb58c2f6d34dd98e3dc2dd023a259ff501643 (patch)
tree7ce71f8ac40452570f110ec1895d3e5a65fafbd2 /source4/nbt_server/interfaces.c
parentb9df3f5fe80087a55a45474a5a860aec2788a26d (diff)
downloadsamba-a47cb58c2f6d34dd98e3dc2dd023a259ff501643.tar.gz
samba-a47cb58c2f6d34dd98e3dc2dd023a259ff501643.tar.bz2
samba-a47cb58c2f6d34dd98e3dc2dd023a259ff501643.zip
r6184: the beginnings of the libcli/dgram/ library, and the dgram
server. Currently just listens on port 138 and parses the packets (using IDL like the rest of NBT). This allows me to develop the structures and test with real packets (This used to be commit 10d64a525349ff96695ad961a3cfeb5bc7c8844f)
Diffstat (limited to 'source4/nbt_server/interfaces.c')
-rw-r--r--source4/nbt_server/interfaces.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index bc01ac6d99..dfd4538321 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -63,6 +63,16 @@ static void nbtd_request_handler(struct nbt_name_socket *nbtsock,
}
+/*
+ receive an incoming dgram request
+*/
+static void dgram_request_handler(struct nbt_dgram_socket *dgmsock,
+ struct nbt_dgram_packet *packet,
+ const char *src_address, int src_port)
+{
+}
+
+
/*
find a registered name on an interface
@@ -93,7 +103,6 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
{
struct nbtd_interface *iface;
NTSTATUS status;
- struct nbt_name_socket *bcast_nbtsock;
/*
we actually create two sockets. One listens on the broadcast address
@@ -113,6 +122,10 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
iface->names = NULL;
if (strcmp(netmask, "0.0.0.0") != 0) {
+ struct nbt_name_socket *bcast_nbtsock;
+ struct nbt_dgram_socket *bcast_dgmsock;
+
+ /* listen for broadcasts on port 137 */
bcast_nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
NT_STATUS_HAVE_NO_MEMORY(bcast_nbtsock);
@@ -125,10 +138,26 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
}
nbt_set_incoming_handler(bcast_nbtsock, nbtd_request_handler, iface);
+
+
+ /* listen for broadcasts on port 138 */
+ bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(bcast_dgmsock);
+
+ status = socket_listen(bcast_dgmsock->sock, bcast, lp_dgram_port(), 0, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Failed to bind to %s:%d - %s\n",
+ bcast, lp_dgram_port(), nt_errstr(status)));
+ talloc_free(iface);
+ return status;
+ }
+
+ dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface);
}
+ /* listen for unicasts on port 137 */
iface->nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
- NT_STATUS_HAVE_NO_MEMORY(iface->ip_address);
+ NT_STATUS_HAVE_NO_MEMORY(iface->nbtsock);
status = socket_listen(iface->nbtsock->sock, bind_address, lp_nbt_port(), 0, 0);
if (!NT_STATUS_IS_OK(status)) {
@@ -137,9 +166,22 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
talloc_free(iface);
return status;
}
-
nbt_set_incoming_handler(iface->nbtsock, nbtd_request_handler, iface);
+
+ /* listen for unicasts on port 138 */
+ iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx);
+ NT_STATUS_HAVE_NO_MEMORY(iface->dgmsock);
+
+ status = socket_listen(iface->dgmsock->sock, bind_address, lp_dgram_port(), 0, 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Failed to bind to %s:%d - %s\n",
+ address, lp_dgram_port(), nt_errstr(status)));
+ talloc_free(iface);
+ return status;
+ }
+ dgram_set_incoming_handler(iface->dgmsock, dgram_request_handler, iface);
+
if (strcmp(netmask, "0.0.0.0") == 0) {
DLIST_ADD(nbtsrv->bcast_interface, iface);
} else {