2006-07-14 09:17:11 +00:00
|
|
|
/* packet-pana.c
|
|
|
|
* Routines for Protocol for carrying Authentication for Network Access dissection
|
|
|
|
* Copyright 2006, Peter Racz <racz@ifi.unizh.ch>
|
|
|
|
*
|
|
|
|
* 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
|
2012-06-28 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-07-14 09:17:11 +00:00
|
|
|
*/
|
2010-10-04 16:46:39 +00:00
|
|
|
/* This protocol implements PANA as of the IETF RFC 5191.
|
|
|
|
* (Note: This dissector was udated to reflect
|
|
|
|
* draft-ietf-pana-pana-18 which is a workitem of the ietf workgroup
|
|
|
|
* internet area/pana. I believe draft-18 then became RFC 5191).
|
2006-07-14 23:04:35 +00:00
|
|
|
*/
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2006-07-14 23:04:35 +00:00
|
|
|
#include <epan/conversation.h>
|
2013-08-31 14:32:01 +00:00
|
|
|
#include <epan/wmem/wmem.h>
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2013-12-14 10:29:26 +00:00
|
|
|
void proto_register_pana(void);
|
|
|
|
void proto_reg_handoff_pana(void);
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
#if 0
|
2006-07-14 09:17:11 +00:00
|
|
|
#define PANA_UDP_PORT 3001
|
2010-10-04 16:46:39 +00:00
|
|
|
#endif
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
#define MIN_AVP_SIZE 8
|
|
|
|
|
|
|
|
#define PANA_FLAG_R 0x8000
|
|
|
|
#define PANA_FLAG_S 0x4000
|
2007-04-16 08:53:33 +00:00
|
|
|
#define PANA_FLAG_C 0x2000
|
|
|
|
#define PANA_FLAG_A 0x1000
|
|
|
|
#define PANA_FLAG_P 0x0800
|
2007-08-22 06:59:28 +00:00
|
|
|
#define PANA_FLAG_I 0x0400
|
2010-10-04 16:46:39 +00:00
|
|
|
#if 0
|
|
|
|
#define PANA_FLAG_RES6 0x0200
|
|
|
|
#define PANA_FLAG_RES7 0x0100
|
|
|
|
#define PANA_FLAG_RES8 0x0080
|
|
|
|
#define PANA_FLAG_RES9 0x0040
|
2006-07-14 09:17:11 +00:00
|
|
|
#define PANA_FLAG_RES10 0x0020
|
|
|
|
#define PANA_FLAG_RES11 0x0010
|
|
|
|
#define PANA_FLAG_RES12 0x0008
|
|
|
|
#define PANA_FLAG_RES13 0x0004
|
|
|
|
#define PANA_FLAG_RES14 0x0002
|
|
|
|
#define PANA_FLAG_RES15 0x0001
|
2010-10-04 16:46:39 +00:00
|
|
|
#endif
|
|
|
|
#define PANA_FLAG_RESERVED 0x03ff
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
#define PANA_AVP_FLAG_V 0x8000
|
2010-10-04 16:46:39 +00:00
|
|
|
#if 0
|
|
|
|
#define PANA_AVP_FLAG_RES1 0x4000
|
|
|
|
#define PANA_AVP_FLAG_RES2 0x2000
|
|
|
|
#define PANA_AVP_FLAG_RES3 0x1000
|
|
|
|
#define PANA_AVP_FLAG_RES4 0x0800
|
|
|
|
#define PANA_AVP_FLAG_RES5 0x0400
|
|
|
|
#define PANA_AVP_FLAG_RES6 0x0200
|
|
|
|
#define PANA_AVP_FLAG_RES7 0x0100
|
|
|
|
#define PANA_AVP_FLAG_RES8 0x0080
|
|
|
|
#define PANA_AVP_FLAG_RES9 0x0040
|
2006-07-14 09:17:11 +00:00
|
|
|
#define PANA_AVP_FLAG_RES10 0x0020
|
|
|
|
#define PANA_AVP_FLAG_RES11 0x0010
|
|
|
|
#define PANA_AVP_FLAG_RES12 0x0008
|
|
|
|
#define PANA_AVP_FLAG_RES13 0x0004
|
|
|
|
#define PANA_AVP_FLAG_RES14 0x0002
|
|
|
|
#define PANA_AVP_FLAG_RES15 0x0001
|
2010-10-04 16:46:39 +00:00
|
|
|
#endif
|
|
|
|
#define PANA_AVP_FLAG_RESERVED 0x7fff
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
static dissector_handle_t eap_handle;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
|
|
|
static int proto_pana = -1;
|
|
|
|
static int hf_pana_reserved_type = -1;
|
|
|
|
static int hf_pana_length_type = -1;
|
|
|
|
static int hf_pana_msg_type = -1;
|
2007-04-16 08:53:33 +00:00
|
|
|
static int hf_pana_session_id = -1;
|
2006-07-14 09:17:11 +00:00
|
|
|
static int hf_pana_seqnumber = -1;
|
2006-07-14 23:04:35 +00:00
|
|
|
static int hf_pana_response_in = -1;
|
|
|
|
static int hf_pana_response_to = -1;
|
2010-10-04 16:46:39 +00:00
|
|
|
static int hf_pana_response_time = -1;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
static int hf_pana_flags = -1;
|
|
|
|
static int hf_pana_flag_r = -1;
|
|
|
|
static int hf_pana_flag_s = -1;
|
2007-04-16 08:53:33 +00:00
|
|
|
static int hf_pana_flag_c = -1;
|
|
|
|
static int hf_pana_flag_a = -1;
|
|
|
|
static int hf_pana_flag_p = -1;
|
2007-08-22 06:59:28 +00:00
|
|
|
static int hf_pana_flag_i = -1;
|
2006-07-14 09:17:11 +00:00
|
|
|
static int hf_pana_avp_code = -1;
|
2010-10-04 16:46:39 +00:00
|
|
|
static int hf_pana_avp_data_length = -1;
|
2006-07-14 09:17:11 +00:00
|
|
|
static int hf_pana_avp_flags = -1;
|
|
|
|
static int hf_pana_avp_flag_v = -1;
|
|
|
|
static int hf_pana_avp_reserved = -1;
|
|
|
|
static int hf_pana_avp_vendorid = -1;
|
|
|
|
|
|
|
|
static int hf_pana_avp_data_uint64 = -1;
|
|
|
|
static int hf_pana_avp_data_int64 = -1;
|
|
|
|
static int hf_pana_avp_data_uint32 = -1;
|
|
|
|
static int hf_pana_avp_data_int32 = -1;
|
|
|
|
static int hf_pana_avp_data_bytes = -1;
|
|
|
|
static int hf_pana_avp_data_string = -1;
|
|
|
|
static int hf_pana_avp_data_enumerated = -1;
|
|
|
|
|
2011-07-29 13:19:16 +00:00
|
|
|
#define MSG_TYPE_MAX 5
|
2006-07-14 09:17:11 +00:00
|
|
|
static const value_string msg_type_names[] = {
|
2007-04-16 08:53:33 +00:00
|
|
|
{ 1, "PANA-Client-Initiation" },
|
|
|
|
{ 2, "PANA-Auth" },
|
|
|
|
{ 3, "PANA-Termination" },
|
|
|
|
{ 4, "PANA-Notification" },
|
2011-07-29 13:19:16 +00:00
|
|
|
{ 5, "PANA-Relay" },
|
2006-07-14 09:17:11 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const value_string msg_subtype_names[] = {
|
|
|
|
{ 0x0000, "Answer" },
|
|
|
|
{ 0x8000, "Request" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2014-02-12 08:46:55 +00:00
|
|
|
#define AVP_CODE_MAX 13
|
2006-07-14 09:17:11 +00:00
|
|
|
static const value_string avp_code_names[] = {
|
2007-08-22 06:59:28 +00:00
|
|
|
{ 1, "AUTH AVP" },
|
|
|
|
{ 2, "EAP-Payload AVP" },
|
|
|
|
{ 3, "Integrity-Algorithm AVP" },
|
2007-06-14 07:09:07 +00:00
|
|
|
{ 4, "Key-Id AVP" },
|
|
|
|
{ 5, "Nonce AVP" },
|
2007-08-22 06:59:28 +00:00
|
|
|
{ 6, "PRF-Algorithm AVP" },
|
|
|
|
{ 7, "Result-Code" },
|
|
|
|
{ 8, "Session-Lifetime" },
|
|
|
|
{ 9, "Termination-Cause" },
|
2011-07-29 13:19:16 +00:00
|
|
|
{ 10, "PaC-Information" },
|
|
|
|
{ 11, "Relayed-Message" },
|
2014-02-12 08:46:55 +00:00
|
|
|
{ 12, "Encryption-Encap" },
|
|
|
|
{ 13, "Encryption-Algorithm" },
|
2006-07-14 09:17:11 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
2013-10-23 06:29:11 +00:00
|
|
|
#if 0
|
2007-06-14 07:09:07 +00:00
|
|
|
static const value_string avp_resultcode_names[] = {
|
2007-04-16 08:53:33 +00:00
|
|
|
{ 0, "PANA_SUCCESS" },
|
|
|
|
{ 1, "PANA_AUTHENTICATION_REJECTED" },
|
|
|
|
{ 2, "PANA_AUTHORIZATION_REJECTED" },
|
2006-07-14 09:17:11 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
2013-10-23 06:29:11 +00:00
|
|
|
#endif
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PANA_OCTET_STRING = 1,
|
|
|
|
PANA_INTEGER32,
|
|
|
|
PANA_INTEGER64,
|
|
|
|
PANA_UNSIGNED32,
|
|
|
|
PANA_UNSIGNED64,
|
|
|
|
PANA_FLOAT32,
|
|
|
|
PANA_FLOAT64,
|
|
|
|
PANA_FLOAT128,
|
|
|
|
PANA_GROUPED,
|
|
|
|
PANA_ENUMERATED,
|
|
|
|
PANA_UTF8STRING,
|
|
|
|
PANA_EAP,
|
2011-07-29 13:19:16 +00:00
|
|
|
PANA_RESULT_CODE,
|
|
|
|
PANA_ENCAPSULATED
|
2006-07-14 09:17:11 +00:00
|
|
|
} pana_avp_types;
|
|
|
|
|
|
|
|
static const value_string avp_type_names[]={
|
2007-04-16 08:53:33 +00:00
|
|
|
{ PANA_OCTET_STRING, "OctetString" },
|
2006-07-14 09:17:11 +00:00
|
|
|
{ PANA_INTEGER32, "Integer32" },
|
|
|
|
{ PANA_INTEGER64, "Integer64" },
|
|
|
|
{ PANA_UNSIGNED32, "Unsigned32" },
|
|
|
|
{ PANA_UNSIGNED64, "Unsigned64" },
|
|
|
|
{ PANA_FLOAT32, "Float32" },
|
|
|
|
{ PANA_FLOAT64, "Float64" },
|
|
|
|
{ PANA_FLOAT128, "Float128" },
|
|
|
|
{ PANA_GROUPED, "Grouped" },
|
|
|
|
{ PANA_ENUMERATED, "Enumerated" },
|
|
|
|
{ PANA_UTF8STRING, "UTF8String" },
|
|
|
|
{ PANA_EAP, "OctetString" },
|
|
|
|
{ PANA_RESULT_CODE, "Unsigned32" },
|
2011-07-29 13:19:16 +00:00
|
|
|
{ PANA_ENCAPSULATED, "Encapsulated" },
|
2006-07-14 09:17:11 +00:00
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_pana = -1;
|
|
|
|
static gint ett_pana_flags = -1;
|
|
|
|
static gint ett_pana_avp = -1;
|
|
|
|
static gint ett_pana_avp_info = -1;
|
|
|
|
static gint ett_pana_avp_flags = -1;
|
|
|
|
|
|
|
|
|
2006-07-14 23:04:35 +00:00
|
|
|
typedef struct _pana_transaction_t {
|
2010-10-04 16:46:39 +00:00
|
|
|
guint32 req_frame;
|
|
|
|
guint32 rep_frame;
|
2006-07-14 23:04:35 +00:00
|
|
|
nstime_t req_time;
|
|
|
|
} pana_transaction_t;
|
|
|
|
|
|
|
|
typedef struct _pana_conv_info_t {
|
2014-04-28 21:21:05 +00:00
|
|
|
wmem_map_t *pdus;
|
2006-07-14 23:04:35 +00:00
|
|
|
} pana_conv_info_t;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2011-07-29 13:19:16 +00:00
|
|
|
static void
|
|
|
|
dissect_pana_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
/*
|
|
|
|
* Function for the PANA flags dissector.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_pana_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset, guint16 flags)
|
|
|
|
{
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_item *flags_item;
|
|
|
|
proto_tree *flags_tree;
|
|
|
|
|
|
|
|
if(parent_tree == NULL)
|
|
|
|
return;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
flags_item = proto_tree_add_uint(parent_tree, hf_pana_flags, tvb,
|
|
|
|
offset, 2, flags);
|
|
|
|
flags_tree = proto_item_add_subtree(flags_item, ett_pana_flags);
|
|
|
|
|
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_r, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_R)
|
|
|
|
proto_item_append_text(flags_item, ", Request");
|
|
|
|
else
|
|
|
|
proto_item_append_text(flags_item, ", Answer");
|
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_s, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_S)
|
|
|
|
proto_item_append_text(flags_item, ", S flag set");
|
2007-04-16 08:53:33 +00:00
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_c, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_C)
|
|
|
|
proto_item_append_text(flags_item, ", C flag set");
|
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_a, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_A)
|
|
|
|
proto_item_append_text(flags_item, ", A flag set");
|
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_p, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_P)
|
|
|
|
proto_item_append_text(flags_item, ", P flag set");
|
2007-08-22 06:59:28 +00:00
|
|
|
proto_tree_add_boolean(flags_tree, hf_pana_flag_i, tvb, offset, 2, flags);
|
|
|
|
if (flags & PANA_FLAG_I)
|
|
|
|
proto_item_append_text(flags_item, ", I flag set");
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
/*
|
|
|
|
* Function for AVP flags dissector.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_pana_avp_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset, guint16 flags)
|
|
|
|
{
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_item *avp_flags_item;
|
|
|
|
proto_tree *avp_flags_tree;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
if(parent_tree == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
avp_flags_item = proto_tree_add_uint(parent_tree, hf_pana_avp_flags, tvb,
|
|
|
|
offset, 2, flags);
|
|
|
|
avp_flags_tree = proto_item_add_subtree(avp_flags_item, ett_pana_avp_flags);
|
|
|
|
|
|
|
|
proto_tree_add_boolean(avp_flags_tree, hf_pana_avp_flag_v, tvb, offset, 2, flags);
|
2010-10-04 16:46:39 +00:00
|
|
|
if (flags & PANA_AVP_FLAG_V) {
|
2006-07-14 09:17:11 +00:00
|
|
|
proto_item_append_text(avp_flags_item, ", Vendor");
|
2010-10-04 16:46:39 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Map AVP code to AVP type
|
|
|
|
*/
|
|
|
|
static pana_avp_types
|
|
|
|
pana_avp_get_type(guint16 avp_code, guint32 vendor_id)
|
|
|
|
{
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
if(vendor_id == 0) {
|
|
|
|
switch(avp_code) {
|
2010-10-04 16:46:39 +00:00
|
|
|
case 1: return PANA_OCTET_STRING; /* AUTH AVP */
|
|
|
|
case 2: return PANA_EAP; /* EAP-Payload AVP */
|
|
|
|
case 3: return PANA_UNSIGNED32; /* Integrity-Algorithm AVP */
|
|
|
|
case 4: return PANA_INTEGER32; /* Key-Id AVP */
|
|
|
|
case 5: return PANA_OCTET_STRING; /* Nonce AVP */
|
|
|
|
case 6: return PANA_UNSIGNED32; /* PRF-Algorithm AVP */
|
|
|
|
case 7: return PANA_RESULT_CODE; /* Result-Code AVP */
|
|
|
|
case 8: return PANA_UNSIGNED32; /* Session-Lifetime AVP */
|
|
|
|
case 9: return PANA_ENUMERATED; /* Termination-Cause AVP */
|
2011-07-29 13:19:16 +00:00
|
|
|
case 10: return PANA_OCTET_STRING; /* PaC-Information AVP */
|
|
|
|
case 11: return PANA_ENCAPSULATED; /* Relayed-Message AVP */
|
2014-02-12 08:46:55 +00:00
|
|
|
case 12: return PANA_OCTET_STRING; /* Encryption-Encap AVP */
|
|
|
|
case 13: return PANA_UNSIGNED32; /* Encryption-Algorithm AVP */
|
2006-07-14 09:17:11 +00:00
|
|
|
default: return PANA_OCTET_STRING;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return PANA_OCTET_STRING;
|
|
|
|
}
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function for AVP dissector.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree)
|
|
|
|
{
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
gint offset;
|
2006-07-14 09:17:11 +00:00
|
|
|
guint16 avp_code;
|
|
|
|
guint16 avp_flags;
|
2010-10-04 16:46:39 +00:00
|
|
|
guint32 avp_length;
|
2006-07-14 09:17:11 +00:00
|
|
|
guint16 avp_type;
|
|
|
|
guint32 vendor_id;
|
2010-10-04 16:46:39 +00:00
|
|
|
guint32 avp_hdr_length;
|
|
|
|
guint32 avp_data_length;
|
|
|
|
guint32 padding;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
gint32 buffer_length;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
tvbuff_t *group_tvb;
|
|
|
|
tvbuff_t *eap_tvb;
|
2011-07-29 13:19:16 +00:00
|
|
|
tvbuff_t *encap_tvb;
|
2006-07-14 09:17:11 +00:00
|
|
|
proto_tree *single_avp_tree;
|
|
|
|
proto_tree *avp_eap_tree;
|
2011-07-29 13:19:16 +00:00
|
|
|
proto_tree *avp_encap_tree;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
offset = 0;
|
2008-04-16 07:18:08 +00:00
|
|
|
buffer_length = tvb_reported_length(tvb);
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Go through all AVPs */
|
2008-04-16 07:18:08 +00:00
|
|
|
while (buffer_length > 0) {
|
2010-10-04 16:46:39 +00:00
|
|
|
avp_code = tvb_get_ntohs(tvb, offset);
|
|
|
|
avp_flags = tvb_get_ntohs(tvb, offset + 2);
|
|
|
|
avp_data_length = tvb_get_ntohs(tvb, offset + 4);
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Check AVP flags for vendor specific AVP */
|
|
|
|
if (avp_flags & PANA_AVP_FLAG_V) {
|
2010-10-04 16:46:39 +00:00
|
|
|
vendor_id = tvb_get_ntohl(tvb, 8);
|
2006-07-14 09:17:11 +00:00
|
|
|
avp_hdr_length = 12;
|
|
|
|
} else {
|
|
|
|
vendor_id = 0;
|
|
|
|
avp_hdr_length = 8;
|
|
|
|
}
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
avp_length = avp_hdr_length + avp_data_length;
|
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
/* Check AVP type */
|
|
|
|
avp_type = pana_avp_get_type(avp_code, vendor_id);
|
|
|
|
|
|
|
|
|
|
|
|
/* Check padding */
|
|
|
|
padding = (4 - (avp_length % 4)) % 4;
|
|
|
|
|
2014-07-05 19:25:32 +00:00
|
|
|
single_avp_tree = proto_tree_add_subtree_format(avp_tree, tvb, offset, avp_length + padding,
|
|
|
|
ett_pana_avp_info, NULL, "%s (%s) length: %d bytes (%d padded bytes)",
|
2006-07-14 09:17:11 +00:00
|
|
|
val_to_str(avp_code, avp_code_names, "Unknown (%d)"),
|
|
|
|
val_to_str(avp_type, avp_type_names, "Unknown (%d)"),
|
|
|
|
avp_length,
|
|
|
|
avp_length + padding);
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
/* AVP Code */
|
|
|
|
proto_tree_add_uint_format_value(single_avp_tree, hf_pana_avp_code, tvb,
|
|
|
|
offset, 2, avp_code, "%s (%u)",
|
|
|
|
val_to_str(avp_code, avp_code_names, "Unknown (%d)"),
|
|
|
|
avp_code);
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += 2;
|
2010-10-04 16:46:39 +00:00
|
|
|
|
|
|
|
/* AVP Flags */
|
|
|
|
dissect_pana_avp_flags(single_avp_tree, tvb, offset, avp_flags);
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += 2;
|
2010-10-04 16:46:39 +00:00
|
|
|
|
|
|
|
/* AVP Length */
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_length, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += 2;
|
2010-10-04 16:46:39 +00:00
|
|
|
|
|
|
|
/* Reserved */
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_reserved, tvb, offset, 2, ENC_NA);
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += 2;
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2008-04-16 07:18:08 +00:00
|
|
|
if (avp_flags & PANA_AVP_FLAG_V) {
|
2010-10-04 16:46:39 +00:00
|
|
|
/* Vendor ID */
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_vendorid, tvb, offset, 4, ENC_BIG_ENDIAN);
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += 4;
|
|
|
|
}
|
2010-10-04 16:46:39 +00:00
|
|
|
if (! (avp_flags & PANA_AVP_FLAG_V)) {
|
2006-07-14 09:17:11 +00:00
|
|
|
/* AVP Value */
|
|
|
|
switch(avp_type) {
|
|
|
|
case PANA_GROUPED: {
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree *avp_group_tree;
|
2014-07-05 19:25:32 +00:00
|
|
|
avp_group_tree = proto_tree_add_subtree(single_avp_tree,
|
2010-10-04 16:46:39 +00:00
|
|
|
tvb, offset, avp_data_length,
|
2014-07-05 19:25:32 +00:00
|
|
|
ett_pana_avp, NULL, "Grouped AVP");
|
2006-07-14 09:17:11 +00:00
|
|
|
group_tvb = tvb_new_subset(tvb, offset,
|
2010-10-04 16:46:39 +00:00
|
|
|
MIN(avp_data_length, tvb_reported_length(tvb)-offset),
|
|
|
|
avp_data_length);
|
|
|
|
dissect_avps(group_tvb, pinfo, avp_group_tree);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_UTF8STRING: {
|
|
|
|
const guint8 *data;
|
|
|
|
data = tvb_get_ptr(tvb, offset, avp_data_length);
|
|
|
|
proto_tree_add_string_format(single_avp_tree, hf_pana_avp_data_string, tvb,
|
|
|
|
offset, avp_data_length, data,
|
|
|
|
"UTF8String: %*.*s",
|
|
|
|
avp_data_length, avp_data_length, data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_OCTET_STRING: {
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_bytes, tvb,
|
|
|
|
offset, avp_data_length, ENC_NA);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_INTEGER32: {
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_int32, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 4, ENC_BIG_ENDIAN);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_UNSIGNED32: {
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_uint32, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 4, ENC_BIG_ENDIAN);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_INTEGER64: {
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_int64, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 8, ENC_BIG_ENDIAN);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_UNSIGNED64: {
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_uint64, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 8, ENC_BIG_ENDIAN);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_ENUMERATED: {
|
|
|
|
proto_tree_add_item(single_avp_tree, hf_pana_avp_data_enumerated, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 4, ENC_BIG_ENDIAN);
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_RESULT_CODE: {
|
|
|
|
proto_tree_add_text(single_avp_tree, tvb, offset, avp_data_length,
|
2010-10-04 16:46:39 +00:00
|
|
|
"Value: %d (%s)",
|
|
|
|
tvb_get_ntohl(tvb, offset),
|
|
|
|
val_to_str(tvb_get_ntohs(tvb, offset), avp_code_names, "Unknown (%d)"));
|
2006-07-14 09:17:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PANA_EAP: {
|
2014-07-05 19:25:32 +00:00
|
|
|
avp_eap_tree = proto_tree_add_subtree(single_avp_tree,
|
2010-10-04 16:46:39 +00:00
|
|
|
tvb, offset, avp_data_length,
|
2014-07-05 19:25:32 +00:00
|
|
|
ett_pana_avp, NULL, "AVP Value (EAP packet)");
|
2014-06-06 14:35:50 +00:00
|
|
|
eap_tvb = tvb_new_subset_length(tvb, offset, avp_data_length);
|
2009-05-29 06:16:43 +00:00
|
|
|
if (eap_handle != NULL) {
|
2006-07-14 09:17:11 +00:00
|
|
|
call_dissector(eap_handle, eap_tvb, pinfo, avp_eap_tree);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-07-29 13:19:16 +00:00
|
|
|
case PANA_ENCAPSULATED: {
|
2014-07-05 19:25:32 +00:00
|
|
|
avp_encap_tree = proto_tree_add_subtree(single_avp_tree,
|
2011-07-29 13:19:16 +00:00
|
|
|
tvb, offset, avp_data_length,
|
2014-07-05 19:25:32 +00:00
|
|
|
ett_pana_avp, NULL, "AVP Value (PANA packet)");
|
2014-06-06 14:35:50 +00:00
|
|
|
encap_tvb = tvb_new_subset_length(tvb, offset, avp_data_length);
|
2011-07-29 13:19:16 +00:00
|
|
|
dissect_pana_pdu(encap_tvb, pinfo, avp_encap_tree);
|
|
|
|
break;
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-16 07:18:08 +00:00
|
|
|
offset += avp_data_length + padding;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Update the buffer length */
|
|
|
|
buffer_length -= avp_length + padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function for the PANA PDU dissector.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_pana_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree *pana_tree = NULL;
|
|
|
|
guint16 flags;
|
|
|
|
guint16 msg_type;
|
|
|
|
guint32 msg_length;
|
|
|
|
guint32 avp_length;
|
|
|
|
guint32 seq_num;
|
|
|
|
conversation_t *conversation;
|
|
|
|
pana_conv_info_t *pana_info;
|
2006-07-14 23:04:35 +00:00
|
|
|
pana_transaction_t *pana_trans;
|
|
|
|
int offset = 0;
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PANA");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Get message length, type and flags */
|
|
|
|
msg_length = tvb_get_ntohs(tvb, 2);
|
2010-10-04 16:46:39 +00:00
|
|
|
flags = tvb_get_ntohs(tvb, 4);
|
|
|
|
msg_type = tvb_get_ntohs(tvb, 6);
|
|
|
|
seq_num = tvb_get_ntohl(tvb, 12);
|
|
|
|
avp_length = msg_length - 16;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2013-06-14 01:56:28 +00:00
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Type %s-%s",
|
2010-10-04 16:46:39 +00:00
|
|
|
val_to_str(msg_type, msg_type_names, "Unknown (%d)"),
|
|
|
|
val_to_str(flags & PANA_FLAG_R, msg_subtype_names, "Unknown (%d)"));
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Make the protocol tree */
|
|
|
|
if (tree) {
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_item *ti;
|
|
|
|
ti = proto_tree_add_item(tree, proto_pana, tvb, 0, -1, ENC_NA);
|
2006-07-14 09:17:11 +00:00
|
|
|
pana_tree = proto_item_add_subtree(ti, ett_pana);
|
2006-07-14 23:04:35 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2007-04-16 08:53:33 +00:00
|
|
|
/*
|
2006-07-14 23:04:35 +00:00
|
|
|
* We need to track some state for this protocol on a per conversation
|
|
|
|
* basis so we can do neat things like request/response tracking
|
|
|
|
*/
|
2010-05-13 18:28:34 +00:00
|
|
|
conversation = find_or_create_conversation(pinfo);
|
|
|
|
|
2006-07-14 23:04:35 +00:00
|
|
|
/*
|
|
|
|
* Do we already have a state structure for this conv
|
|
|
|
*/
|
2013-03-19 19:28:57 +00:00
|
|
|
pana_info = (pana_conv_info_t *)conversation_get_proto_data(conversation, proto_pana);
|
2006-07-14 23:04:35 +00:00
|
|
|
if (!pana_info) {
|
|
|
|
/* No. Attach that information to the conversation, and add
|
|
|
|
* it to the list of information structures.
|
|
|
|
*/
|
2013-08-31 14:32:01 +00:00
|
|
|
pana_info = wmem_new(wmem_file_scope(), pana_conv_info_t);
|
2014-04-28 21:21:05 +00:00
|
|
|
pana_info->pdus=wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
|
2006-07-14 23:04:35 +00:00
|
|
|
|
|
|
|
conversation_add_proto_data(conversation, proto_pana, pana_info);
|
|
|
|
}
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 23:04:35 +00:00
|
|
|
if(!pinfo->fd->flags.visited){
|
|
|
|
if(flags&PANA_FLAG_R){
|
|
|
|
/* This is a request */
|
2013-08-31 14:32:01 +00:00
|
|
|
pana_trans=wmem_new(wmem_file_scope(), pana_transaction_t);
|
2006-07-14 23:04:35 +00:00
|
|
|
pana_trans->req_frame=pinfo->fd->num;
|
|
|
|
pana_trans->rep_frame=0;
|
|
|
|
pana_trans->req_time=pinfo->fd->abs_ts;
|
2014-04-28 21:21:05 +00:00
|
|
|
wmem_map_insert(pana_info->pdus, GUINT_TO_POINTER(seq_num), (void *)pana_trans);
|
2006-07-14 23:04:35 +00:00
|
|
|
} else {
|
2014-04-28 21:21:05 +00:00
|
|
|
pana_trans=(pana_transaction_t *)wmem_map_lookup(pana_info->pdus, GUINT_TO_POINTER(seq_num));
|
2006-07-14 23:04:35 +00:00
|
|
|
if(pana_trans){
|
|
|
|
pana_trans->rep_frame=pinfo->fd->num;
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
2006-07-14 23:04:35 +00:00
|
|
|
} else {
|
2014-04-28 21:21:05 +00:00
|
|
|
pana_trans=(pana_transaction_t *)wmem_map_lookup(pana_info->pdus, GUINT_TO_POINTER(seq_num));
|
2006-07-14 23:04:35 +00:00
|
|
|
}
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 23:04:35 +00:00
|
|
|
if(!pana_trans){
|
|
|
|
/* create a "fake" pana_trans structure */
|
2013-08-31 14:32:01 +00:00
|
|
|
pana_trans=wmem_new(wmem_packet_scope(), pana_transaction_t);
|
2006-07-14 23:04:35 +00:00
|
|
|
pana_trans->req_frame=0;
|
|
|
|
pana_trans->rep_frame=0;
|
|
|
|
pana_trans->req_time=pinfo->fd->abs_ts;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
2006-07-14 23:04:35 +00:00
|
|
|
/* print state tracking in the tree */
|
|
|
|
if(flags&PANA_FLAG_R){
|
|
|
|
/* This is a request */
|
|
|
|
if(pana_trans->rep_frame){
|
|
|
|
proto_item *it;
|
|
|
|
|
|
|
|
it=proto_tree_add_uint(pana_tree, hf_pana_response_in, tvb, 0, 0, pana_trans->rep_frame);
|
|
|
|
PROTO_ITEM_SET_GENERATED(it);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This is a reply */
|
|
|
|
if(pana_trans->req_frame){
|
|
|
|
proto_item *it;
|
|
|
|
nstime_t ns;
|
|
|
|
|
|
|
|
it=proto_tree_add_uint(pana_tree, hf_pana_response_to, tvb, 0, 0, pana_trans->req_frame);
|
|
|
|
PROTO_ITEM_SET_GENERATED(it);
|
|
|
|
|
|
|
|
nstime_delta(&ns, &pinfo->fd->abs_ts, &pana_trans->req_time);
|
2010-10-04 16:46:39 +00:00
|
|
|
it=proto_tree_add_time(pana_tree, hf_pana_response_time, tvb, 0, 0, &ns);
|
2006-07-14 23:04:35 +00:00
|
|
|
PROTO_ITEM_SET_GENERATED(it);
|
|
|
|
}
|
2007-04-16 08:53:33 +00:00
|
|
|
}
|
2006-07-14 23:04:35 +00:00
|
|
|
|
|
|
|
/* Reserved field */
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree_add_item(pana_tree, hf_pana_reserved_type, tvb, offset, 2, ENC_NA);
|
2007-08-22 06:59:28 +00:00
|
|
|
offset += 2;
|
2006-07-14 23:04:35 +00:00
|
|
|
|
|
|
|
/* Length */
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree_add_item(pana_tree, hf_pana_length_type, tvb, offset, 2, ENC_BIG_ENDIAN);
|
2006-07-14 23:04:35 +00:00
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* Flags */
|
|
|
|
dissect_pana_flags(pana_tree, tvb, offset, flags);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* Message Type */
|
|
|
|
proto_tree_add_uint_format_value(pana_tree, hf_pana_msg_type, tvb,
|
2010-10-04 16:46:39 +00:00
|
|
|
offset, 2, msg_type, "%s-%s (%d)",
|
|
|
|
val_to_str(msg_type, msg_type_names, "Unknown (%d)"),
|
|
|
|
val_to_str(flags & PANA_FLAG_R, msg_subtype_names, "Unknown (%d)"),
|
|
|
|
msg_type);
|
2006-07-14 23:04:35 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2007-04-16 08:53:33 +00:00
|
|
|
/* Session ID */
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree_add_item(pana_tree, hf_pana_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
|
2007-04-16 08:53:33 +00:00
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
/* Sequence Number */
|
2010-10-04 16:46:39 +00:00
|
|
|
proto_tree_add_item(pana_tree, hf_pana_seqnumber, tvb, offset, 4, ENC_BIG_ENDIAN);
|
2006-07-14 23:04:35 +00:00
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
/* AVPs */
|
2010-10-04 16:46:39 +00:00
|
|
|
if(avp_length != 0){
|
|
|
|
tvbuff_t *avp_tvb;
|
|
|
|
proto_tree *avp_tree;
|
2014-06-06 14:35:50 +00:00
|
|
|
avp_tvb = tvb_new_subset_length(tvb, offset, avp_length);
|
2014-07-05 19:25:32 +00:00
|
|
|
avp_tree = proto_tree_add_subtree(pana_tree, tvb, offset, avp_length, ett_pana_avp, NULL, "Attribute Value Pairs");
|
2006-07-14 23:04:35 +00:00
|
|
|
|
|
|
|
if (avp_tree != NULL) {
|
|
|
|
dissect_avps(avp_tvb, pinfo, avp_tree);
|
|
|
|
}
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function for the PANA dissector.
|
|
|
|
*/
|
2010-10-04 16:46:39 +00:00
|
|
|
/* Called either as a "new-style" or a heuristic dissector */
|
|
|
|
static int
|
2012-09-10 21:40:21 +00:00
|
|
|
dissect_pana(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2006-07-14 09:17:11 +00:00
|
|
|
{
|
|
|
|
|
2007-08-22 13:58:39 +00:00
|
|
|
guint16 pana_res;
|
2010-10-04 16:46:39 +00:00
|
|
|
guint32 msg_length;
|
2006-07-14 09:17:11 +00:00
|
|
|
guint16 flags;
|
|
|
|
guint32 buffer_length;
|
|
|
|
guint16 msg_type;
|
2010-10-04 16:46:39 +00:00
|
|
|
guint32 avp_length;
|
2006-07-14 09:17:11 +00:00
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
/* Get actual buffer length */
|
2014-06-19 17:18:16 +00:00
|
|
|
buffer_length = tvb_length(tvb);
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
/* Check minimum buffer length */
|
|
|
|
if(buffer_length < 12) {
|
2010-10-04 16:46:39 +00:00
|
|
|
return 0;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
2013-10-09 16:20:54 +00:00
|
|
|
/* Check minimum packet length */
|
2006-07-14 09:17:11 +00:00
|
|
|
msg_length = tvb_get_ntohs(tvb, 2);
|
2010-10-04 16:46:39 +00:00
|
|
|
if(msg_length < 16) {
|
|
|
|
return 0;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
/* Check the packet length */
|
|
|
|
if(msg_length != tvb_reported_length(tvb)) {
|
|
|
|
return 0;
|
2007-10-12 21:31:58 +00:00
|
|
|
}
|
|
|
|
|
2007-08-22 13:58:39 +00:00
|
|
|
/* check that the reserved field is zero */
|
2013-10-09 16:20:54 +00:00
|
|
|
pana_res = tvb_get_ntohs(tvb, 0);
|
2010-10-04 16:46:39 +00:00
|
|
|
if (pana_res != 0) {
|
|
|
|
return 0;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* verify that none of the reserved bits are set */
|
2013-10-09 16:20:54 +00:00
|
|
|
flags = tvb_get_ntohs(tvb, 4);
|
2010-10-04 16:46:39 +00:00
|
|
|
if (flags & PANA_FLAG_RESERVED) {
|
|
|
|
return 0;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* verify that we recognize the message type */
|
2013-10-09 16:20:54 +00:00
|
|
|
msg_type = tvb_get_ntohs(tvb, 6);
|
2010-10-04 16:46:39 +00:00
|
|
|
if ((msg_type > MSG_TYPE_MAX) || (msg_type == 0)) {
|
|
|
|
return 0;
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
avp_length = msg_length - 16;
|
|
|
|
|
|
|
|
/* For bug 1908: check the length of the first AVP, too */
|
|
|
|
|
|
|
|
if (avp_length != 0) {
|
|
|
|
guint32 avp_offset;
|
|
|
|
guint16 avp_code;
|
|
|
|
guint32 first_avp_length;
|
|
|
|
guint16 avp_flags;
|
|
|
|
|
|
|
|
if (avp_length < MIN_AVP_SIZE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
avp_offset = 16;
|
|
|
|
/* Make sure no exceptions since we're just doing a preliminary heuristic check */
|
|
|
|
if ((avp_offset + 8) > buffer_length ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
avp_code = tvb_get_ntohs(tvb, avp_offset);
|
|
|
|
if ((avp_code == 0) || (avp_code > AVP_CODE_MAX)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
avp_flags = tvb_get_ntohs(tvb, avp_offset + 2);
|
|
|
|
if (avp_flags & PANA_AVP_FLAG_RESERVED) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* check whether is the V (vendor) flag on or not */
|
|
|
|
if (avp_flags & PANA_AVP_FLAG_V) {
|
|
|
|
first_avp_length = 12;
|
|
|
|
} else {
|
|
|
|
first_avp_length = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
first_avp_length += tvb_get_ntohs(tvb, avp_offset + 4);
|
|
|
|
|
|
|
|
if (first_avp_length > avp_length) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
dissect_pana_pdu(tvb, pinfo, tree);
|
|
|
|
|
2010-10-04 16:46:39 +00:00
|
|
|
return tvb_reported_length(tvb);
|
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the protocol with Wireshark
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
proto_register_pana(void)
|
|
|
|
{
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
static hf_register_info hf[] = {
|
2006-07-14 23:04:35 +00:00
|
|
|
{ &hf_pana_response_in,
|
|
|
|
{ "Response In", "pana.response_in",
|
2009-07-07 09:02:59 +00:00
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
2006-07-14 23:04:35 +00:00
|
|
|
"The response to this PANA request is in this frame", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pana_response_to,
|
|
|
|
{ "Request In", "pana.response_to",
|
2009-07-07 09:02:59 +00:00
|
|
|
FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
2006-07-14 23:04:35 +00:00
|
|
|
"This is a response to the PANA request in this frame", HFILL }
|
|
|
|
},
|
2010-10-04 16:46:39 +00:00
|
|
|
{ &hf_pana_response_time,
|
|
|
|
{ "Response Time", "pana.response_time",
|
2006-07-14 23:04:35 +00:00
|
|
|
FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
|
|
|
|
"The time between the Call and the Reply", HFILL }
|
|
|
|
},
|
2006-07-14 09:17:11 +00:00
|
|
|
{ &hf_pana_reserved_type,
|
|
|
|
{ "PANA Reserved", "pana.reserved",
|
2010-10-04 16:46:39 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_length_type,
|
|
|
|
{ "PANA Message Length", "pana.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_pana_flags,
|
|
|
|
{ "Flags", "pana.flags",
|
|
|
|
FT_UINT8, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_flag_r,
|
|
|
|
{ "Request", "pana.flags.r",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_R,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_flag_s,
|
2007-04-16 08:53:33 +00:00
|
|
|
{ "Start", "pana.flags.s",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_S,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
2007-04-16 08:53:33 +00:00
|
|
|
{ &hf_pana_flag_c,
|
|
|
|
{ "Complete","pana.flags.c",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_C,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2007-04-16 08:53:33 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_flag_a,
|
|
|
|
{ "Auth","pana.flags.a",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_A,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2007-04-16 08:53:33 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_flag_p,
|
|
|
|
{ "Ping","pana.flags.p",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_P,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pana_flag_i,
|
|
|
|
{ "IP Reconfig","pana.flags.i",
|
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_FLAG_I,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{ &hf_pana_msg_type,
|
|
|
|
{ "PANA Message Type", "pana.type",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
2007-04-16 08:53:33 +00:00
|
|
|
{ &hf_pana_session_id,
|
|
|
|
{ "PANA Session ID", "pana.sid",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2007-04-16 08:53:33 +00:00
|
|
|
},
|
2006-07-14 09:17:11 +00:00
|
|
|
{ &hf_pana_seqnumber,
|
|
|
|
{ "PANA Sequence Number", "pana.seq",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_pana_avp_code,
|
|
|
|
{ "AVP Code", "pana.avp.code",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
2010-10-04 16:46:39 +00:00
|
|
|
{ &hf_pana_avp_data_length,
|
|
|
|
{ "AVP Data Length", "pana.avp.data_length",
|
2006-07-14 09:17:11 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_flags,
|
|
|
|
{ "AVP Flags", "pana.avp.flags",
|
|
|
|
FT_UINT16, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_flag_v,
|
|
|
|
{ "Vendor", "pana.avp.flags.v",
|
2007-08-22 06:59:28 +00:00
|
|
|
FT_BOOLEAN, 16, TFS(&tfs_set_notset), PANA_AVP_FLAG_V,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_reserved,
|
|
|
|
{ "AVP Reserved", "pana.avp.reserved",
|
2010-10-04 16:46:39 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_vendorid,
|
|
|
|
{ "AVP Vendor ID", "pana.avp.vendorid",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{ &hf_pana_avp_data_uint64,
|
|
|
|
{ "Value", "pana.avp.data.uint64",
|
|
|
|
FT_UINT64, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_int64,
|
|
|
|
{ "Value", "pana.avp.data.int64",
|
2008-03-15 22:41:57 +00:00
|
|
|
FT_INT64, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_uint32,
|
|
|
|
{ "Value", "pana.avp.data.uint32",
|
|
|
|
FT_UINT32, BASE_HEX, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_int32,
|
|
|
|
{ "Value", "pana.avp.data.int32",
|
2008-03-15 22:41:57 +00:00
|
|
|
FT_INT32, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_bytes,
|
|
|
|
{ "Value", "pana.avp.data.bytes",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_string,
|
|
|
|
{ "Value", "pana.avp.data.string",
|
|
|
|
FT_STRING, BASE_NONE, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
2006-07-14 09:17:11 +00:00
|
|
|
},
|
|
|
|
{ &hf_pana_avp_data_enumerated,
|
|
|
|
{ "Value", "pana.avp.data.enum",
|
|
|
|
FT_INT32, BASE_DEC, NULL, 0x0,
|
2007-06-14 07:09:07 +00:00
|
|
|
NULL, HFILL }
|
|
|
|
}
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_pana,
|
|
|
|
&ett_pana_flags,
|
|
|
|
&ett_pana_avp,
|
|
|
|
&ett_pana_avp_info,
|
2007-06-14 07:09:07 +00:00
|
|
|
&ett_pana_avp_flags
|
2006-07-14 09:17:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Register the protocol name and description */
|
|
|
|
proto_pana = proto_register_protocol("Protocol for carrying Authentication for Network Access",
|
|
|
|
"PANA", "pana");
|
|
|
|
|
|
|
|
/* Required function calls to register the header fields and subtrees used */
|
|
|
|
proto_register_field_array(proto_pana, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_pana(void)
|
|
|
|
{
|
2010-10-04 16:46:39 +00:00
|
|
|
|
2008-09-30 14:46:48 +00:00
|
|
|
dissector_handle_t pana_handle;
|
|
|
|
|
2006-07-14 09:17:11 +00:00
|
|
|
heur_dissector_add("udp", dissect_pana, proto_pana);
|
|
|
|
|
|
|
|
pana_handle = new_create_dissector_handle(dissect_pana, proto_pana);
|
2014-06-20 16:43:28 +00:00
|
|
|
dissector_add_for_decode_as("udp.port", pana_handle);
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
eap_handle = find_dissector("eap");
|
2008-09-30 14:46:48 +00:00
|
|
|
/** if(!eap_handle) fprintf(stderr,"PANA warning: EAP dissector not found\n"); **/
|
2006-07-14 09:17:11 +00:00
|
|
|
|
|
|
|
}
|