Added explicit examples for veto files.
[Samba/gbeck.git] / source / namelogon.c
blob1c118c854184251361391acaa8d4ab3776117b36
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 NBT netbios routines and daemon - version 2
5 Copyright (C) Andrew Tridgell 1994-1997
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 Revision History:
23 14 jan 96: lkcl@pires.co.uk
24 added multiple workgroup domain master support
28 #include "includes.h"
30 extern int ClientDGRAM;
32 #define TEST_CODE /* want to debug unknown browse packets */
34 extern int DEBUGLEVEL;
36 extern pstring myname;
39 /****************************************************************************
40 process a domain logon packet
42 **************************************************************************/
43 void process_logon_packet(struct packet_struct *p,char *buf,int len)
45 struct dgram_packet *dgram = &p->packet.dgram;
46 char *logname,*q;
47 fstring reply_name;
48 BOOL add_slashes = False;
49 pstring outbuf;
50 int code,reply_code;
51 char unknown_byte = 0;
52 uint16 request_count = 0;
53 uint16 token = 0;
55 if (!lp_domain_logons())
57 DEBUG(3,("No domain logons\n"));
58 return;
62 code = SVAL(buf,0);
63 switch (code)
65 case 0:
67 char *machine = buf+2;
68 char *user = skip_string(machine,1);
69 char *tmp;
70 logname = skip_string(user,1);
71 tmp = skip_string(logname,1);
72 unknown_byte = CVAL(tmp,0);
73 request_count = SVAL(tmp,1);
74 token = SVAL(tmp,3);
76 reply_code = 0x6;
77 strcpy(reply_name,myname);
78 strupper(reply_name);
79 add_slashes = True;
80 DEBUG(3,("Domain login request from %s(%s) user=%s token=%x\n",
81 machine,inet_ntoa(p->ip),user,token));
82 break;
84 case 7:
86 char *machine = buf+2;
87 logname = skip_string(machine,1);
88 token = SVAL(skip_string(logname,1),0);
90 strcpy(reply_name,lp_domain_controller());
91 if (!*reply_name)
93 /* oo! no domain controller. must be us, then */
94 strcpy(reply_name,myname);
95 reply_code = 0xC;
97 else
99 /* refer logon request to the domain controller */
100 reply_code = 0x7;
103 strupper(reply_name);
104 DEBUG(3,("GETDC request from %s(%s), reporting %s 0x%x token=%x\n",
105 machine,inet_ntoa(p->ip), reply_name, reply_code,token));
106 break;
108 default:
110 DEBUG(3,("Unknown domain request %d\n",code));
111 return;
115 bzero(outbuf,sizeof(outbuf));
116 q = outbuf;
117 SSVAL(q,0,reply_code);
118 q += 2;
120 if (token == 0xffff || /* LM 2.0 or later */
121 token == 0xfffe) /* WfWg networking */
123 if (add_slashes)
125 strcpy(q,"\\\\");
126 q += 2;
128 strcpy(q, reply_name);
129 strupper(q);
130 q = skip_string(q,1);
132 if (token == 0xffff) /* LM 2.0 or later */
134 SSVAL(q,0,token);
135 q += 2;
139 SSVAL(q,0,0xFFFF);
140 q += 2;
142 send_mailslot_reply(True, logname,ClientDGRAM,outbuf,PTR_DIFF(q,outbuf),
143 myname,&dgram->source_name.name[0],0x20,0,p->ip,
144 *iface_ip(p->ip));