| 1 | #include "idl_types.h"
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | IDL structures for WINS replication protocol (port 42)
|
|---|
| 5 |
|
|---|
| 6 | Note that WINS replication is not traditionally encoded using
|
|---|
| 7 | IDL/NDR
|
|---|
| 8 |
|
|---|
| 9 | Written by Andrew Tridgell <tridge@osdl.org>
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | import "nbt.idl";
|
|---|
| 13 |
|
|---|
| 14 | interface wrepl
|
|---|
| 15 | {
|
|---|
| 16 | const int WINS_REPLICATION_PORT = 42;
|
|---|
| 17 |
|
|---|
| 18 | typedef [flag(NDR_BIG_ENDIAN)] struct {
|
|---|
| 19 | ipv4address owner;
|
|---|
| 20 | ipv4address ip;
|
|---|
| 21 | } wrepl_ip;
|
|---|
| 22 |
|
|---|
| 23 | typedef [flag(NDR_LITTLE_ENDIAN)] struct {
|
|---|
| 24 | uint32 num_ips;
|
|---|
| 25 | wrepl_ip ips[num_ips];
|
|---|
| 26 | } wrepl_address_list;
|
|---|
| 27 |
|
|---|
| 28 | typedef [nodiscriminant] union {
|
|---|
| 29 | [case(0)] ipv4address ip;
|
|---|
| 30 | [case(2)] wrepl_address_list addresses;
|
|---|
| 31 | } wrepl_addresses;
|
|---|
| 32 |
|
|---|
| 33 | typedef [enum8bit] enum {
|
|---|
| 34 | WREPL_TYPE_UNIQUE = 0x0,
|
|---|
| 35 | WREPL_TYPE_GROUP = 0x1,
|
|---|
| 36 | WREPL_TYPE_SGROUP = 0x2,
|
|---|
| 37 | WREPL_TYPE_MHOMED = 0x3
|
|---|
| 38 | } wrepl_name_type;
|
|---|
| 39 |
|
|---|
| 40 | typedef [enum8bit] enum {
|
|---|
| 41 | WREPL_STATE_ACTIVE = 0x0,
|
|---|
| 42 | WREPL_STATE_RELEASED = 0x1,
|
|---|
| 43 | WREPL_STATE_TOMBSTONE = 0x2,
|
|---|
| 44 | WREPL_STATE_RESERVED = 0x3
|
|---|
| 45 | } wrepl_name_state;
|
|---|
| 46 |
|
|---|
| 47 | typedef [enum8bit] enum {
|
|---|
| 48 | WREPL_NODE_B = 0x0,
|
|---|
| 49 | WREPL_NODE_P = 0x1,
|
|---|
| 50 | WREPL_NODE_M = 0x2,
|
|---|
| 51 | WREPL_NODE_H = 0x3
|
|---|
| 52 | } wrepl_name_node;
|
|---|
| 53 |
|
|---|
| 54 | typedef [bitmap32bit] bitmap {
|
|---|
| 55 | WREPL_FLAGS_RECORD_TYPE = 0x00000003,
|
|---|
| 56 | WREPL_FLAGS_RECORD_STATE = 0x0000000C,
|
|---|
| 57 | WREPL_FLAGS_REGISTERED_LOCAL = 0x00000010,
|
|---|
| 58 | WREPL_FLAGS_NODE_TYPE = 0x00000060,
|
|---|
| 59 | WREPL_FLAGS_IS_STATIC = 0x00000080
|
|---|
| 60 | } wrepl_flags;
|
|---|
| 61 |
|
|---|
| 62 | typedef [v1_enum] enum {
|
|---|
| 63 | WREPL_GROUP_FLAG_NO_GROUP = 0x00000000,
|
|---|
| 64 | WREPL_GROUP_FLAG_IS_GROUP = 0x00000001
|
|---|
| 65 | } wrepl_group_flag;
|
|---|
| 66 |
|
|---|
| 67 | #define WREPL_IS_GROUP(flags) (\
|
|---|
| 68 | ((((flags) & WREPL_FLAGS_RECORD_TYPE) == WREPL_TYPE_GROUP)|| \
|
|---|
| 69 | (((flags) & WREPL_FLAGS_RECORD_TYPE) == WREPL_TYPE_SGROUP))\
|
|---|
| 70 | ? WREPL_GROUP_FLAG_IS_GROUP : WREPL_GROUP_FLAG_NO_GROUP)
|
|---|
| 71 |
|
|---|
| 72 | typedef struct {
|
|---|
| 73 | wrepl_nbt_name name;
|
|---|
| 74 | wrepl_flags flags;
|
|---|
| 75 | [flag(NDR_LITTLE_ENDIAN),value(WREPL_IS_GROUP(flags))] wrepl_group_flag is_group;
|
|---|
| 76 | udlongr id;
|
|---|
| 77 | [switch_is(flags & 2)] wrepl_addresses addresses;
|
|---|
| 78 | ipv4address unknown;
|
|---|
| 79 | } wrepl_wins_name;
|
|---|
| 80 |
|
|---|
| 81 | typedef struct {
|
|---|
| 82 | uint32 num_names;
|
|---|
| 83 | wrepl_wins_name names[num_names];
|
|---|
| 84 | } wrepl_send_reply;
|
|---|
| 85 |
|
|---|
| 86 | typedef struct {
|
|---|
| 87 | ipv4address address;
|
|---|
| 88 | udlongr max_version;
|
|---|
| 89 | udlongr min_version;
|
|---|
| 90 | uint32 type;
|
|---|
| 91 | } wrepl_wins_owner;
|
|---|
| 92 |
|
|---|
| 93 | typedef struct {
|
|---|
| 94 | uint32 partner_count;
|
|---|
| 95 | wrepl_wins_owner partners[partner_count];
|
|---|
| 96 | ipv4address initiator;
|
|---|
| 97 | } wrepl_table;
|
|---|
| 98 |
|
|---|
| 99 | typedef [v1_enum] enum {
|
|---|
| 100 | WREPL_REPL_TABLE_QUERY = 0,
|
|---|
| 101 | WREPL_REPL_TABLE_REPLY = 1,
|
|---|
| 102 | WREPL_REPL_SEND_REQUEST = 2,
|
|---|
| 103 | WREPL_REPL_SEND_REPLY = 3,
|
|---|
| 104 | WREPL_REPL_UPDATE = 4,
|
|---|
| 105 | WREPL_REPL_UPDATE2 = 5,
|
|---|
| 106 | WREPL_REPL_INFORM = 8,
|
|---|
| 107 | WREPL_REPL_INFORM2 = 9
|
|---|
| 108 | } wrepl_replication_cmd;
|
|---|
| 109 |
|
|---|
| 110 | typedef [nodiscriminant] union {
|
|---|
| 111 | [case(WREPL_REPL_TABLE_QUERY)] ;
|
|---|
| 112 | [case(WREPL_REPL_TABLE_REPLY)] wrepl_table table;
|
|---|
| 113 | [case(WREPL_REPL_SEND_REQUEST)] wrepl_wins_owner owner;
|
|---|
| 114 | [case(WREPL_REPL_SEND_REPLY)] wrepl_send_reply reply;
|
|---|
| 115 | [case(WREPL_REPL_UPDATE)] wrepl_table table;
|
|---|
| 116 | [case(WREPL_REPL_UPDATE2)] wrepl_table table;
|
|---|
| 117 | [case(WREPL_REPL_INFORM)] wrepl_table table;
|
|---|
| 118 | [case(WREPL_REPL_INFORM2)] wrepl_table table;
|
|---|
| 119 | } wrepl_replication_info;
|
|---|
| 120 |
|
|---|
| 121 | typedef struct {
|
|---|
| 122 | wrepl_replication_cmd command;
|
|---|
| 123 | [switch_is(command)] wrepl_replication_info info;
|
|---|
| 124 | } wrepl_replication;
|
|---|
| 125 |
|
|---|
| 126 | typedef struct {
|
|---|
| 127 | uint32 assoc_ctx;
|
|---|
| 128 | uint16 minor_version;
|
|---|
| 129 | uint16 major_version;
|
|---|
| 130 | } wrepl_start;
|
|---|
| 131 |
|
|---|
| 132 | typedef struct {
|
|---|
| 133 | uint32 reason;
|
|---|
| 134 | } wrepl_stop;
|
|---|
| 135 |
|
|---|
| 136 | typedef [v1_enum] enum {
|
|---|
| 137 | WREPL_START_ASSOCIATION = 0,
|
|---|
| 138 | WREPL_START_ASSOCIATION_REPLY = 1,
|
|---|
| 139 | WREPL_STOP_ASSOCIATION = 2,
|
|---|
| 140 | WREPL_REPLICATION = 3
|
|---|
| 141 | } wrepl_mess_type;
|
|---|
| 142 |
|
|---|
| 143 | typedef [nodiscriminant] union {
|
|---|
| 144 | [case(WREPL_START_ASSOCIATION)] wrepl_start start;
|
|---|
| 145 | [case(WREPL_START_ASSOCIATION_REPLY)] wrepl_start start_reply;
|
|---|
| 146 | [case(WREPL_STOP_ASSOCIATION)] wrepl_stop stop;
|
|---|
| 147 | [case(WREPL_REPLICATION)] wrepl_replication replication;
|
|---|
| 148 | } wrepl_message;
|
|---|
| 149 |
|
|---|
| 150 | /*
|
|---|
| 151 | the opcode appears to be a bitfield, but as far as I can tell
|
|---|
| 152 | you must always set the following bits. Additional bits don't
|
|---|
| 153 | seem to matter. Very strange.
|
|---|
| 154 | */
|
|---|
| 155 | const int WREPL_OPCODE_BITS = 0x7800;
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 | typedef [gensize,flag(NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
|
|---|
| 159 | uint32 opcode;
|
|---|
| 160 | uint32 assoc_ctx;
|
|---|
| 161 | wrepl_mess_type mess_type;
|
|---|
| 162 | [switch_is(mess_type)] wrepl_message message;
|
|---|
| 163 | [flag(NDR_REMAINING)] DATA_BLOB padding;
|
|---|
| 164 | } wrepl_packet;
|
|---|
| 165 |
|
|---|
| 166 | typedef [flag(NDR_BIG_ENDIAN|NDR_PAHEX),public] struct {
|
|---|
| 167 | [value(ndr_size_wrepl_packet(&packet, ndr->iconv_convenience, ndr->flags))] uint32 size;
|
|---|
| 168 | wrepl_packet packet;
|
|---|
| 169 | } wrepl_wrap;
|
|---|
| 170 |
|
|---|
| 171 | void decode_winsrepl(
|
|---|
| 172 | [in] wrepl_wrap p
|
|---|
| 173 | );
|
|---|
| 174 |
|
|---|
| 175 | }
|
|---|