nmbd/nmbd_nodestatus.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    NBT netbios routines and daemon - version 2
00004    Copyright (C) Andrew Tridgell 1994-1998
00005    Copyright (C) Luke Kenneth Casson Leighton 1994-1998
00006    Copyright (C) Jeremy Allison 1994-2003
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021    
00022 */
00023 
00024 #include "includes.h"
00025 
00026 /****************************************************************************
00027  Deal with a successful node status response.
00028 ****************************************************************************/
00029 
00030 static void node_status_response(struct subnet_record *subrec,
00031                        struct response_record *rrec, struct packet_struct *p)
00032 {
00033         struct nmb_packet *nmb = &p->packet.nmb;
00034         struct nmb_name *question_name = &rrec->packet->packet.nmb.question.question_name;
00035         struct nmb_name *answer_name = &nmb->answers->rr_name;
00036 
00037         /* Sanity check. Ensure that the answer name in the incoming packet is the
00038                 same as the requested name in the outgoing packet. */
00039 
00040         if(!nmb_name_equal(question_name, answer_name)) {
00041                 DEBUG(0,("node_status_response: Answer name %s differs from question \
00042 name %s.\n", nmb_namestr(answer_name), nmb_namestr(question_name)));
00043                 return;
00044         }
00045 
00046         DEBUG(5,("node_status_response: response from name %s on subnet %s.\n",
00047                 nmb_namestr(answer_name), subrec->subnet_name));
00048 
00049         /* Just send the whole answer resource record for the success function to parse. */
00050         if(rrec->success_fn)
00051                 (*(node_status_success_function)rrec->success_fn)(subrec, rrec->userdata, nmb->answers, p->ip);
00052 
00053         /* Ensure we don't retry. */
00054         remove_response_record(subrec, rrec);
00055 }
00056 
00057 /****************************************************************************
00058  Deal with a timeout when requesting a node status.
00059 ****************************************************************************/
00060 
00061 static void node_status_timeout_response(struct subnet_record *subrec,
00062                        struct response_record *rrec)
00063 {
00064         struct nmb_packet *sent_nmb = &rrec->packet->packet.nmb;
00065         struct nmb_name *question_name = &sent_nmb->question.question_name;
00066 
00067         DEBUG(5,("node_status_timeout_response: failed to get node status from name %s on subnet %s\n",
00068                 nmb_namestr(question_name), subrec->subnet_name));
00069 
00070         if( rrec->fail_fn)
00071                 (*rrec->fail_fn)(subrec, rrec);
00072 
00073         /* Ensure we don't retry. */
00074         remove_response_record(subrec, rrec);
00075 }
00076 
00077 /****************************************************************************
00078  Try and do a node status to a name - given the name & IP address.
00079 ****************************************************************************/
00080  
00081 BOOL node_status(struct subnet_record *subrec, struct nmb_name *nmbname,
00082                  struct in_addr send_ip, node_status_success_function success_fn, 
00083                  node_status_fail_function fail_fn, struct userdata_struct *userdata)
00084 {
00085         if(queue_node_status( subrec, node_status_response, node_status_timeout_response,
00086                                 success_fn, fail_fn, userdata, nmbname, send_ip)==NULL) {
00087                 DEBUG(0,("node_status: Failed to send packet trying to get node status for \
00088 name %s, IP address %s\n", nmb_namestr(nmbname), inet_ntoa(send_ip)));
00089                 return True;
00090         } 
00091         return False;
00092 }

Sambaに対してSat Aug 29 21:23:08 2009に生成されました。  doxygen 1.4.7