r5118: added support for node status replies in nbtd. nmblookup -S now works against...
[samba.git] / source / librpc / idl / nbt.idl
1 #include "idl_types.h"
2
3 /*
4    IDL structures for NBT operations
5
6    NBT is not traditionally encoded using IDL/NDR. This is a bit of an
7    experiment, and I may well switch us back to a more traditional
8    encoding if it doesn't work out
9 */
10
11 interface nbt
12 {
13         const int NBT_NAME_SERVICE_PORT  = 137;
14         const int NBT_DGRAM_SERVICE_PORT = 138;
15
16         typedef [bitmap16bit] bitmap {
17                 NBT_RCODE                   = 0x000F,
18                 NBT_FLAG_BROADCAST          = 0x0010,
19                 NBT_FLAG_RECURSION_AVAIL    = 0x0080,
20                 NBT_FLAG_RECURSION_DESIRED  = 0x0100,
21                 NBT_FLAG_TRUNCATION         = 0x0200,
22                 NBT_FLAG_AUTHORITIVE        = 0x0400,
23                 NBT_OPCODE                  = 0x7800,
24                 NBT_FLAG_REPLY              = 0x8000
25         } nbt_operation;
26
27         /* the opcodes are in the operation field, masked with
28            NBT_OPCODE */
29         const int NBT_OPCODE_QUERY          =  (0<<11);
30         const int NBT_OPCODE_REGISTER       =  (5<<11);
31         const int NBT_OPCODE_RELEASE        =  (6<<11);
32         const int NBT_OPCODE_WACK           =  (7<<11);
33         const int NBT_OPCODE_REFRESH        =  (8<<11);
34
35         /* rcode values */
36         typedef enum {
37                 NBT_RCODE_FMT = 0x1,
38                 NBT_RCODE_SVR = 0x2,
39                 NBT_RCODE_NAM = 0x3,
40                 NBT_RCODE_IMP = 0x4,
41                 NBT_RCODE_RFS = 0x5,
42                 NBT_RCODE_ACT = 0x6,
43                 NBT_RCODE_CFT = 0x7
44         } nbt_rcode;
45
46         /* we support any 8bit name type, but by defining the common
47            ones here we get better debug displays */
48         typedef [enum8bit] enum {
49                 NBT_NAME_CLIENT   = 0x00,
50                 NBT_NAME_MS       = 0x01,
51                 NBT_NAME_USER     = 0x03,
52                 NBT_NAME_SERVER   = 0x20,
53                 NBT_NAME_PDC      = 0x1B,
54                 NBT_NAME_LOGON    = 0x1C,
55                 NBT_NAME_MASTER   = 0x1D,
56                 NBT_NAME_BROWSER  = 0x1E
57         } nbt_name_type;
58
59         /* the ndr parser for nbt_name is separately defined in
60            nbtname.c */
61         typedef [nopull,nopush] struct {
62                 string        name;
63                 string        scope;
64                 nbt_name_type type;
65         } nbt_name;
66
67         typedef [enum16bit] enum {
68                 NBT_QCLASS_IP = 0x01
69         } nbt_qclass;
70
71         typedef [enum16bit] enum {
72                 NBT_QTYPE_ADDRESS     = 0x0001,
73                 NBT_QTYPE_NAMESERVICE = 0x0002,
74                 NBT_QTYPE_NULL        = 0x000A,
75                 NBT_QTYPE_NETBIOS     = 0x0020,
76                 NBT_QTYPE_STATUS      = 0x0021
77         } nbt_qtype;
78
79         typedef struct {
80                 nbt_name   name;
81                 nbt_qtype  question_type;
82                 nbt_qclass question_class;
83         } nbt_name_question;
84
85         /* these are the possible values of the NBT_NM_OWNER_TYPE
86            field */
87         typedef enum {
88                 NBT_NODE_B = 0x0000,
89                 NBT_NODE_P = 0x2000,
90                 NBT_NODE_M = 0x4000,
91                 NBT_NODE_H = 0x6000
92         } nbt_node_type;
93
94         typedef [bitmap16bit] bitmap {
95                 NBT_NM_PERMANENT        = 0x0200,
96                 NBT_NM_ACTIVE           = 0x0400,
97                 NBT_NM_CONFLICT         = 0x0800,
98                 NBT_NM_DEREGISTER       = 0x1000,
99                 NBT_NM_OWNER_TYPE       = 0x6000,
100                 NBT_NM_GROUP            = 0x8000
101         } nb_flags;
102
103         typedef struct {
104                 nb_flags nb_flags;
105                 uint32   ipaddr;
106         } nbt_rdata_address;
107
108         typedef struct {
109                 uint16 length;
110                 nbt_rdata_address addresses[length/6];
111         } nbt_rdata_netbios;
112
113         typedef struct {
114                 uint8 unit_id[6];
115                 uint8 jumpers;
116                 uint8 test_result;
117                 uint16 version_number;
118                 uint16 period_of_statistics;
119                 uint16 number_of_crcs;
120                 uint16 number_alignment_errors;
121                 uint16 number_of_collisions;
122                 uint16 number_send_aborts;
123                 uint32 number_good_sends;
124                 uint32 number_good_receives;
125                 uint16 number_retransmits;
126                 uint16 number_no_resource_conditions;
127                 uint16 number_free_command_blocks;
128                 uint16 total_number_command_blocks;
129                 uint16 max_total_number_command_blocks;
130                 uint16 number_pending_sessions;
131                 uint16 max_number_pending_sessions;
132                 uint16 max_total_sessions_possible;
133                 uint16 session_data_packet_size;
134         } nbt_statistics;
135
136         typedef struct {
137                 astring15 name;
138                 nbt_name_type type;
139                 nb_flags  nb_flags;
140         } nbt_status_name;
141
142         typedef struct {
143                 [value(r->num_names * 18 + 47)] uint16 length;
144                 uint8 num_names;
145                 nbt_status_name names[num_names];
146                 nbt_statistics  statistics;
147         } nbt_rdata_status;
148
149         typedef struct {
150                 uint16 length;
151                 uint8  data[length];
152         } nbt_rdata_data;
153
154         typedef [nodiscriminant] union {
155                 [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
156                 [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status;
157                 [default]                 nbt_rdata_data   data;
158         } nbt_rdata;
159
160         typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
161                 nbt_name   name;
162                 nbt_qtype  rr_type;
163                 nbt_qclass rr_class;
164                 uint32     ttl;
165                 [switch_is(rr_type)] nbt_rdata rdata;
166         } nbt_res_rec;
167
168         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
169                 uint16            name_trn_id;
170                 nbt_operation     operation;
171                 uint16            qdcount;
172                 uint16            ancount;
173                 uint16            nscount;
174                 uint16            arcount;
175                 nbt_name_question questions[qdcount];
176                 nbt_res_rec       answers[ancount];
177                 nbt_res_rec       nsrecs[nscount];
178                 nbt_res_rec       additional[arcount];
179                 [flag(NDR_REMAINING)] DATA_BLOB padding;
180         } nbt_name_packet;
181 }