e12ec6290a865c78299b5f7ca170651de9b60d03
[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_netbios;
107
108
109         typedef struct {
110                 uint8 unit_id[6];
111                 uint8 jumpers;
112                 uint8 test_result;
113                 uint16 version_number;
114                 uint16 period_of_statistics;
115                 uint16 number_of_crcs;
116                 uint16 number_alignment_errors;
117                 uint16 number_of_collisions;
118                 uint16 number_send_aborts;
119                 uint32 number_good_sends;
120                 uint32 number_good_receives;
121                 uint16 number_retransmits;
122                 uint16 number_no_resource_conditions;
123                 uint16 number_free_command_blocks;
124                 uint16 total_number_command_blocks;
125                 uint16 max_total_number_command_blocks;
126                 uint16 number_pending_sessions;
127                 uint16 max_number_pending_sessions;
128                 uint16 max_total_sessions_possible;
129                 uint16 session_data_packet_size;
130         } nbt_statistics;
131
132         typedef struct {
133                 astring15 name;
134                 nbt_name_type type;
135                 nb_flags  nb_flags;
136         } nbt_status_name;
137
138         typedef struct {
139                 uint8 num_names;
140                 nbt_status_name names[num_names];
141                 nbt_statistics  statistics;
142         } nbt_rdata_status;
143
144         typedef struct {
145                 nbt_operation operation;
146         } nbt_rdata_wack;
147
148         typedef [nodiscriminant] union {
149                 [case(NBT_QTYPE_NETBIOS)] nbt_rdata_netbios netbios;
150                 [case(NBT_QTYPE_STATUS)]  nbt_rdata_status status;
151                 [case(NBT_QTYPE_NULL)]    nbt_rdata_wack wack;
152         } nbt_rdata;
153
154         typedef [flag(LIBNDR_PRINT_ARRAY_HEX)] struct {
155                 nbt_name   name;
156                 nbt_qtype  rr_type;
157                 nbt_qclass rr_class;
158                 uint32     ttl;
159                 [subcontext(2),switch_is(rr_type)] nbt_rdata rdata;
160         } nbt_res_rec;
161
162         typedef [flag(NDR_NOALIGN|NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
163                 uint16            name_trn_id;
164                 nbt_operation     operation;
165                 uint16            qdcount;
166                 uint16            ancount;
167                 uint16            nscount;
168                 uint16            arcount;
169                 nbt_name_question questions[qdcount];
170                 nbt_res_rec       answers[ancount];
171                 nbt_res_rec       nsrecs[nscount];
172                 nbt_res_rec       additional[arcount];
173                 [flag(NDR_REMAINING)] DATA_BLOB padding;
174         } nbt_name_packet;
175 }