LCOV - code coverage report
Current view: top level - source4/torture/nbt - wins.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 262 294 89.1 %
Date: 2024-04-21 15:09:00 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    NBT WINS server testing
       5             : 
       6             :    Copyright (C) Andrew Tridgell 2005
       7             :    
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             :    
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             :    
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : #include "includes.h"
      23             : #include "lib/util/dlinklist.h"
      24             : #include "lib/events/events.h"
      25             : #include "lib/socket/socket.h"
      26             : #include "libcli/resolve/resolve.h"
      27             : #include "system/network.h"
      28             : #include "lib/socket/netif.h"
      29             : #include "librpc/gen_ndr/ndr_nbt.h"
      30             : #include "torture/torture.h"
      31             : #include "torture/nbt/proto.h"
      32             : #include "param/param.h"
      33             : 
      34             : #define CHECK_VALUE(tctx, v, correct) \
      35             :         torture_assert_int_equal(tctx, v, correct, "Incorrect value")
      36             : 
      37             : #define CHECK_STRING(tctx, v, correct) \
      38             :         torture_assert_casestr_equal(tctx, v, correct, "Incorrect value")
      39             : 
      40             : #define CHECK_NAME(tctx, _name, correct) do { \
      41             :         CHECK_STRING(tctx, (_name).name, (correct).name); \
      42             :         CHECK_VALUE(tctx, (uint8_t)(_name).type, (uint8_t)(correct).type); \
      43             :         CHECK_STRING(tctx, (_name).scope, (correct).scope); \
      44             : } while (0)
      45             : 
      46             : 
      47             : /*
      48             :   test operations against a WINS server
      49             : */
      50          18 : static bool nbt_test_wins_name(struct torture_context *tctx, const char *address,
      51             :                                struct nbt_name *name, uint16_t nb_flags,
      52             :                                bool try_low_port,
      53             :                                uint8_t register_rcode)
      54             : {
      55           0 :         struct nbt_name_register_wins io;
      56           0 :         struct nbt_name_register name_register;
      57           0 :         struct nbt_name_query query;
      58           0 :         struct nbt_name_refresh_wins refresh;
      59           0 :         struct nbt_name_release release;
      60           0 :         struct nbt_name_request *req;
      61           0 :         NTSTATUS status;
      62          18 :         struct nbt_name_socket *nbtsock = torture_init_nbt_socket(tctx);
      63           0 :         const char *myaddress;
      64           0 :         struct socket_address *socket_address;
      65           0 :         struct interface *ifaces;
      66          18 :         bool low_port = try_low_port;
      67           0 :         char **l;
      68             : 
      69          18 :         load_interface_list(tctx, tctx->lp_ctx, &ifaces);
      70             : 
      71          18 :         myaddress = talloc_strdup(tctx, iface_list_best_ip(ifaces, address));
      72             : 
      73          18 :         socket_address = socket_address_from_strings(tctx, 
      74          18 :                                                      nbtsock->sock->backend_name,
      75             :                                                      myaddress, lpcfg_nbt_port(tctx->lp_ctx));
      76          18 :         torture_assert(tctx, socket_address != NULL, 
      77             :                                    "Error getting address");
      78             : 
      79             :         /* we do the listen here to ensure the WINS server receives the packets from
      80             :            the right IP */
      81          18 :         status = socket_listen(nbtsock->sock, socket_address, 0, 0);
      82          18 :         talloc_free(socket_address);
      83          18 :         if (!NT_STATUS_IS_OK(status)) {
      84           0 :                 low_port = false;
      85           0 :                 socket_address = socket_address_from_strings(tctx,
      86           0 :                                                              nbtsock->sock->backend_name,
      87             :                                                              myaddress, 0);
      88           0 :                 torture_assert(tctx, socket_address != NULL,
      89             :                                "Error getting address");
      90             : 
      91           0 :                 status = socket_listen(nbtsock->sock, socket_address, 0, 0);
      92           0 :                 talloc_free(socket_address);
      93           0 :                 torture_assert_ntstatus_ok(tctx, status,
      94             :                                            "socket_listen for WINS failed");
      95             :         }
      96             : 
      97          18 :         torture_comment(tctx, "Testing name registration to WINS with name %s at %s nb_flags=0x%x\n", 
      98             :                nbt_name_string(tctx, name), myaddress, nb_flags);
      99             : 
     100          18 :         torture_comment(tctx, "release the name\n");
     101          18 :         release.in.name = *name;
     102          18 :         release.in.dest_port = lpcfg_nbt_port(tctx->lp_ctx);
     103          18 :         release.in.dest_addr = address;
     104          18 :         release.in.address = myaddress;
     105          18 :         release.in.nb_flags = nb_flags;
     106          18 :         release.in.broadcast = false;
     107          18 :         release.in.timeout = 3;
     108          18 :         release.in.retries = 0;
     109             : 
     110          18 :         status = nbt_name_release(nbtsock, tctx, &release);
     111          18 :         torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address));
     112          18 :         CHECK_VALUE(tctx, release.out.rcode, 0);
     113             : 
     114          18 :         if (nb_flags & NBT_NM_GROUP) {
     115             :                 /* ignore this for group names */
     116          14 :         } else if (!low_port) {
     117           9 :                 torture_comment(tctx, "no low port - skip: register the name with a wrong address\n");
     118             :         } else {
     119           5 :                 torture_comment(tctx, "register the name with a wrong address (makes the next request slow!)\n");
     120           5 :                 io.in.name = *name;
     121           5 :                 io.in.wins_port = lpcfg_nbt_port(tctx->lp_ctx);
     122           5 :                 io.in.wins_servers = const_str_list(
     123             :                         str_list_make_single(tctx, address));
     124           5 :                 io.in.addresses = const_str_list(
     125             :                         str_list_make_single(tctx, "127.64.64.1"));
     126           5 :                 io.in.nb_flags = nb_flags;
     127           5 :                 io.in.ttl = 300000;
     128             : 
     129           5 :                 status = nbt_name_register_wins(nbtsock, tctx, &io);
     130           5 :                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     131           0 :                         torture_assert_ntstatus_ok(tctx, status,
     132             :                                 talloc_asprintf(tctx, "No response from %s for name register\n",
     133             :                                                 address));
     134             :                 }
     135           5 :                 torture_assert_ntstatus_ok(tctx, status,
     136             :                         talloc_asprintf(tctx, "Bad response from %s for name register\n",
     137             :                                         address));
     138             : 
     139           5 :                 CHECK_STRING(tctx, io.out.wins_server, address);
     140           5 :                 CHECK_VALUE(tctx, io.out.rcode, 0);
     141             : 
     142           5 :                 torture_comment(tctx, "register the name correct address\n");
     143           5 :                 name_register.in.name           = *name;
     144           5 :                 name_register.in.dest_port      = lpcfg_nbt_port(tctx->lp_ctx);
     145           5 :                 name_register.in.dest_addr      = address;
     146           5 :                 name_register.in.address        = myaddress;
     147           5 :                 name_register.in.nb_flags       = nb_flags;
     148           5 :                 name_register.in.register_demand= false;
     149           5 :                 name_register.in.broadcast      = false;
     150           5 :                 name_register.in.multi_homed    = true;
     151           5 :                 name_register.in.ttl            = 300000;
     152           5 :                 name_register.in.timeout        = 3;
     153           5 :                 name_register.in.retries        = 2;
     154             : 
     155             :                 /*
     156             :                  * test if the server ignores resent requests
     157             :                  */
     158           5 :                 req = nbt_name_register_send(nbtsock, &name_register);
     159           0 :                 while (true) {
     160          10 :                         tevent_loop_once(nbtsock->event_ctx);
     161          10 :                         if (req->state != NBT_REQUEST_WAIT) {
     162           0 :                                 break;
     163             :                         }
     164          10 :                         if (req->received_wack) {
     165             :                                 /*
     166             :                                  * if we received the wack response
     167             :                                  * we resend the request and the
     168             :                                  * server should ignore that
     169             :                                  * and not handle it as new request
     170             :                                  */
     171           5 :                                 req->state = NBT_REQUEST_SEND;
     172           5 :                                 DLIST_ADD_END(nbtsock->send_queue, req);
     173           5 :                                 TEVENT_FD_WRITEABLE(nbtsock->fde);
     174           5 :                                 break;
     175             :                         }
     176             :                 }
     177             : 
     178           5 :                 status = nbt_name_register_recv(req, tctx, &name_register);
     179           5 :                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     180           0 :                         torture_assert_ntstatus_ok(tctx, status,
     181             :                                 talloc_asprintf(tctx, "No response from %s for name register\n",
     182             :                                                 address));
     183             :                 }
     184           5 :                 torture_assert_ntstatus_ok(tctx, status,
     185             :                         talloc_asprintf(tctx, "Bad response from %s for name register\n",
     186             :                                         address));
     187             : 
     188           5 :                 CHECK_VALUE(tctx, name_register.out.rcode, 0);
     189           5 :                 CHECK_STRING(tctx, name_register.out.reply_addr, myaddress);
     190             :         }
     191             : 
     192          18 :         torture_comment(tctx, "register the name correct address\n");
     193          18 :         io.in.name = *name;
     194          18 :         io.in.wins_port = lpcfg_nbt_port(tctx->lp_ctx);
     195          18 :         l = str_list_make_single(tctx, address);
     196          18 :         io.in.wins_servers = discard_const_p(const char *, l);
     197          18 :         l = str_list_make_single(tctx, myaddress);
     198          18 :         io.in.addresses = discard_const_p(const char *, l);
     199          18 :         io.in.nb_flags = nb_flags;
     200          18 :         io.in.ttl = 300000;
     201             :         
     202          18 :         status = nbt_name_register_wins(nbtsock, tctx, &io);
     203          18 :         torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name register", address));
     204             :         
     205          18 :         CHECK_STRING(tctx, io.out.wins_server, address);
     206          18 :         CHECK_VALUE(tctx, io.out.rcode, register_rcode);
     207             : 
     208          18 :         if (register_rcode != NBT_RCODE_OK) {
     209           1 :                 return true;
     210             :         }
     211             : 
     212          17 :         if (name->type != NBT_NAME_MASTER &&
     213          15 :             name->type != NBT_NAME_LOGON && 
     214          14 :             name->type != NBT_NAME_BROWSER && 
     215             :             (nb_flags & NBT_NM_GROUP)) {
     216           1 :                 torture_comment(tctx, "Try to register as non-group\n");
     217           1 :                 io.in.nb_flags &= ~NBT_NM_GROUP;
     218           1 :                 status = nbt_name_register_wins(nbtsock, tctx, &io);
     219           1 :                 torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name register\n",
     220             :                         address));
     221           1 :                 CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT);
     222             :         }
     223             : 
     224          17 :         torture_comment(tctx, "query the name to make sure its there\n");
     225          17 :         query.in.name = *name;
     226          17 :         query.in.dest_addr = address;
     227          17 :         query.in.dest_port = lpcfg_nbt_port(tctx->lp_ctx);
     228          17 :         query.in.broadcast = false;
     229          17 :         query.in.wins_lookup = true;
     230          17 :         query.in.timeout = 3;
     231          17 :         query.in.retries = 0;
     232             : 
     233          17 :         status = nbt_name_query(nbtsock, tctx, &query);
     234          17 :         if (name->type == NBT_NAME_MASTER) {
     235           2 :                 torture_assert_ntstatus_equal(
     236             :                           tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, 
     237             :                           talloc_asprintf(tctx, "Bad response from %s for name query", address));
     238           2 :                 return true;
     239             :         }
     240          15 :         torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address));
     241             :         
     242          15 :         CHECK_NAME(tctx, query.out.name, *name);
     243          15 :         CHECK_VALUE(tctx, query.out.num_addrs, 1);
     244          15 :         if (name->type != NBT_NAME_LOGON &&
     245             :             (nb_flags & NBT_NM_GROUP)) {
     246           2 :                 CHECK_STRING(tctx, query.out.reply_addrs[0], "255.255.255.255");
     247             :         } else {
     248          13 :                 CHECK_STRING(tctx, query.out.reply_addrs[0], myaddress);
     249             :         }
     250             : 
     251             : 
     252          15 :         query.in.name.name = strupper_talloc(tctx, name->name);
     253          15 :         if (query.in.name.name &&
     254          13 :             strcmp(query.in.name.name, name->name) != 0) {
     255           1 :                 torture_comment(tctx, "check case sensitivity\n");
     256           1 :                 status = nbt_name_query(nbtsock, tctx, &query);
     257           1 :                 torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, talloc_asprintf(tctx, "Bad response from %s for name query", address));
     258             :         }
     259             : 
     260          15 :         query.in.name = *name;
     261          15 :         if (name->scope) {
     262           8 :                 query.in.name.scope = strupper_talloc(tctx, name->scope);
     263             :         }
     264          15 :         if (query.in.name.scope &&
     265           8 :             strcmp(query.in.name.scope, name->scope) != 0) {
     266           7 :                 torture_comment(tctx, "check case sensitivity on scope\n");
     267           7 :                 status = nbt_name_query(nbtsock, tctx, &query);
     268           7 :                 torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, talloc_asprintf(tctx, "Bad response from %s for name query", address));
     269             :         }
     270             : 
     271          15 :         torture_comment(tctx, "refresh the name\n");
     272          15 :         refresh.in.name = *name;
     273          15 :         refresh.in.wins_port = lpcfg_nbt_port(tctx->lp_ctx);
     274          15 :         l = str_list_make_single(tctx, address);
     275          15 :         refresh.in.wins_servers = discard_const_p(const char *, l);
     276          15 :         l = str_list_make_single(tctx, myaddress);
     277          15 :         refresh.in.addresses = discard_const_p(const char *, l);
     278          15 :         refresh.in.nb_flags = nb_flags;
     279          15 :         refresh.in.ttl = 12345;
     280             :         
     281          15 :         status = nbt_name_refresh_wins(nbtsock, tctx, &refresh);
     282          15 :         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     283           0 :                 torture_assert_ntstatus_ok(tctx, status,
     284             :                         talloc_asprintf(tctx, "No response from %s for name refresh",
     285             :                                         address));
     286             :         }
     287          15 :         torture_assert_ntstatus_ok(tctx, status,
     288             :                 talloc_asprintf(tctx, "Bad response from %s for name refresh",
     289             :                                 address));
     290             : 
     291          15 :         CHECK_STRING(tctx, refresh.out.wins_server, address);
     292          15 :         CHECK_VALUE(tctx, refresh.out.rcode, 0);
     293             : 
     294          15 :         printf("release the name\n");
     295          15 :         release.in.name = *name;
     296          15 :         release.in.dest_port = lpcfg_nbt_port(tctx->lp_ctx);
     297          15 :         release.in.dest_addr = address;
     298          15 :         release.in.address = myaddress;
     299          15 :         release.in.nb_flags = nb_flags;
     300          15 :         release.in.broadcast = false;
     301          15 :         release.in.timeout = 3;
     302          15 :         release.in.retries = 0;
     303             : 
     304          15 :         status = nbt_name_release(nbtsock, tctx, &release);
     305          15 :         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     306           0 :                 torture_assert_ntstatus_ok(tctx, status,
     307             :                         talloc_asprintf(tctx, "No response from %s for name release",
     308             :                                         address));
     309             :         }
     310          15 :         torture_assert_ntstatus_ok(tctx, status,
     311             :                 talloc_asprintf(tctx, "Bad response from %s for name release",
     312             :                                 address));
     313             : 
     314          15 :         CHECK_NAME(tctx, release.out.name, *name);
     315          15 :         CHECK_VALUE(tctx, release.out.rcode, 0);
     316             : 
     317          15 :         if (nb_flags & NBT_NM_GROUP) {
     318             :                 /* ignore this for group names */
     319          12 :         } else if (!low_port) {
     320           7 :                 torture_comment(tctx, "no low port - skip: register the name with a wrong address\n");
     321             :         } else {
     322           5 :                 torture_comment(tctx, "register the name with a wrong address (makes the next request slow!)\n");
     323           5 :                 io.in.name = *name;
     324           5 :                 io.in.wins_port = lpcfg_nbt_port(tctx->lp_ctx);
     325           5 :                 io.in.wins_servers = const_str_list(
     326             :                         str_list_make_single(tctx, address));
     327           5 :                 io.in.addresses = const_str_list(
     328             :                         str_list_make_single(tctx, "127.64.64.1"));
     329           5 :                 io.in.nb_flags = nb_flags;
     330           5 :                 io.in.ttl = 300000;
     331             :         
     332           5 :                 status = nbt_name_register_wins(nbtsock, tctx, &io);
     333           5 :                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     334           0 :                         torture_assert_ntstatus_ok(tctx, status,
     335             :                                 talloc_asprintf(tctx, "No response from %s for name register\n",
     336             :                                                 address));
     337             :                 }
     338           5 :                 torture_assert_ntstatus_ok(tctx, status,
     339             :                         talloc_asprintf(tctx, "Bad response from %s for name register\n",
     340             :                                         address));
     341             : 
     342           5 :                 CHECK_STRING(tctx, io.out.wins_server, address);
     343           5 :                 CHECK_VALUE(tctx, io.out.rcode, 0);
     344             :         }
     345             : 
     346          15 :         torture_comment(tctx, "refresh the name with the correct address\n");
     347          15 :         refresh.in.name = *name;
     348          15 :         refresh.in.wins_port = lpcfg_nbt_port(tctx->lp_ctx);
     349          15 :         refresh.in.wins_servers = const_str_list(
     350             :                         str_list_make_single(tctx, address));
     351          15 :         refresh.in.addresses = const_str_list(
     352             :                         str_list_make_single(tctx, myaddress));
     353          15 :         refresh.in.nb_flags = nb_flags;
     354          15 :         refresh.in.ttl = 12345;
     355             : 
     356          15 :         status = nbt_name_refresh_wins(nbtsock, tctx, &refresh);
     357          15 :         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
     358           0 :                 torture_assert_ntstatus_ok(tctx, status,
     359             :                         talloc_asprintf(tctx, "No response from %s for name refresh",
     360             :                                         address));
     361             :         }
     362          15 :         torture_assert_ntstatus_ok(tctx, status,
     363             :                 talloc_asprintf(tctx, "Bad response from %s for name refresh",
     364             :                                 address));
     365             : 
     366          15 :         CHECK_STRING(tctx, refresh.out.wins_server, address);
     367          15 :         CHECK_VALUE(tctx, refresh.out.rcode, 0);
     368             : 
     369          15 :         torture_comment(tctx, "release the name\n");
     370          15 :         release.in.name = *name;
     371          15 :         release.in.dest_port = lpcfg_nbt_port(tctx->lp_ctx);
     372          15 :         release.in.dest_addr = address;
     373          15 :         release.in.address = myaddress;
     374          15 :         release.in.nb_flags = nb_flags;
     375          15 :         release.in.broadcast = false;
     376          15 :         release.in.timeout = 3;
     377          15 :         release.in.retries = 0;
     378             : 
     379          15 :         status = nbt_name_release(nbtsock, tctx, &release);
     380          15 :         torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address));
     381             :         
     382          15 :         CHECK_NAME(tctx, release.out.name, *name);
     383          15 :         CHECK_VALUE(tctx, release.out.rcode, 0);
     384             : 
     385          15 :         torture_comment(tctx, "release again\n");
     386          15 :         status = nbt_name_release(nbtsock, tctx, &release);
     387          15 :         torture_assert_ntstatus_ok(tctx, status, 
     388             :                                 talloc_asprintf(tctx, "Bad response from %s for name query",
     389             :                        address));
     390             :         
     391          15 :         CHECK_NAME(tctx, release.out.name, *name);
     392          15 :         CHECK_VALUE(tctx, release.out.rcode, 0);
     393             : 
     394             : 
     395          15 :         torture_comment(tctx, "query the name to make sure its gone\n");
     396          15 :         query.in.name = *name;
     397          15 :         status = nbt_name_query(nbtsock, tctx, &query);
     398          15 :         if (name->type != NBT_NAME_LOGON &&
     399             :             (nb_flags & NBT_NM_GROUP)) {
     400           2 :                 torture_assert_ntstatus_ok(tctx, status, 
     401             :                                 "ERROR: Name query failed after group release");
     402             :         } else {
     403          13 :                 torture_assert_ntstatus_equal(tctx, status, 
     404             :                                                                           NT_STATUS_OBJECT_NAME_NOT_FOUND,
     405             :                                 "Incorrect response to name query");
     406             :         }
     407             :         
     408          15 :         return true;
     409             : }
     410             : 
     411             : 
     412           2 : static char *test_nbt_wins_scope_string(TALLOC_CTX *mem_ctx, uint8_t count)
     413             : {
     414           0 :         char *res;
     415           0 :         uint8_t i;
     416             : 
     417           2 :         res = talloc_array(mem_ctx, char, count+1);
     418           2 :         if (res == NULL) {
     419           0 :                 return NULL;
     420             :         }
     421             : 
     422         477 :         for (i=0; i < count; i++) {
     423         475 :                 switch (i) {
     424           6 :                 case 63:
     425             :                 case 63 + 1 + 63:
     426             :                 case 63 + 1 + 63 + 1 + 63:
     427           6 :                         res[i] = '.';
     428           6 :                         break;
     429         469 :                 default:
     430         469 :                         res[i] = '0' + (i%10);
     431         469 :                         break;
     432             :                 }
     433             :         }
     434             : 
     435           2 :         res[count] = '\0';
     436             : 
     437           2 :         talloc_set_name_const(res, res);
     438             : 
     439           2 :         return res;
     440             : }
     441             : 
     442             : /*
     443             :   test operations against a WINS server
     444             : */
     445           1 : static bool nbt_test_wins(struct torture_context *tctx)
     446             : {
     447           0 :         struct nbt_name name;
     448           1 :         uint32_t r = (uint32_t)(random() % (100000));
     449           0 :         const char *address;
     450           1 :         bool ret = true;
     451             : 
     452           1 :         if (!torture_nbt_get_name(tctx, &name, &address))
     453           0 :                 return false;
     454             : 
     455           1 :         name.name = talloc_asprintf(tctx, "_TORTURE-%5u", r);
     456             : 
     457           1 :         name.type = NBT_NAME_CLIENT;
     458           1 :         name.scope = NULL;
     459           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     460             :                                   NBT_NODE_H, true, NBT_RCODE_OK);
     461             : 
     462           1 :         name.type = NBT_NAME_MASTER;
     463           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     464             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     465             : 
     466           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     467             :                                   NBT_NODE_H | NBT_NM_GROUP, false, NBT_RCODE_OK);
     468             : 
     469           1 :         name.type = NBT_NAME_SERVER;
     470           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     471             :                                   NBT_NODE_H, true, NBT_RCODE_OK);
     472             : 
     473           1 :         name.type = NBT_NAME_LOGON;
     474           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     475             :                                   NBT_NODE_H | NBT_NM_GROUP, false, NBT_RCODE_OK);
     476             : 
     477           1 :         name.type = NBT_NAME_BROWSER;
     478           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     479             :                                   NBT_NODE_H | NBT_NM_GROUP, false, NBT_RCODE_OK);
     480             : 
     481           1 :         name.type = NBT_NAME_PDC;
     482           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     483             :                                   NBT_NODE_H, true, NBT_RCODE_OK);
     484             : 
     485           1 :         name.type = 0xBF;
     486           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     487             :                                   NBT_NODE_H, true, NBT_RCODE_OK);
     488             : 
     489           1 :         name.type = 0xBE;
     490           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     491             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     492             : 
     493           1 :         name.scope = "example";
     494           1 :         name.type = 0x72;
     495           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     496             :                                   NBT_NODE_H, true, NBT_RCODE_OK);
     497             : 
     498           1 :         name.scope = "example";
     499           1 :         name.type = 0x71;
     500           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     501             :                                   NBT_NODE_H | NBT_NM_GROUP, false, NBT_RCODE_OK);
     502             : 
     503           1 :         name.scope = "foo.example.com";
     504           1 :         name.type = 0x72;
     505           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     506             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     507             : 
     508           1 :         name.name = talloc_asprintf(tctx, "_T\01-%5u.foo", r);
     509           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     510             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     511             : 
     512           1 :         name.name = "";
     513           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     514             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     515             : 
     516           1 :         name.name = talloc_asprintf(tctx, ".");
     517           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     518             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     519             : 
     520           1 :         name.name = talloc_asprintf(tctx, "%5u-\377\200\300FOO", r);
     521           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     522             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     523             : 
     524           1 :         name.scope = test_nbt_wins_scope_string(tctx, 237);
     525           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     526             :                                   NBT_NODE_H, false, NBT_RCODE_OK);
     527             : 
     528           1 :         name.scope = test_nbt_wins_scope_string(tctx, 238);
     529           1 :         ret &= nbt_test_wins_name(tctx, address, &name,
     530             :                                   NBT_NODE_H, false, NBT_RCODE_SVR);
     531             : 
     532           1 :         return ret;
     533             : }
     534             : 
     535             : /*
     536             :   test WINS operations
     537             : */
     538        2354 : struct torture_suite *torture_nbt_wins(TALLOC_CTX *mem_ctx)
     539             : {
     540        2354 :         struct torture_suite *suite = torture_suite_create(mem_ctx, "wins");
     541             : 
     542        2354 :         torture_suite_add_simple_test(suite, "wins", nbt_test_wins);
     543             : 
     544        2354 :         return suite;
     545             : }

Generated by: LCOV version 1.14