Unix SMB/Netbios implementation.
Version 1.9.
NBT netbios header - version 2
- Copyright (C) Andrew Tridgell 1994-1995
+ Copyright (C) Andrew Tridgell 1994-1997
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#define NB_ACTIVE 0x04
#define NB_CONFL 0x08
#define NB_DEREG 0x10
-#define NB_BFLAG 0x00
-#define NB_PFLAG 0x20
-#define NB_MFLAG 0x40
-#define NB__FLAG 0x60
+#define NB_BFLAG 0x00 /* broadcast node type */
+#define NB_PFLAG 0x20 /* point-to-point node type */
+#define NB_MFLAG 0x40 /* mixed bcast & p-p node type */
+#define NB_HFLAG 0x60 /* microsoft 'hybrid' node type */
#define NB_FLGMSK 0x60
#define REFRESH_TIME (15*60)
#define NAME_BFLAG(p) (((p) & NB_FLGMSK) == NB_BFLAG)
#define NAME_PFLAG(p) (((p) & NB_FLGMSK) == NB_PFLAG)
#define NAME_MFLAG(p) (((p) & NB_FLGMSK) == NB_MFLAG)
-#define NAME__FLAG(p) (((p) & NB_FLGMSK) == NB__FLAG)
+#define NAME_HFLAG(p) (((p) & NB_FLGMSK) == NB_HFLAG)
/* server type identifiers */
#define AM_MASTER(work) (work->ServerType & SV_TYPE_MASTER_BROWSER)
#define AM_BACKUP(work) (work->ServerType & SV_TYPE_BACKUP_BROWSER)
-#define AM_DOMCTL(work) (work->ServerType & SV_TYPE_DOMAIN_CTRL)
+#define AM_DOMMST(work) (work->ServerType & SV_TYPE_DOMAIN_MASTER)
+#define AM_DOMMEM(work) (work->ServerType & SV_TYPE_DOMAIN_MEMBER)
/* microsoft browser NetBIOS name */
#define MSBROWSE "\001\002__MSBROWSE__\002"
/* mail slots */
#define BROWSE_MAILSLOT "\\MAILSLOT\\BROWSE"
#define NET_LOGON_MAILSLOT "\\MAILSLOT\\NET\\NETLOGON"
+#define NT_LOGON_MAILSLOT "\\MAILSLOT\\NET\\NTLOGON"
enum name_source {STATUS_QUERY, LMHOSTS, REGISTER, SELF, DNS, DNSFAIL};
enum node_type {B_NODE=0, P_NODE=1, M_NODE=2, NBDD_NODE=3};
enum packet_type {NMB_PACKET, DGRAM_PACKET};
+
enum master_state
{
- MST_NONE,
- MST_WON,
+ MST_POTENTIAL,
+ MST_BACK,
MST_MSB,
- MST_BROWSER,
- MST_DOMAIN_NONE,
- MST_DOMAIN_MEM,
- MST_DOMAIN_TST,
- MST_DOMAIN
+ MST_BROWSER
+};
+
+enum domain_state
+{
+ DOMAIN_NONE,
+ DOMAIN_WAIT,
+ DOMAIN_MST
+};
+
+enum logon_state
+{
+ LOGON_NONE,
+ LOGON_WAIT,
+ LOGON_SRV
};
enum state_type
{
- NAME_STATUS_PDC_SRV_CHK,
+ NAME_STATUS_DOM_SRV_CHK,
NAME_STATUS_SRV_CHK,
NAME_REGISTER_CHALLENGE,
NAME_REGISTER,
NAME_RELEASE,
NAME_QUERY_CONFIRM,
- NAME_QUERY_SYNC,
- NAME_QUERY_PDC_SRV_CHK,
+ NAME_QUERY_SYNC_LOCAL,
+ NAME_QUERY_SYNC_REMOTE,
+ NAME_QUERY_DOM_SRV_CHK,
NAME_QUERY_SRV_CHK,
NAME_QUERY_FIND_MST,
- NAME_QUERY_MST_CHK
+ NAME_QUERY_MST_CHK,
+ NAME_QUERY_DOMAIN
};
/* a netbios name structure */
int name_type;
};
+/* a netbios flags + ip address structure */
+/* this is used for multi-homed systems and for internet group names */
+struct nmb_ip
+{
+ struct in_addr ip; /* ip address of host that owns this name */
+ uint16 nb_flags; /* netbios flags */
+};
+
/* this is the structure used for the local netbios name list */
struct name_record
{
struct name_record *prev;
struct nmb_name name; /* the netbios name */
- struct in_addr ip; /* ip address of host that owns this name */
- int nb_flags; /* netbios flags */
+ struct nmb_ip *ip_flgs; /* the ip + flags */
+ int num_ips; /* number of ip+flags entries */
enum name_source source; /* where the name came from */
time_t refresh_time; /* time record should be refreshed */
};
+struct subnet_record;
+
/* browse and backup server cache for synchronising browse list */
struct browse_cache_record
{
struct in_addr ip;
time_t sync_time;
BOOL synced;
+ BOOL local;
+ struct subnet_record *subnet;
};
/* this is used to hold the list of servers in my domain, and is */
struct server_record *serverlist;
- /* stage of development from non-master to master browser / domain master */
- enum master_state state;
+ /* stage of development from non-local-master up to local-master browser */
+ enum master_state mst_state;
+
+ /* stage of development from non-domain-master to domain master browser */
+ enum domain_state dom_state;
+
+ /* stage of development from non-logon-server to logon server */
+ enum logon_state log_state;
/* work group info */
fstring work_group;
};
/* initiated name queries recorded in this list to track any responses... */
+/* sadly, we need to group everything together. i suppose that if this
+ gets unwieldy, then a union ought to be considered. oh for c++... */
struct response_record
{
struct response_record *next;
int nb_flags;
time_t ttl;
+ int server_type;
+ fstring my_name;
+ fstring my_comment;
+
BOOL bcast;
BOOL recurse;
struct in_addr send_ip;
struct in_addr bcast_ip;
struct in_addr mask_ip;
struct in_addr myip;
-
- BOOL my_interface;
};
/* a resource record */
} packet;
};
+/* NETLOGON opcodes */
+#define QUERYFORPDC 7 /* Query for PDC */
+#define QUERYFORPDC_R 12 /* Response to Query for PDC */
+#define SAMLOGON 18
+#define SAMLOGON_R 19
+
/* ids for netbios packet types */
#define ANN_HostAnnouncement 1
/* broadcast packet announcement intervals, in minutes */
+/* attempt to add domain logon and domain master names */
+#define CHECK_TIME_ADD_DOM_NAMES 5
+
/* search for master browsers of workgroups samba knows about,
except default */
#define CHECK_TIME_MST_BROWSE 5
/* announce as master to WINS server and any Primary Domain Controllers */
#define CHECK_TIME_MST_ANNOUNCE 15
+/* do all remote announcements this often */
+#define REMOTE_ANNOUNCE_INTERVAL 180
+
+/* Types of machine we can announce as */
+#define ANNOUNCE_AS_NT 1
+#define ANNOUNCE_AS_WIN95 2
+#define ANNOUNCE_AS_WFW 3
+
+/* Macro's to enumerate subnets either with or without
+ the WINS subnet. */
+
+extern struct subnet_record *subnetlist;
+extern struct subnet_record *wins_subnet;
+
+#define FIRST_SUBNET subnetlist
+#define NEXT_SUBNET_EXCLUDING_WINS(x) ((x)->next)
+#define NEXT_SUBNET_INCLUDING_WINS(x) ( ((x) == wins_subnet) ? NULL : \
+ (((x)->next == NULL) ? wins_subnet : \
+ (x)->next))
+