LCOV - code coverage report
Current view: top level - source4/nbt_server/dgram - browse.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 10 30 33.3 %
Date: 2021-09-23 10:06:22 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /* 
       2             :    Unix SMB/CIFS implementation.
       3             : 
       4             :    NBT datagram browse server
       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 "nbt_server/nbt_server.h"
      24             : #include "lib/socket/socket.h"
      25             : #include "librpc/gen_ndr/ndr_nbt.h"
      26             : #include "nbt_server/dgram/proto.h"
      27             : 
      28           0 : static const char *nbt_browse_opcode_string(enum nbt_browse_opcode r)
      29             : {
      30           0 :         const char *val = NULL;
      31             : 
      32           0 :         switch (r) {
      33           0 :                 case HostAnnouncement: val = "HostAnnouncement"; break;
      34           0 :                 case AnnouncementRequest: val = "AnnouncementRequest"; break;
      35           0 :                 case Election: val = "Election"; break;
      36           0 :                 case GetBackupListReq: val = "GetBackupListReq"; break;
      37           0 :                 case GetBackupListResp: val = "GetBackupListResp"; break;
      38           0 :                 case BecomeBackup: val = "BecomeBackup"; break;
      39           0 :                 case DomainAnnouncement: val = "DomainAnnouncement"; break;
      40           0 :                 case MasterAnnouncement: val = "MasterAnnouncement"; break;
      41           0 :                 case ResetBrowserState: val = "ResetBrowserState"; break;
      42           0 :                 case LocalMasterAnnouncement: val = "LocalMasterAnnouncement"; break;
      43             :         }
      44             : 
      45           0 :         return val;
      46             : }
      47             : 
      48             : /*
      49             :   handle incoming browse mailslot requests
      50             : */
      51         527 : void nbtd_mailslot_browse_handler(struct dgram_mailslot_handler *dgmslot, 
      52             :                                   struct nbt_dgram_packet *packet, 
      53             :                                   struct socket_address *src)
      54             : {
      55         527 :         struct nbt_browse_packet *browse = talloc(dgmslot, struct nbt_browse_packet);
      56         527 :         struct nbt_name *name = &packet->data.msg.dest_name;
      57             :         NTSTATUS status;
      58             : 
      59         527 :         if (browse == NULL) {
      60           0 :                 status = NT_STATUS_INVALID_PARAMETER;
      61           0 :                 goto failed;
      62             :         }
      63             : 
      64         527 :         status = dgram_mailslot_browse_parse(dgmslot, browse, packet, browse);
      65         527 :         if (!NT_STATUS_IS_OK(status)) goto failed;
      66             : 
      67         527 :         DEBUG(4,("Browse %s (Op %d) on '%s' '%s' from %s:%d\n", 
      68             :                 nbt_browse_opcode_string(browse->opcode), browse->opcode,
      69             :                 nbt_name_string(browse, name), dgmslot->mailslot_name,
      70             :                 src->addr, src->port));
      71             : 
      72         527 :         if (DEBUGLEVEL >= 10) {
      73           0 :                 NDR_PRINT_DEBUG(nbt_browse_packet, browse);
      74             :         }
      75             : 
      76         527 :         talloc_free(browse);
      77         527 :         return;
      78             : 
      79           0 : failed:
      80           0 :         DEBUG(2,("nbtd browse handler failed from %s:%d to %s - %s\n",
      81             :                  src->addr, src->port, nbt_name_string(browse, name),
      82             :                  nt_errstr(status)));
      83           0 :         talloc_free(browse);
      84             : 
      85             : }

Generated by: LCOV version 1.13