2005-08-29 20:07:06 +00:00
|
|
|
/* packet-pres.c
|
|
|
|
* Routine to dissect ISO 8823 OSI Presentation Protocol packets
|
2010-01-04 23:17:37 +00:00
|
|
|
* Based on the dissector by
|
2005-08-29 20:07:06 +00:00
|
|
|
* Yuriy Sidelnikov <YSidelnikov@hotmail.com>
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-08-29 20:07:06 +00:00
|
|
|
* 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 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-08-29 20:07:06 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:29:52 +00:00
|
|
|
#include "config.h"
|
2005-08-29 20:07:06 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
2009-03-07 00:28:34 +00:00
|
|
|
#include <epan/prefs.h>
|
2005-08-29 20:07:06 +00:00
|
|
|
#include <epan/conversation.h>
|
2013-09-15 14:37:46 +00:00
|
|
|
#include <epan/wmem/wmem.h>
|
2009-03-07 00:28:34 +00:00
|
|
|
#include <epan/expert.h>
|
|
|
|
#include <epan/uat.h>
|
2005-08-29 20:07:06 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2007-05-13 20:58:29 +00:00
|
|
|
#include <epan/asn1.h>
|
2008-04-13 16:08:34 +00:00
|
|
|
#include <epan/oids.h>
|
2005-08-29 20:07:06 +00:00
|
|
|
#include "packet-ber.h"
|
|
|
|
#include "packet-ses.h"
|
|
|
|
#include "packet-pres.h"
|
2005-09-04 20:30:31 +00:00
|
|
|
#include "packet-rtse.h"
|
2005-08-29 20:07:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define PNAME "ISO 8823 OSI Presentation Protocol"
|
|
|
|
#define PSNAME "PRES"
|
|
|
|
#define PFNAME "pres"
|
|
|
|
|
2010-01-04 23:17:37 +00:00
|
|
|
#define CLPNAME "ISO 9576-1 OSI Connectionless Presentation Protocol"
|
|
|
|
#define CLPSNAME "CLPRES"
|
|
|
|
#define CLPFNAME "clpres"
|
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/* Initialize the protocol and registered fields */
|
2009-10-11 16:24:29 +00:00
|
|
|
static int proto_pres = -1;
|
2009-03-07 00:28:34 +00:00
|
|
|
|
2010-01-04 23:17:37 +00:00
|
|
|
/* Initialize the connectionles protocol */
|
|
|
|
static int proto_clpres = -1;
|
|
|
|
|
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/* type of session envelop */
|
|
|
|
static struct SESSION_DATA_STRUCTURE* session = NULL;
|
|
|
|
|
|
|
|
/* pointers for acse dissector */
|
|
|
|
proto_tree *global_tree = NULL;
|
|
|
|
packet_info *global_pinfo = NULL;
|
2005-09-04 09:00:01 +00:00
|
|
|
|
2005-11-14 10:02:31 +00:00
|
|
|
static const char *abstract_syntax_name_oid;
|
2005-08-31 20:20:56 +00:00
|
|
|
static guint32 presentation_context_identifier;
|
|
|
|
|
|
|
|
/* to keep track of presentation context identifiers and protocol-oids */
|
|
|
|
typedef struct _pres_ctx_oid_t {
|
|
|
|
guint32 ctx_id;
|
|
|
|
char *oid;
|
2007-06-27 17:51:19 +00:00
|
|
|
guint32 index;
|
2005-08-31 20:20:56 +00:00
|
|
|
} pres_ctx_oid_t;
|
|
|
|
static GHashTable *pres_ctx_oid_table = NULL;
|
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
typedef struct _pres_user_t {
|
|
|
|
guint ctx_id;
|
|
|
|
char *oid;
|
|
|
|
} pres_user_t;
|
|
|
|
|
|
|
|
static pres_user_t *pres_users;
|
|
|
|
static guint num_pres_users;
|
|
|
|
|
2005-09-06 18:08:45 +00:00
|
|
|
static int hf_pres_CP_type = -1;
|
|
|
|
static int hf_pres_CPA_PPDU = -1;
|
|
|
|
static int hf_pres_Abort_type = -1;
|
|
|
|
static int hf_pres_CPR_PPDU = -1;
|
|
|
|
static int hf_pres_Typed_data_type = -1;
|
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
#include "packet-pres-hf.c"
|
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_pres = -1;
|
|
|
|
|
|
|
|
#include "packet-pres-ett.c"
|
|
|
|
|
2013-06-03 03:42:36 +00:00
|
|
|
static expert_field ei_pres_dissector_not_available = EI_INIT;
|
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
UAT_DEC_CB_DEF(pres_users, ctx_id, pres_user_t)
|
|
|
|
UAT_CSTRING_CB_DEF(pres_users, oid, pres_user_t)
|
2005-08-31 20:20:56 +00:00
|
|
|
|
|
|
|
static guint
|
|
|
|
pres_ctx_oid_hash(gconstpointer k)
|
|
|
|
{
|
2005-09-04 09:00:01 +00:00
|
|
|
pres_ctx_oid_t *pco=(pres_ctx_oid_t *)k;
|
|
|
|
return pco->ctx_id;
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
2007-06-27 17:51:19 +00:00
|
|
|
|
2005-08-31 20:20:56 +00:00
|
|
|
static gint
|
|
|
|
pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2)
|
|
|
|
{
|
2005-09-04 09:00:01 +00:00
|
|
|
pres_ctx_oid_t *pco1=(pres_ctx_oid_t *)k1;
|
|
|
|
pres_ctx_oid_t *pco2=(pres_ctx_oid_t *)k2;
|
2007-06-27 17:51:19 +00:00
|
|
|
return (pco1->ctx_id==pco2->ctx_id && pco1->index==pco2->index);
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pres_init(void)
|
|
|
|
{
|
|
|
|
if( pres_ctx_oid_table ){
|
|
|
|
g_hash_table_destroy(pres_ctx_oid_table);
|
|
|
|
pres_ctx_oid_table = NULL;
|
|
|
|
}
|
|
|
|
pres_ctx_oid_table = g_hash_table_new(pres_ctx_oid_hash,
|
|
|
|
pres_ctx_oid_equal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-11-14 10:02:31 +00:00
|
|
|
register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid)
|
2005-08-31 20:20:56 +00:00
|
|
|
{
|
2005-09-04 09:00:01 +00:00
|
|
|
pres_ctx_oid_t *pco, *tmppco;
|
2007-06-27 17:51:19 +00:00
|
|
|
conversation_t *conversation;
|
2005-11-20 02:48:26 +00:00
|
|
|
|
|
|
|
if(!oid){
|
|
|
|
/* we did not get any oid name, malformed packet? */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-15 14:37:46 +00:00
|
|
|
pco=wmem_new(wmem_file_scope(), pres_ctx_oid_t);
|
2007-06-27 17:51:19 +00:00
|
|
|
pco->ctx_id=idx;
|
2013-09-15 14:37:46 +00:00
|
|
|
pco->oid=wmem_strdup(wmem_file_scope(), oid);
|
2010-01-04 23:17:37 +00:00
|
|
|
conversation=find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
|
2007-06-27 17:51:19 +00:00
|
|
|
pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
|
|
|
if (conversation) {
|
|
|
|
pco->index = conversation->index;
|
|
|
|
} else {
|
|
|
|
pco->index = 0;
|
|
|
|
}
|
2005-08-31 20:20:56 +00:00
|
|
|
|
|
|
|
/* if this ctx already exists, remove the old one first */
|
2005-09-04 09:00:01 +00:00
|
|
|
tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, pco);
|
|
|
|
if(tmppco){
|
|
|
|
g_hash_table_remove(pres_ctx_oid_table, tmppco);
|
|
|
|
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
2005-09-04 09:00:01 +00:00
|
|
|
g_hash_table_insert(pres_ctx_oid_table, pco, pco);
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
2009-03-07 00:28:34 +00:00
|
|
|
|
2012-12-12 15:17:36 +00:00
|
|
|
static char *
|
|
|
|
find_oid_in_users_table(packet_info *pinfo, guint32 ctx_id)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_pres_users; i++) {
|
|
|
|
pres_user_t *u = &(pres_users[i]);
|
|
|
|
|
|
|
|
if (u->ctx_id == ctx_id) {
|
|
|
|
/* Register oid so other dissectors can find this connection */
|
|
|
|
register_ctx_id_and_oid(pinfo, u->ctx_id, u->oid);
|
|
|
|
return u->oid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-04 09:00:01 +00:00
|
|
|
char *
|
2012-12-12 15:17:36 +00:00
|
|
|
find_oid_by_pres_ctx_id(packet_info *pinfo, guint32 idx)
|
2005-08-31 20:20:56 +00:00
|
|
|
{
|
2005-09-04 09:00:01 +00:00
|
|
|
pres_ctx_oid_t pco, *tmppco;
|
2007-06-27 17:51:19 +00:00
|
|
|
conversation_t *conversation;
|
|
|
|
|
2005-09-04 09:00:01 +00:00
|
|
|
pco.ctx_id=idx;
|
2010-01-04 23:17:37 +00:00
|
|
|
conversation=find_conversation (pinfo->fd->num, &pinfo->src, &pinfo->dst,
|
2007-06-27 17:51:19 +00:00
|
|
|
pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
|
|
|
|
if (conversation) {
|
|
|
|
pco.index = conversation->index;
|
|
|
|
} else {
|
|
|
|
pco.index = 0;
|
|
|
|
}
|
|
|
|
|
2005-09-04 09:00:01 +00:00
|
|
|
tmppco=(pres_ctx_oid_t *)g_hash_table_lookup(pres_ctx_oid_table, &pco);
|
|
|
|
if(tmppco){
|
|
|
|
return tmppco->oid;
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
2012-12-12 15:17:36 +00:00
|
|
|
|
|
|
|
return find_oid_in_users_table(pinfo, idx);
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
static void *
|
2010-10-29 21:51:59 +00:00
|
|
|
pres_copy_cb(void *dest, const void *orig, size_t len _U_)
|
2009-03-07 00:28:34 +00:00
|
|
|
{
|
2013-03-19 21:22:31 +00:00
|
|
|
pres_user_t *u = (pres_user_t *)dest;
|
|
|
|
const pres_user_t *o = (const pres_user_t *)orig;
|
2009-03-07 00:28:34 +00:00
|
|
|
|
2009-03-13 22:21:22 +00:00
|
|
|
u->ctx_id = o->ctx_id;
|
2009-03-07 00:28:34 +00:00
|
|
|
u->oid = g_strdup(o->oid);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pres_free_cb(void *r)
|
|
|
|
{
|
2013-03-19 21:22:31 +00:00
|
|
|
pres_user_t *u = (pres_user_t *)r;
|
2009-03-07 00:28:34 +00:00
|
|
|
|
2009-03-13 22:21:22 +00:00
|
|
|
g_free(u->oid);
|
2009-03-07 00:28:34 +00:00
|
|
|
}
|
|
|
|
|
2005-08-31 20:20:56 +00:00
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
#include "packet-pres-fn.c"
|
|
|
|
|
2005-08-31 20:20:56 +00:00
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/*
|
|
|
|
* Dissect an PPDU.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
dissect_ppdu(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2009-03-07 00:28:34 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *pres_tree = NULL;
|
|
|
|
asn1_ctx_t asn1_ctx;
|
|
|
|
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
|
2007-05-13 20:58:29 +00:00
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
/* do we have spdu type from the session dissector? */
|
2005-08-31 20:20:56 +00:00
|
|
|
if( !pinfo->private_data ){
|
|
|
|
if(tree){
|
|
|
|
proto_tree_add_text(tree, tvb, offset, -1,
|
|
|
|
"Internal error:can't get spdu type from session dissector.");
|
2010-01-20 12:51:04 +00:00
|
|
|
return 0;
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
|
|
|
|
if(session->spdu_type == 0 ){
|
|
|
|
if(tree){
|
|
|
|
proto_tree_add_text(tree, tvb, offset, -1,
|
|
|
|
"Internal error:wrong spdu type %x from session dissector.",session->spdu_type);
|
2010-01-20 12:51:04 +00:00
|
|
|
return 0;
|
2005-08-31 20:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-01-20 12:51:04 +00:00
|
|
|
/* set up type of PPDU */
|
2010-09-20 12:49:52 +00:00
|
|
|
col_add_str(pinfo->cinfo, COL_INFO,
|
|
|
|
val_to_str(session->spdu_type, ses_vals, "Unknown PPDU type (0x%02x)"));
|
2009-03-07 00:28:34 +00:00
|
|
|
if (tree){
|
2011-07-19 18:48:31 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_pres, tvb, offset, -1, ENC_NA);
|
2009-03-07 00:28:34 +00:00
|
|
|
pres_tree = proto_item_add_subtree(ti, ett_pres);
|
|
|
|
}
|
2005-08-29 20:07:06 +00:00
|
|
|
|
2005-08-31 20:20:56 +00:00
|
|
|
switch(session->spdu_type){
|
2005-08-29 20:07:06 +00:00
|
|
|
case SES_CONNECTION_REQUEST:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_CP_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CP_type);
|
2005-08-29 20:07:06 +00:00
|
|
|
break;
|
|
|
|
case SES_CONNECTION_ACCEPT:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_CPA_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CPA_PPDU);
|
2005-08-29 20:07:06 +00:00
|
|
|
break;
|
|
|
|
case SES_ABORT:
|
2005-09-06 18:08:45 +00:00
|
|
|
case SES_ABORT_ACCEPT:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_Abort_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_Abort_type);
|
2005-08-29 20:07:06 +00:00
|
|
|
break;
|
|
|
|
case SES_DATA_TRANSFER:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_CPC_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_user_data);
|
2005-09-06 18:08:45 +00:00
|
|
|
break;
|
|
|
|
case SES_TYPED_DATA:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_Typed_data_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_Typed_data_type);
|
2005-09-06 18:08:45 +00:00
|
|
|
break;
|
|
|
|
case SES_RESYNCHRONIZE:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_RS_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, -1);
|
2005-09-06 18:08:45 +00:00
|
|
|
break;
|
|
|
|
case SES_RESYNCHRONIZE_ACK:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_RSA_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, -1);
|
2005-08-29 20:07:06 +00:00
|
|
|
break;
|
2005-10-13 05:20:40 +00:00
|
|
|
case SES_REFUSE:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_CPR_PPDU(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_CPR_PPDU);
|
2005-10-13 05:20:40 +00:00
|
|
|
break;
|
2005-08-29 20:07:06 +00:00
|
|
|
default:
|
2007-05-13 20:58:29 +00:00
|
|
|
offset = dissect_pres_CPC_type(FALSE, tvb, offset, &asn1_ctx, pres_tree, hf_pres_user_data);
|
2005-08-29 20:07:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2009-10-07 07:47:41 +00:00
|
|
|
static void
|
2005-08-29 20:07:06 +00:00
|
|
|
dissect_pres(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
|
|
|
|
{
|
2005-08-30 19:43:32 +00:00
|
|
|
int offset = 0, old_offset;
|
2009-03-07 00:28:34 +00:00
|
|
|
|
2010-01-04 23:17:37 +00:00
|
|
|
session = ((struct SESSION_DATA_STRUCTURE*)(pinfo->private_data));
|
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
/* first, try to check length */
|
|
|
|
/* do we have at least 4 bytes */
|
2005-08-29 20:07:06 +00:00
|
|
|
if (!tvb_bytes_exist(tvb, 0, 4)){
|
2007-06-24 05:28:27 +00:00
|
|
|
if (session && session->spdu_type != SES_MAJOR_SYNC_POINT) {
|
2010-01-04 23:17:37 +00:00
|
|
|
proto_tree_add_text(parent_tree, tvb, offset,
|
2007-06-24 05:28:27 +00:00
|
|
|
tvb_reported_length_remaining(tvb,offset),"User data");
|
|
|
|
return; /* no, it isn't a presentation PDU */
|
|
|
|
}
|
2005-08-29 20:07:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-04 23:17:37 +00:00
|
|
|
/* save pointers for calling the acse dissector */
|
|
|
|
global_tree = parent_tree;
|
|
|
|
global_pinfo = pinfo;
|
|
|
|
|
|
|
|
/* if the session unit-data packet then we process it */
|
|
|
|
/* as a connectionless presentation protocol unit data */
|
|
|
|
if(session && session->spdu_type == CLSES_UNIT_DATA)
|
|
|
|
{
|
|
|
|
proto_tree * clpres_tree = NULL;
|
|
|
|
proto_item *ti;
|
|
|
|
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CL-PRES");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
|
|
|
|
if (parent_tree)
|
|
|
|
{
|
2011-07-19 18:48:31 +00:00
|
|
|
ti = proto_tree_add_item(parent_tree, proto_clpres, tvb, offset, -1, ENC_NA);
|
2010-01-04 23:17:37 +00:00
|
|
|
clpres_tree = proto_item_add_subtree(ti, ett_pres);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dissect the packet */
|
|
|
|
dissect_UD_type_PDU(tvb, pinfo, clpres_tree);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/* we can't make any additional checking here */
|
|
|
|
/* postpone it before dissector will have more information */
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PRES");
|
2009-08-09 07:36:13 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2005-08-29 20:07:06 +00:00
|
|
|
|
2007-06-24 05:28:27 +00:00
|
|
|
if (session && session->spdu_type == SES_MAJOR_SYNC_POINT) {
|
|
|
|
/* This is a reassembly initiated in packet-ses */
|
|
|
|
char *oid = find_oid_by_pres_ctx_id (pinfo, session->pres_ctx_id);
|
|
|
|
if (oid) {
|
|
|
|
call_ber_oid_callback (oid, tvb, offset, pinfo, parent_tree);
|
|
|
|
} else {
|
2010-01-04 23:17:37 +00:00
|
|
|
proto_tree_add_text(parent_tree, tvb, offset,
|
2007-06-24 05:28:27 +00:00
|
|
|
tvb_reported_length_remaining(tvb,offset),"User data");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2010-01-04 23:17:37 +00:00
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
while (tvb_reported_length_remaining(tvb, offset) > 0){
|
2005-08-30 19:43:32 +00:00
|
|
|
old_offset = offset;
|
2005-08-29 20:07:06 +00:00
|
|
|
offset = dissect_ppdu(tvb, offset, pinfo, parent_tree);
|
2005-08-30 19:43:32 +00:00
|
|
|
if(offset <= old_offset){
|
|
|
|
proto_tree_add_text(parent_tree, tvb, offset, -1,"Invalid offset");
|
|
|
|
THROW(ReportedBoundsError);
|
2005-08-29 20:07:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--- proto_register_pres -------------------------------------------*/
|
|
|
|
void proto_register_pres(void) {
|
|
|
|
|
|
|
|
/* List of fields */
|
|
|
|
static hf_register_info hf[] = {
|
2005-09-06 18:08:45 +00:00
|
|
|
{ &hf_pres_CP_type,
|
|
|
|
{ "CP-type", "pres.cptype",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0,
|
2009-06-22 06:02:36 +00:00
|
|
|
NULL, HFILL }},
|
2005-09-06 18:08:45 +00:00
|
|
|
{ &hf_pres_CPA_PPDU,
|
|
|
|
{ "CPA-PPDU", "pres.cpapdu",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0,
|
2009-06-22 06:02:36 +00:00
|
|
|
NULL, HFILL }},
|
2005-09-06 18:08:45 +00:00
|
|
|
{ &hf_pres_Abort_type,
|
|
|
|
{ "Abort type", "pres.aborttype",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(pres_Abort_type_vals), 0,
|
2009-06-22 06:02:36 +00:00
|
|
|
NULL, HFILL }},
|
2005-09-06 18:08:45 +00:00
|
|
|
{ &hf_pres_CPR_PPDU,
|
|
|
|
{ "CPR-PPDU", "pres.cprtype",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(pres_CPR_PPDU_vals), 0,
|
2009-06-22 06:02:36 +00:00
|
|
|
NULL, HFILL }},
|
2005-09-06 18:08:45 +00:00
|
|
|
{ &hf_pres_Typed_data_type,
|
|
|
|
{ "Typed data type", "pres.Typed_data_type",
|
|
|
|
FT_UINT32, BASE_DEC, VALS(pres_Typed_data_type_vals), 0,
|
2009-06-22 06:02:36 +00:00
|
|
|
NULL, HFILL }},
|
2005-09-06 18:08:45 +00:00
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
|
|
|
|
#include "packet-pres-hfarr.c"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* List of subtrees */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_pres,
|
|
|
|
#include "packet-pres-ettarr.c"
|
|
|
|
};
|
2010-01-04 23:17:37 +00:00
|
|
|
|
2013-06-03 03:42:36 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_pres_dissector_not_available, { "pres.dissector_not_available", PI_UNDECODED, PI_WARN, "Dissector is not available", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
static uat_field_t users_flds[] = {
|
|
|
|
UAT_FLD_DEC(pres_users,ctx_id,"Context Id","Presentation Context Identifier"),
|
|
|
|
UAT_FLD_CSTRING(pres_users,oid,"Syntax Name OID","Abstract Syntax Name (Object Identifier)"),
|
|
|
|
UAT_END_FIELDS
|
|
|
|
};
|
2005-08-29 20:07:06 +00:00
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
uat_t* users_uat = uat_new("PRES Users Context List",
|
|
|
|
sizeof(pres_user_t),
|
|
|
|
"pres_context_list",
|
|
|
|
TRUE,
|
2013-03-19 21:22:31 +00:00
|
|
|
(void**) &pres_users,
|
2009-03-07 00:28:34 +00:00
|
|
|
&num_pres_users,
|
UATs could be put into "categories". The categories were defined only
implicitly by the #define name and string they were defined to; not all
UATs neatly fit into any of the categories, so some of them were put
into categories that weren't obviously correct for them, and one - the
display filter macro UAT - wasn't put into any category at all (which
caused crashes when editing them, as the GUI code that handled UAT
changes from a dialog assumed the category field was non-null).
The category was, in practice, used only to decide, in the
aforementioned GUI code, whether the packet summary pane needed to be
updated or not. It also offered no option of "don't update the packet
summary pane *and* don't redissect anything", which is what would be
appropriate for the display filter macro UAT.
Replace the category with a set of fields indicating what the UAT
affects; we currently offer "dissection", which applies to most UATs
(any UAT in libwireshark presumably affects dissection at a minimum) and
"the set of named fields that exist". Changing any UAT that affects
dissection requires a redissection; changing any UAT that affects the
set of named fields that exist requires a redissection *and* rebuilding
the packet summary pane.
Perhaps we also need "filtering", so that if you change a display filter
macro, we re-filter, in case the display is currently filtered with a
display filter that uses a macro that changed.
svn path=/trunk/; revision=43603
2012-07-08 01:00:46 +00:00
|
|
|
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
|
2009-03-07 00:28:34 +00:00
|
|
|
"ChPresContextList",
|
|
|
|
pres_copy_cb,
|
|
|
|
NULL,
|
|
|
|
pres_free_cb,
|
2010-03-04 12:50:18 +00:00
|
|
|
NULL,
|
2009-03-07 00:28:34 +00:00
|
|
|
users_flds);
|
2010-01-04 23:17:37 +00:00
|
|
|
|
2013-06-03 03:42:36 +00:00
|
|
|
expert_module_t* expert_pres;
|
|
|
|
module_t *pres_module;
|
2010-01-04 23:17:37 +00:00
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/* Register protocol */
|
|
|
|
proto_pres = proto_register_protocol(PNAME, PSNAME, PFNAME);
|
|
|
|
register_dissector("pres", dissect_pres, proto_pres);
|
2010-01-04 23:17:37 +00:00
|
|
|
|
|
|
|
/* Register connectionless protocol (just for the description) */
|
|
|
|
proto_clpres = proto_register_protocol(CLPNAME, CLPSNAME, CLPFNAME);
|
|
|
|
|
2005-08-29 20:07:06 +00:00
|
|
|
/* Register fields and subtrees */
|
|
|
|
proto_register_field_array(proto_pres, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-06-03 03:42:36 +00:00
|
|
|
expert_pres = expert_register_protocol(proto_pres);
|
|
|
|
expert_register_field_array(expert_pres, ei, array_length(ei));
|
2005-08-31 20:20:56 +00:00
|
|
|
register_init_routine(pres_init);
|
2005-08-29 20:07:06 +00:00
|
|
|
|
2009-03-07 00:28:34 +00:00
|
|
|
pres_module = prefs_register_protocol(proto_pres, NULL);
|
|
|
|
|
|
|
|
prefs_register_uat_preference(pres_module, "users_table", "Users Context List",
|
|
|
|
"A table that enumerates user protocols to be used against"
|
|
|
|
" specific presentation context identifiers",
|
|
|
|
users_uat);
|
2005-08-29 20:07:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--- proto_reg_handoff_pres ---------------------------------------*/
|
|
|
|
void proto_reg_handoff_pres(void) {
|
|
|
|
|
2010-01-04 23:17:37 +00:00
|
|
|
/* register_ber_oid_dissector("0.4.0.0.1.1.1.1", dissect_pres, proto_pres,
|
2005-08-29 20:07:06 +00:00
|
|
|
"itu-t(0) identified-organization(4) etsi(0) mobileDomain(0) gsm-Network(1) abstractSyntax(1) pres(1) version1(1)"); */
|
|
|
|
|
|
|
|
}
|