00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "includes.h"
00025
00026
00027
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
00038
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
00050 if(rrec->success_fn)
00051 (*(node_status_success_function)rrec->success_fn)(subrec, rrec->userdata, nmb->answers, p->ip);
00052
00053
00054 remove_response_record(subrec, rrec);
00055 }
00056
00057
00058
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
00074 remove_response_record(subrec, rrec);
00075 }
00076
00077
00078
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 }