aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-msnlb.c
blob: 02639c6d9059416e99794f610426a653a9418444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* packet-msnlb.c
 * Routines for MS NLB dissection
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * 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 the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "config.h"

#include <glib.h>
#include <epan/packet.h>
#include <epan/etypes.h>
#include "packet-smb-common.h"

void proto_register_msnlb(void);
void proto_reg_handoff_msnlb(void);

/* Initialize the protocol and registered fields */
static int proto_msnlb = -1;

static int hf_msnlb_unknown = -1;
static int hf_msnlb_hpn = -1;
static int hf_msnlb_cls_virt_ip = -1;
static int hf_msnlb_host_ip = -1;
static int hf_msnlb_count = -1;
static int hf_msnlb_host_name = -1;

/* Initialize the subtree pointers */
static gint ett_msnlb = -1;

/* Code to actually dissect the packets */
static void
dissect_msnlb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  proto_item  *ti;
  proto_tree  *msnlb_tree;
  guint16     offset = 0;

  guint8 type = 0; /* Blatent assumption of name and size */

  col_set_str(pinfo->cinfo, COL_PROTOCOL, "MS NLB");

  col_set_str(pinfo->cinfo, COL_INFO, "MS NLB heartbeat");

  if (tree) {
    ti = proto_tree_add_item(tree, proto_msnlb, tvb, 0, -1, ENC_NA);
    msnlb_tree = proto_item_add_subtree(ti, ett_msnlb);

    type = tvb_get_guint8(tvb, offset);

    proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_hpn, tvb, offset, 4, ENC_LITTLE_ENDIAN);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_cls_virt_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_host_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
    offset += 4;

    proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
    offset += 4;

    switch (type) {
      case 0xc0:
        /*offset =*/ display_unicode_string(tvb, msnlb_tree, offset, hf_msnlb_host_name, NULL);
        break;

      case 0xbf:
        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        offset += 4;

        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, 4, ENC_NA);
        /*offset += 4;*/
        break;

      default:
        proto_tree_add_item(msnlb_tree, hf_msnlb_unknown, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA);
        /*offset += 4;*/
    }
  }
}

void
proto_register_msnlb(void)
{
  static hf_register_info hf[] = {
    { &hf_msnlb_unknown,
      { "Unknown", "msnlb.unknown",
        FT_BYTES, BASE_NONE,
        NULL, 0,
        NULL, HFILL }
    },
    { &hf_msnlb_hpn,
      { "Host Priority Number", "msnlb.hpn",
        FT_UINT32, BASE_DEC,
        NULL, 0,
        NULL, HFILL }
    },
    { &hf_msnlb_host_ip,
      { "Host IP", "msnlb.host_ip",
        FT_IPv4, BASE_NONE,
        NULL, 0,
        "Host IP address", HFILL }
    },
    { &hf_msnlb_cls_virt_ip,
      { "Cluster Virtual IP", "msnlb.cluster_virtual_ip",
        FT_IPv4, BASE_NONE,
        NULL, 0,
        "Cluster Virtual IP address", HFILL }
    },
    { &hf_msnlb_count,
      { "Count", "msnlb.count",
        FT_UINT32, BASE_HEX,
        NULL, 0,
        NULL, HFILL }
    },
    { &hf_msnlb_host_name,
      { "Host name", "msnlb.host_name",
        FT_STRING, BASE_NONE,
        NULL, 0,
        NULL, HFILL }
    }
  };

  static gint *ett[] = {
    &ett_msnlb
  };

  proto_msnlb = proto_register_protocol("MS Network Load Balancing", "MS NLB", "msnlb");
  proto_register_field_array(proto_msnlb, hf, array_length(hf));
  proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_msnlb(void)
{
  dissector_handle_t msnlb_handle;

  msnlb_handle = create_dissector_handle(dissect_msnlb, proto_msnlb);
  dissector_add_uint("ethertype", ETHERTYPE_MS_NLB_HEARTBEAT, msnlb_handle);
}