forked from osmocom/wireshark
MATE has a grammar.
Although not yet fully implemented I want this version as a reference. svn path=/trunk/; revision=14373
This commit is contained in:
parent
a14646212b
commit
047baf2c38
|
@ -27,7 +27,8 @@ INCLUDES = -I$(top_srcdir)
|
|||
plugindir = @plugindir@
|
||||
|
||||
plugin_LTLIBRARIES = mate.la
|
||||
mate_la_SOURCES = moduleinfo.h mate.h mate_util.h packet-mate.c mate_runtime.c mate_setup.c mate_util.c mate_plugin.c
|
||||
mate_la_SOURCES = moduleinfo.h mate.h mate_util.h mate_grammar.h \
|
||||
packet-mate.c mate_runtime.c mate_setup.c mate_util.c mate_plugin.c mate_grammar.c mate_parser.c
|
||||
mate_la_LDFLAGS = -module -avoid-version
|
||||
mate_la_LIBADD = @PLUGIN_LIBS@
|
||||
|
||||
|
@ -41,4 +42,17 @@ CLEANFILES = \
|
|||
*~
|
||||
|
||||
EXTRA_DIST = \
|
||||
mate_grammar.lemon \
|
||||
mate_parser.l \
|
||||
Makefile.nmake
|
||||
|
||||
mate_parser.c : mate_parser.l
|
||||
$(LEX) -Pdf_ -omate_parser.c $(srcdir)/mate_parser.l
|
||||
|
||||
LEMON = ../../tools/lemon
|
||||
|
||||
mate_grammar.h : mate_grammar.c
|
||||
mate_grammar.c : mate_grammar.lemon mate.h mate_util.h
|
||||
$(LEMON)/lemon t=$(srcdir)/$(LEMON)/lempar.c $(srcdir)/mate_grammar.lemon || \
|
||||
(rm -f grammar.c grammar.h ; false)
|
||||
|
||||
|
|
|
@ -68,196 +68,145 @@
|
|||
|
||||
#define MATE_ITEM_ID_SIZE 24
|
||||
|
||||
/* Config AVP Names */
|
||||
#define KEYWORD_ACTION "Action"
|
||||
#define KEYWORD_SETTINGS "Settings"
|
||||
#define KEYWORD_INCLUDE "Include"
|
||||
#define KEYWORD_TRANSFORM "Transform"
|
||||
#define KEYWORD_PDU "PduDef"
|
||||
#define KEYWORD_PDUCRITERIA "PduCriteria"
|
||||
#define KEYWORD_PDUEXTRA "PduExtra"
|
||||
#define KEYWORD_PDUTRANSFORM "PduTransform"
|
||||
#define KEYWORD_GOP "GopDef"
|
||||
#define KEYWORD_GOPSTART "GopStart"
|
||||
#define KEYWORD_GOPSTOP "GopStop"
|
||||
#define KEYWORD_GOPEXTRA "GopExtra"
|
||||
#define KEYWORD_GOPTRANSFORM "GopTransform"
|
||||
#define KEYWORD_GOGDEF "GogDef"
|
||||
#define KEYWORD_GOGKEY "GogKey"
|
||||
#define KEYWORD_GOGEXTRA "GogExtra"
|
||||
#define KEYWORD_GOGTRANSFORM "GogTransform"
|
||||
#define KEYWORD_NAME "Name"
|
||||
#define KEYWORD_ON "On"
|
||||
#define KEYWORD_FOR "For"
|
||||
#define KEYWORD_FROM "From"
|
||||
#define KEYWORD_TO "To"
|
||||
#define KEYWORD_MATCH "Match"
|
||||
#define KEYWORD_MODE "Mode"
|
||||
#define KEYWORD_FILENAME "Filename"
|
||||
#define KEYWORD_PROTO "Proto"
|
||||
#define KEYWORD_METHOD "Method"
|
||||
#define KEYWORD_TRANSPORT "Transport"
|
||||
#define KEYWORD_PAYLOAD "Payload"
|
||||
#define KEYWORD_STRICT "Strict"
|
||||
#define KEYWORD_LOOSE "Loose"
|
||||
#define KEYWORD_EVERY "Every"
|
||||
#define KEYWORD_REPLACE "Replace"
|
||||
#define KEYWORD_INSERT "Insert"
|
||||
#define KEYWORD_MAP "Map"
|
||||
#define KEYWORD_GOGEXPIRE "GogExpiration"
|
||||
#define KEYWORD_GOPTREE "GopTree"
|
||||
#define KEYWORD_DISCARDPDU "DiscardPduData"
|
||||
#define KEYWORD_LIBPATH "ThingLibPath"
|
||||
#define KEYWORD_SHOWPDUTREE "ShowPduTree"
|
||||
#define KEYWORD_SHOWGOPTIMES "ShowGopTimes"
|
||||
#define KEYWORD_STOP "Stop"
|
||||
#define KEYWORD_DROPGOP "DiscardUnassignedGop"
|
||||
#define KEYWORD_DROPPDU "DiscardUnassignedPdu"
|
||||
#define KEYWORD_LIB "Lib"
|
||||
#define KEYWORD_ACCEPT "Accept"
|
||||
#define KEYWORD_REJECT "Reject"
|
||||
#define KEYWORD_NOTREE "NoTree"
|
||||
#define KEYWORD_BASICTREE "BasicTree"
|
||||
#define KEYWORD_FULLTREE "FullTree"
|
||||
#define KEYWORD_PDUTREE "PduTree"
|
||||
#define KEYWORD_FRAMETREE "FrameTree"
|
||||
#define KEYWORD_GOPEXPIRATION "GopExpiration"
|
||||
#define KEYWORD_GOPIDLETIMEOUT "GopIdleTimeout"
|
||||
#define KEYWORD_GOPLIFETIME "GopLifetime"
|
||||
|
||||
#define KEYWORD_DEBUGFILENAME "Debug_File"
|
||||
#define KEYWORD_DBG_GENERAL "Debug_General"
|
||||
#define KEYWORD_DBG_CFG "Debug_Cfg"
|
||||
#define KEYWORD_DBG_PDU "Debug_Pdu"
|
||||
#define KEYWORD_DBG_GOP "Debug_Gop"
|
||||
#define KEYWORD_DBG_GOG "Debug_Gog"
|
||||
#ifdef _AVP_DEBUGGING
|
||||
#define KEYWORD_DBG_AVPLIB "Debug_AVP_Lib"
|
||||
#define KEYWORD_DBG_AVP "Debug_AVP"
|
||||
#define KEYWORD_DBG_AVP_OP "Debug_AVP_Op"
|
||||
#define KEYWORD_DBG_AVPL "Debug_AVPL"
|
||||
#define KEYWORD_DBG_AVPL_OP "Debug_AVPL_Op"
|
||||
#endif
|
||||
|
||||
#define VALUE_TOO ((void*)1)
|
||||
|
||||
typedef enum _mate_item_type {
|
||||
MATE_UNK_TYPE,
|
||||
MATE_PDU_TYPE,
|
||||
MATE_GOP_TYPE,
|
||||
MATE_GOG_TYPE
|
||||
} mate_item_type;
|
||||
#define MateConfigError 65535
|
||||
|
||||
typedef struct _mate_cfg_item mate_cfg_pdu;
|
||||
typedef struct _mate_cfg_item mate_cfg_gop;
|
||||
typedef struct _mate_cfg_item mate_cfg_gog;
|
||||
typedef enum _gop_tree_mode_t {
|
||||
GOP_NULL_TREE,
|
||||
GOP_BASIC_TREE,
|
||||
GOP_FULL_TREE
|
||||
} gop_tree_mode_t;
|
||||
|
||||
typedef struct _mate_item mate_item;
|
||||
typedef struct _mate_item mate_pdu;
|
||||
typedef struct _mate_item mate_gop;
|
||||
typedef struct _mate_item mate_gog;
|
||||
typedef enum _gop_pdu_tree {
|
||||
GOP_NO_TREE,
|
||||
GOP_PDU_TREE,
|
||||
GOP_FRAME_TREE,
|
||||
GOP_BASIC_PDU_TREE
|
||||
} gop_pdu_tree_t;
|
||||
|
||||
typedef struct _mate_cfg_item {
|
||||
guint8* name;
|
||||
mate_item_type type;
|
||||
GPtrArray* transforms; /* transformations to be applied */
|
||||
AVPL* extra; /* attributes to be added */
|
||||
typedef enum _accept_mode_t {
|
||||
ACCEPT_MODE,
|
||||
REJECT_MODE
|
||||
} accept_mode_t;
|
||||
|
||||
|
||||
typedef struct _mate_cfg_pdu {
|
||||
gchar* name;
|
||||
guint last_id; /* keeps the last id given to an item of this kind */
|
||||
int hfid;
|
||||
GHashTable* my_hfids; /* for creating register info */
|
||||
|
||||
GHashTable* items; /* all the items of this type */
|
||||
GPtrArray* transforms; /* transformations to be applied */
|
||||
|
||||
int hfid;
|
||||
|
||||
int hfid_proto;
|
||||
int hfid_pdu_rel_time;
|
||||
int hfid_pdu_time_in_gop;
|
||||
|
||||
GHashTable* my_hfids; /* for creating register info */
|
||||
|
||||
gint ett;
|
||||
gint ett_attr;
|
||||
|
||||
GHashTable* hfids_attr; /* k=hfid v=avp_name */
|
||||
|
||||
gboolean discard;
|
||||
gboolean last_extracted;
|
||||
gboolean drop_unassigned;
|
||||
|
||||
GPtrArray* transport_ranges; /* hfids of candidate transport ranges from which to extract attributes */
|
||||
GPtrArray* payload_ranges; /* hfids of candidate payload ranges from which to extract attributes */
|
||||
|
||||
avpl_match_mode criterium_match_mode;
|
||||
accept_mode_t criterium_accept_mode;
|
||||
AVPL* criterium;
|
||||
} mate_cfg_pdu;
|
||||
|
||||
|
||||
typedef struct _mate_cfg_gop {
|
||||
gchar* name;
|
||||
guint last_id; /* keeps the last id given to an item of this kind */
|
||||
GHashTable* items; /* all the items of this type */
|
||||
|
||||
GPtrArray* transforms; /* transformations to be applied */
|
||||
gchar* on_pdu;
|
||||
|
||||
AVPL* key; /* key candidate avpl */
|
||||
AVPL* start; /* start candidate avpl */
|
||||
AVPL* stop; /* stop candidate avpl */
|
||||
AVPL* extra; /* attributes to be added */
|
||||
|
||||
float expiration;
|
||||
float idle_timeout;
|
||||
float lifetime;
|
||||
|
||||
gboolean drop_unassigned;
|
||||
gop_pdu_tree_t pdu_tree_mode;
|
||||
gboolean show_times;
|
||||
|
||||
GHashTable* my_hfids; /* for creating register info */
|
||||
int hfid;
|
||||
int hfid_start_time;
|
||||
int hfid_stop_time;
|
||||
int hfid_last_time;
|
||||
int hfid_gop_pdu;
|
||||
int hfid_gop_num_pdus;
|
||||
|
||||
gint ett;
|
||||
gint ett_attr;
|
||||
gint ett_times;
|
||||
gint ett_children;
|
||||
|
||||
/* pdu */
|
||||
gboolean discard_pdu_attributes;
|
||||
gboolean last_to_be_created;
|
||||
int hfid_proto;
|
||||
GPtrArray* transport_ranges; /* hfids of candidate transport ranges from which to extract attributes */
|
||||
GPtrArray* payload_ranges; /* hfids of candidate payload ranges from which to extract attributes */
|
||||
GHashTable* hfids_attr; /* k=hfid v=avp_name */
|
||||
gboolean drop_pdu;
|
||||
avpl_match_mode criterium_match_mode;
|
||||
AVPL* criterium; /* must match to be created */
|
||||
int hfid_pdu_rel_time;
|
||||
int hfid_pdu_time_in_gop;
|
||||
|
||||
|
||||
/* common to gop and gog */
|
||||
float expiration;
|
||||
int hfid_start_time;
|
||||
int hfid_stop_time;
|
||||
int hfid_last_time;
|
||||
|
||||
/* gop */
|
||||
AVPL* start; /* start candidate avpl */
|
||||
AVPL* stop; /* stop candidate avpl */
|
||||
AVPL* key; /* key candidate avpl */
|
||||
guint8* show_pdu_tree;
|
||||
gboolean show_times;
|
||||
gboolean drop_gop;
|
||||
float idle_timeout;
|
||||
float lifetime;
|
||||
int hfid_gop_pdu;
|
||||
int hfid_gop_num_pdus;
|
||||
|
||||
GHashTable* gop_index;
|
||||
GHashTable* gog_index;
|
||||
} mate_cfg_gop;
|
||||
|
||||
|
||||
typedef struct _mate_cfg_gog {
|
||||
gchar* name;
|
||||
|
||||
GHashTable* items; /* all the items of this type */
|
||||
guint last_id; /* keeps the last id given to an item of this kind */
|
||||
|
||||
/* gog */
|
||||
guint8* gop_as_subtree;
|
||||
GPtrArray* transforms; /* transformations to be applied */
|
||||
|
||||
LoAL* keys;
|
||||
AVPL* extra; /* attributes to be added */
|
||||
|
||||
float expiration;
|
||||
gop_tree_mode_t gop_tree_mode;
|
||||
gboolean show_times;
|
||||
|
||||
GHashTable* my_hfids; /* for creating register info */
|
||||
int hfid;
|
||||
int hfid_gog_num_of_gops;
|
||||
int hfid_gog_gop;
|
||||
int hfid_gog_gopstart;
|
||||
int hfid_gog_gopstop;
|
||||
int hfid_start_time;
|
||||
int hfid_stop_time;
|
||||
int hfid_last_time;
|
||||
gint ett;
|
||||
gint ett_attr;
|
||||
gint ett_times;
|
||||
gint ett_children;
|
||||
gint ett_gog_gop;
|
||||
|
||||
} mate_cfg_item;
|
||||
} mate_cfg_gog;
|
||||
|
||||
typedef struct _mate_config {
|
||||
/* current defaults */
|
||||
float gog_expiration; /* default expirations for gogs if undefined in gog */
|
||||
gboolean discard_pdu_attributes; /* destroy the pdu's avpl once analyzed */
|
||||
gboolean drop_pdu; /* destroy the pdu if not assign to a gop */
|
||||
gboolean drop_gop; /* destroy the gop if not assign to a gog */
|
||||
guint8* mate_lib_path; /* where to look for "Include" files first */
|
||||
guint8* show_pdu_tree;
|
||||
gboolean show_times;
|
||||
gboolean last_to_be_created;
|
||||
avpl_match_mode match_mode;
|
||||
avpl_replace_mode replace_mode;
|
||||
guint8* gop_as_subtree;
|
||||
gchar* mate_config_file; /* name of the config file */
|
||||
|
||||
int hfid_mate;
|
||||
|
||||
float gop_expiration;
|
||||
float gop_idle_timeout;
|
||||
float gop_lifetime;
|
||||
GString* fields_filter; /* "ip.addr || dns.id || ... " for the tap */
|
||||
GString* protos_filter; /* "dns || ftp || ..." for the tap */
|
||||
gchar* tap_filter;
|
||||
|
||||
/* text "constants" */
|
||||
guint8* accept;
|
||||
guint8* reject;
|
||||
guint8* no_tree;
|
||||
guint8* frame_tree;
|
||||
guint8* pdu_tree;
|
||||
guint8* full_tree;
|
||||
guint8* basic_tree;
|
||||
|
||||
/* what to dbgprint */
|
||||
int dbg_lvl;
|
||||
int dbg_cfg_lvl;
|
||||
int dbg_pdu_lvl;
|
||||
int dbg_gop_lvl;
|
||||
int dbg_gog_lvl;
|
||||
|
||||
guint8* mate_config_file; /* name of the config file */
|
||||
GString* mate_attrs_filter; /* "ip.addr || dns.id || ... " for the tap */
|
||||
GString* mate_protos_filter; /* "dns || ftp || ..." for the tap */
|
||||
FILE* dbg_facility; /* where to dump dbgprint output g_message if null */
|
||||
guint8* tap_filter;
|
||||
|
||||
|
||||
gchar* mate_lib_path; /* where to look for "Include" files first */
|
||||
|
||||
GHashTable* pducfgs; /* k=pducfg->name v=pducfg */
|
||||
GHashTable* gopcfgs; /* k=gopcfg->name v=gopcfg */
|
||||
GHashTable* gogcfgs; /* k=gogcfg->name v=gogcfg */
|
||||
|
@ -266,12 +215,58 @@ typedef struct _mate_config {
|
|||
GPtrArray* pducfglist; /* pducfgs in order of "execution" */
|
||||
GHashTable* gops_by_pduname; /* k=pducfg->name v=gopcfg */
|
||||
GHashTable* gogs_by_gopname; /* k=gopname v=loal where avpl->name == matchedgop->name */
|
||||
|
||||
|
||||
GArray* hfrs;
|
||||
gint ett_root;
|
||||
GArray* ett;
|
||||
|
||||
/* defaults */
|
||||
struct _mate_cfg_defaults {
|
||||
struct _pdu_defaults {
|
||||
avpl_match_mode match_mode;
|
||||
avpl_replace_mode replace_mode;
|
||||
gboolean last_extracted;
|
||||
|
||||
gboolean drop_unassigned;
|
||||
gboolean discard;
|
||||
} pdu;
|
||||
|
||||
struct _gop_defaults {
|
||||
float expiration;
|
||||
float idle_timeout;
|
||||
float lifetime;
|
||||
|
||||
gop_pdu_tree_t pdu_tree_mode;
|
||||
gboolean show_times;
|
||||
gboolean drop_unassigned;
|
||||
|
||||
} gop;
|
||||
|
||||
struct _gog_defaults {
|
||||
float expiration;
|
||||
|
||||
gop_tree_mode_t gop_tree_mode;
|
||||
} gog;
|
||||
} defaults;
|
||||
|
||||
/* what to dbgprint */
|
||||
int dbg_lvl;
|
||||
int dbg_pdu_lvl;
|
||||
int dbg_gop_lvl;
|
||||
int dbg_gog_lvl;
|
||||
|
||||
GPtrArray* config_stack;
|
||||
GString* config_error;
|
||||
|
||||
} mate_config;
|
||||
|
||||
|
||||
typedef struct _mate_config_frame {
|
||||
gchar* filename;
|
||||
guint linenum;
|
||||
} mate_config_frame;
|
||||
|
||||
|
||||
typedef struct _mate_runtime_data {
|
||||
guint current_items; /* a count of items */
|
||||
GMemChunk* mate_items;
|
||||
|
@ -282,70 +277,113 @@ typedef struct _mate_runtime_data {
|
|||
|
||||
} mate_runtime_data;
|
||||
|
||||
/* these are used to contain information regarding pdus, gops and gogs */
|
||||
struct _mate_item {
|
||||
/* all three of them */
|
||||
guint32 id; /* 1:1 -> saving a g_malloc */
|
||||
mate_cfg_item* cfg; /* the type of this item */
|
||||
typedef struct _mate_pdu mate_pdu;
|
||||
typedef struct _mate_gop mate_gop;
|
||||
typedef struct _mate_gog mate_gog;
|
||||
|
||||
/* these are used to contain information regarding pdus, gops and gogs */
|
||||
struct _mate_pdu {
|
||||
guint32 id; /* 1:1 -> saving a g_malloc */
|
||||
mate_cfg_pdu* cfg; /* the type of this item */
|
||||
|
||||
AVPL* avpl;
|
||||
|
||||
guint32 frame; /* wich frame I belog to? */
|
||||
mate_pdu* next_in_frame; /* points to the next pdu in this frame */
|
||||
float rel_time; /* time since start of capture */
|
||||
|
||||
mate_gop* gop; /* the gop the pdu belongs to (if any) */
|
||||
mate_pdu* next; /* next in gop */
|
||||
float time_in_gop; /* time since gop start */
|
||||
|
||||
gboolean first; /* is this the first pdu in this frame? */
|
||||
gboolean is_start; /* this is the start pdu for this gop */
|
||||
gboolean is_stop; /* this is the stop pdu for this gop */
|
||||
gboolean after_release; /* this pdu comes after the stop */
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct _mate_gop {
|
||||
guint32 id;
|
||||
mate_cfg_gop* cfg;
|
||||
|
||||
guint8* gop_key;
|
||||
AVPL* avpl; /* the attributes of the pdu/gop/gog */
|
||||
|
||||
mate_item* next; /* in pdu: next in gop; in gop: next in gog; in gog this doesn't make any sense yet */
|
||||
guint last_n;
|
||||
|
||||
mate_gog* gog; /* the gog of a gop */
|
||||
mate_gop* next; /* next in gog; */
|
||||
|
||||
float expiration; /* when will it expire after release (all gops releases if gog)? */
|
||||
float idle_expiration; /* when will it expire if no new pdus are assigned to it */
|
||||
float time_to_die;
|
||||
float time_to_timeout;
|
||||
|
||||
float start_time; /* time of start */
|
||||
float release_time; /* when this gop/gog was released */
|
||||
float last_time; /* the rel_time at which the last pdu has been added (to gop or gog's gop) */
|
||||
|
||||
|
||||
int num_of_pdus; /* how many gops a gog has? */
|
||||
int num_of_after_release_pdus; /* how many pdus have arrived since it's been released */
|
||||
mate_pdu* pdus; /* pdus that belong to a gop (NULL in gog) */
|
||||
mate_pdu* last_pdu; /* last pdu in pdu's list */
|
||||
|
||||
gboolean released; /* has this gop been released? */
|
||||
};
|
||||
|
||||
|
||||
struct _mate_gog {
|
||||
guint32 id;
|
||||
mate_cfg_gog* cfg;
|
||||
|
||||
AVPL* avpl; /* the attributes of the pdu/gop/gog */
|
||||
guint last_n; /* the number of attributes the avpl had the last time we checked */
|
||||
|
||||
gboolean released; /* has this gop been released? */
|
||||
|
||||
float expiration; /* when will it expire after release (all gops releases if gog)? */
|
||||
float idle_expiration; /* when will it expire if no new pdus are assigned to it */
|
||||
|
||||
/* on gop and gog: */
|
||||
float start_time; /* time of start */
|
||||
float release_time; /* when this gop/gog was released */
|
||||
float last_time; /* the rel_time at which the last pdu has been added (to gop or gog's gop) */
|
||||
float release_time; /* when this gog was released */
|
||||
float last_time; /* the rel_time at which the last pdu has been added */
|
||||
|
||||
/* union _payload { */
|
||||
/* struct _pdu { */
|
||||
guint32 frame; /* wich frame I belog to? */
|
||||
mate_gop* gop; /* the gop the pdu belongs to (if any) */
|
||||
gboolean first; /* is this the first pdu in this frame? */
|
||||
gboolean is_start; /* this is the start pdu for this gop */
|
||||
gboolean is_stop; /* this is the stop pdu for this gop */
|
||||
gboolean after_release; /* this pdu comes after the stop */
|
||||
float rel_time; /* time since start of capture */
|
||||
float time_in_gop; /* time since gop start */
|
||||
mate_pdu* next_in_frame; /* points to the next pdu in this frame */
|
||||
/* } pdu; */
|
||||
|
||||
/* struct _gop { */
|
||||
/* membership* gogs; */
|
||||
mate_gog* gog; /* the gog of a gop */
|
||||
mate_pdu* pdus; /* pdus that belong to a gop (NULL in gog) */
|
||||
gboolean released; /* has this gop been released? */
|
||||
int num_of_pdus; /* how many gops a gog has? */
|
||||
int num_of_after_release_pdus; /* how many pdus have arrived since it's been released */
|
||||
guint8* gop_key; /* used by gop */
|
||||
mate_pdu* last_pdu; /* last pdu in pdu's list */
|
||||
float time_to_die;
|
||||
float time_to_timeout;
|
||||
/* } gop; */
|
||||
|
||||
/* struct _gog { */
|
||||
/* membership* gops; */
|
||||
mate_gop* gops; /* gops that belong to a gog (NULL in gop) */
|
||||
int num_of_gops; /* how many gops a gog has? */
|
||||
int num_of_counting_gops; /* how many of them count for gog release */
|
||||
int num_of_released_gops; /* how many of them have already been released */
|
||||
guint last_n; /* the number of attributes the avpl had the last time we checked */
|
||||
GPtrArray* gog_keys; /* the keys under which this gog is stored in the gogs hash */
|
||||
mate_gop* last_gop; /* last gop in gop's list */
|
||||
/* } gog; */
|
||||
/* } o; */
|
||||
mate_gop* gops; /* gops that belong to a gog (NULL in gop) */
|
||||
mate_gop* last_gop; /* last gop in gop's list */
|
||||
|
||||
int num_of_gops; /* how many gops a gog has? */
|
||||
int num_of_counting_gops; /* how many of them count for gog release */
|
||||
int num_of_released_gops; /* how many of them have already been released */
|
||||
GPtrArray* gog_keys; /* the keys under which this gog is stored in the gogs hash */
|
||||
};
|
||||
|
||||
typedef union _mate_max_size {
|
||||
mate_pdu pdu;
|
||||
mate_gop gop;
|
||||
mate_gog gog;
|
||||
} mate_max_size;
|
||||
|
||||
/* from mate_runtime.c */
|
||||
extern void initialize_mate_runtime(void);
|
||||
extern mate_pdu* mate_get_pdus(guint32 framenum);
|
||||
extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree);
|
||||
|
||||
/* from mate_setup.c */
|
||||
extern mate_config* mate_make_config(guint8* filename, int mate_hfid);
|
||||
extern mate_config* mate_make_config(gchar* filename, int mate_hfid);
|
||||
|
||||
extern mate_config* mate_cfg(void);
|
||||
extern mate_cfg_pdu* new_pducfg(gchar* name);
|
||||
extern mate_cfg_gop* new_gopcfg(gchar* name);
|
||||
extern mate_cfg_gog* new_gogcfg(gchar* name);
|
||||
|
||||
extern gboolean add_hfid(header_field_info* hfi, gchar* as, GHashTable* where);
|
||||
extern gchar* add_ranges(gchar* range, GPtrArray* range_ptr_arr);
|
||||
|
||||
|
||||
/* from mate_parser.l */
|
||||
extern gboolean mate_load_config(gchar* filename, mate_config* mc);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,296 @@
|
|||
%option noyywrap
|
||||
%option nounput
|
||||
%option never-interactive
|
||||
%option prefix="Mate"
|
||||
|
||||
%{
|
||||
|
||||
/* mate_parser.l
|
||||
* lexical analyzer for MATE configuration files
|
||||
*
|
||||
* Copyright 2004, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
|
||||
*
|
||||
* $Id: packet-xml.c 13427 2005-02-18 22:33:16Z lego $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "mate.h"
|
||||
#include "mate_grammar.h"
|
||||
|
||||
void MateParser(void*,int, gchar*, mate_config* matecfg);
|
||||
void *MateParserAlloc(void *(*)(gulong));
|
||||
void MateParserFree( void*, void(*)(void*) );
|
||||
void MateParseTrace(FILE*,char*);
|
||||
|
||||
#define MAX_INCLUDE_DEPTH 10
|
||||
YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
|
||||
int include_stack_ptr = 0;
|
||||
|
||||
void* pParser;
|
||||
mate_config_frame* current_frame;
|
||||
|
||||
mate_config* mc;
|
||||
|
||||
#define MATE_PARSE(token_type) MateParser(pParser, (token_type), g_strdup(yytext), mc );
|
||||
|
||||
%}
|
||||
|
||||
pdu_kw Pdu
|
||||
gop_kw Gop
|
||||
gog_kw Gog
|
||||
transform_kw Transform
|
||||
match_kw Match
|
||||
always_kw Always
|
||||
strict_kw Strict
|
||||
every_kw Every
|
||||
loose_kw Loose
|
||||
replace_kw Replace
|
||||
insert_kw Insert
|
||||
gop_tree_kw GopTree
|
||||
member_kw Member
|
||||
on_kw On
|
||||
start_kw Start
|
||||
stop_kw Stop
|
||||
extra_kw Extra
|
||||
show_tree_kw ShowTree
|
||||
show_times_kw ShowTimes
|
||||
expiration_kw Expiration
|
||||
idle_timeout_kw IdleTimeout
|
||||
lifetime_kw Lifetime
|
||||
no_tree_kw NoTree
|
||||
pdu_tree_kw PduTree
|
||||
frame_tree_kw FrameTree
|
||||
basic_tree_kw BasicTree
|
||||
true_kw [Tt][Rr][Uu][Ee]
|
||||
false_kw [Ff][Aa][Ll][Ss][Ee]
|
||||
proto_kw Proto
|
||||
payload_kw Payload
|
||||
transport_kw Transport
|
||||
criteria_kw Criteria
|
||||
accept_kw Accept
|
||||
reject_kw Reject
|
||||
extract_kw Extract
|
||||
from_kw From
|
||||
drop_unassigned_kw DropUnassigned
|
||||
discard_pdu_data_kw DiscardPduData
|
||||
last_pdu_kw LastPdu
|
||||
done_kw Done
|
||||
|
||||
|
||||
|
||||
open_parens "("
|
||||
close_parens ")"
|
||||
open_brace "{"
|
||||
close_brace "}"
|
||||
comma ","
|
||||
semicolon ";"
|
||||
slash "/"
|
||||
pipe "|"
|
||||
|
||||
integer [0-9]+
|
||||
floating ([0-9]+\.[0-9]+)
|
||||
doted_ip [0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?
|
||||
colonized [0-9A-Fa-f:]*[:][0-9A-Fa-f:]*
|
||||
|
||||
name [a-z][-\.a-zA-Z0-9_]*
|
||||
avp_operator [$^~=<>!]
|
||||
quote ["]
|
||||
not_quoted [^"]*
|
||||
|
||||
include "#include"
|
||||
filename [-A-Za-z0-9_/.]+
|
||||
|
||||
whitespace [[:blank:]\r]+
|
||||
newline \n
|
||||
|
||||
comment "//"[^\n]*\n
|
||||
|
||||
blk_cmnt_start "/*"
|
||||
cmnt_char .
|
||||
blk_cmnt_stop "*/"
|
||||
|
||||
%START OUT QUOTED INCLUDING COMMENT
|
||||
%%
|
||||
|
||||
{newline} current_frame->linenum++;
|
||||
{whitespace} ;
|
||||
|
||||
<OUT>{include} BEGIN INCLUDING;
|
||||
|
||||
<INCLUDING>{filename} {
|
||||
if ( include_stack_ptr >= MAX_INCLUDE_DEPTH )
|
||||
g_error("dtd_preparse: include files nested to deeply");
|
||||
|
||||
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
|
||||
yyin = fopen( yytext, "r" );
|
||||
|
||||
if (!yyin) {
|
||||
yy_delete_buffer( YY_CURRENT_BUFFER );
|
||||
|
||||
yy_switch_to_buffer(include_stack[--include_stack_ptr] );
|
||||
|
||||
if (errno)
|
||||
g_string_sprintfa(mc->config_error, "Mate parser: Could not open file: '%s': %s", yytext, strerror(errno) );
|
||||
|
||||
} else {
|
||||
|
||||
current_frame = g_malloc(sizeof(mate_config_frame));
|
||||
current_frame->filename = g_strdup(yytext);
|
||||
current_frame->linenum = 1;
|
||||
|
||||
g_ptr_array_add(mc->config_stack,current_frame);
|
||||
|
||||
yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) );
|
||||
}
|
||||
|
||||
BEGIN OUT;
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
if ( --include_stack_ptr < 0 ) {
|
||||
yyterminate();
|
||||
} else {
|
||||
yy_delete_buffer( YY_CURRENT_BUFFER );
|
||||
yy_switch_to_buffer( include_stack[include_stack_ptr] );
|
||||
|
||||
g_free(current_frame->filename);
|
||||
g_free(current_frame);
|
||||
current_frame = g_ptr_array_remove_index(mc->config_stack,mc->config_stack->len-1);
|
||||
}
|
||||
}
|
||||
|
||||
<OUT>{comment} ;
|
||||
|
||||
<OUT>{blk_cmnt_start} BEGIN COMMENT;
|
||||
<COMMENT>{cmnt_char} ;
|
||||
<COMMENT>{blk_cmnt_stop} BEGIN OUT;
|
||||
|
||||
<OUT>{pdu_kw} MATE_PARSE(TOKEN_PDU_KW);
|
||||
<OUT>{gop_kw} MATE_PARSE(TOKEN_GOP_KW);
|
||||
<OUT>{gog_kw} MATE_PARSE(TOKEN_GOG_KW);
|
||||
<OUT>{transform_kw} MATE_PARSE(TOKEN_TRANSFORM_KW);
|
||||
<OUT>{match_kw} MATE_PARSE(TOKEN_MATCH_KW);
|
||||
<OUT>{strict_kw} MATE_PARSE(TOKEN_STRICT_KW);
|
||||
<OUT>{every_kw} MATE_PARSE(TOKEN_EVERY_KW);
|
||||
<OUT>{loose_kw} MATE_PARSE(TOKEN_LOOSE_KW);
|
||||
<OUT>{replace_kw} MATE_PARSE(TOKEN_REPLACE_KW);
|
||||
<OUT>{insert_kw} MATE_PARSE(TOKEN_INSERT_KW);
|
||||
<OUT>{gop_tree_kw} MATE_PARSE(TOKEN_GOP_TREE_KW);
|
||||
<OUT>{member_kw} MATE_PARSE(TOKEN_MEMBER_KW);
|
||||
<OUT>{on_kw} MATE_PARSE(TOKEN_ON_KW);
|
||||
<OUT>{start_kw} MATE_PARSE(TOKEN_START_KW);
|
||||
<OUT>{stop_kw} MATE_PARSE(TOKEN_STOP_KW);
|
||||
<OUT>{extra_kw} MATE_PARSE(TOKEN_EXTRA_KW);
|
||||
<OUT>{show_tree_kw} MATE_PARSE(TOKEN_SHOW_TREE_KW);
|
||||
<OUT>{show_times_kw} MATE_PARSE(TOKEN_SHOW_TIMES_KW);
|
||||
<OUT>{expiration_kw} MATE_PARSE(TOKEN_EXPIRATION_KW);
|
||||
<OUT>{idle_timeout_kw} MATE_PARSE(TOKEN_IDLE_TIMEOUT_KW);
|
||||
<OUT>{lifetime_kw} MATE_PARSE(TOKEN_LIFETIME_KW);
|
||||
<OUT>{no_tree_kw} MATE_PARSE(TOKEN_NO_TREE_KW);
|
||||
<OUT>{pdu_tree_kw} MATE_PARSE(TOKEN_PDU_TREE_KW);
|
||||
<OUT>{frame_tree_kw} MATE_PARSE(TOKEN_FRAME_TREE_KW);
|
||||
<OUT>{basic_tree_kw} MATE_PARSE(TOKEN_BASIC_TREE_KW);
|
||||
<OUT>{true_kw} MATE_PARSE(TOKEN_TRUE_KW);
|
||||
<OUT>{false_kw} MATE_PARSE(TOKEN_FALSE_KW);
|
||||
<OUT>{proto_kw} MATE_PARSE(TOKEN_PROTO_KW);
|
||||
<OUT>{payload_kw} MATE_PARSE(TOKEN_PAYLOAD_KW);
|
||||
<OUT>{transport_kw} MATE_PARSE(TOKEN_TRANSPORT_KW);
|
||||
<OUT>{criteria_kw} MATE_PARSE(TOKEN_CRITERIA_KW);
|
||||
<OUT>{accept_kw} MATE_PARSE(TOKEN_ACCEPT_KW);
|
||||
<OUT>{reject_kw} MATE_PARSE(TOKEN_REJECT_KW);
|
||||
<OUT>{extract_kw} MATE_PARSE(TOKEN_EXTRACT_KW);
|
||||
<OUT>{from_kw} MATE_PARSE(TOKEN_FROM_KW);
|
||||
<OUT>{drop_unassigned_kw} MATE_PARSE(TOKEN_DROP_UNASSIGNED_KW);
|
||||
<OUT>{discard_pdu_data_kw} MATE_PARSE(TOKEN_DISCARD_PDU_DATA_KW);
|
||||
<OUT>{last_pdu_kw} MATE_PARSE(TOKEN_LAST_PDU_KW);
|
||||
<OUT>{done_kw} MATE_PARSE(TOKEN_DONE_KW);
|
||||
|
||||
<OUT>{open_parens} MATE_PARSE(TOKEN_OPEN_PARENS);
|
||||
<OUT>{close_parens} MATE_PARSE(TOKEN_CLOSE_PARENS);
|
||||
<OUT>{open_brace} MATE_PARSE(TOKEN_OPEN_BRACE);
|
||||
<OUT>{close_brace} MATE_PARSE(TOKEN_CLOSE_BRACE);
|
||||
<OUT>{comma} MATE_PARSE(TOKEN_COMMA);
|
||||
<OUT>{semicolon} MATE_PARSE(TOKEN_SEMICOLON);
|
||||
<OUT>{slash} MATE_PARSE(TOKEN_SLASH);
|
||||
<OUT>{pipe} MATE_PARSE(TOKEN_PIPE);
|
||||
|
||||
<OUT>{integer} MATE_PARSE(TOKEN_INTEGER);
|
||||
<OUT>{floating} MATE_PARSE(TOKEN_FLOATING);
|
||||
<OUT>{doted_ip} MATE_PARSE(TOKEN_DOTED_IP);
|
||||
<OUT>{colonized} MATE_PARSE(TOKEN_COLONIZED);
|
||||
<OUT>{name} MATE_PARSE(TOKEN_NAME);
|
||||
<OUT>{avp_operator} MATE_PARSE(TOKEN_AVP_OPERATOR);
|
||||
|
||||
|
||||
<OUT>{quote} BEGIN QUOTED;
|
||||
<QUOTED>{not_quoted} MATE_PARSE(TOKEN_QUOTED);
|
||||
<QUOTED>{quote} BEGIN OUT;
|
||||
|
||||
%%
|
||||
|
||||
extern gboolean mate_load_config(gchar* filename, mate_config* matecfg) {
|
||||
gboolean state;
|
||||
mc = matecfg;
|
||||
|
||||
yyin = fopen(filename,"r");
|
||||
|
||||
if (!yyin) {
|
||||
g_string_sprintfa(mc->config_error,"Mate parser: Could not open file: '%s', error: %s", filename, strerror(errno) );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mc->config_stack = g_ptr_array_new();
|
||||
|
||||
current_frame = g_malloc(sizeof(mate_config_frame));
|
||||
current_frame->filename = g_strdup(filename);
|
||||
current_frame->linenum = 1;
|
||||
|
||||
g_ptr_array_add(mc->config_stack,current_frame);
|
||||
|
||||
pParser = MateParserAlloc(g_malloc);
|
||||
|
||||
/* MateParserTrace(stdout,""); */
|
||||
|
||||
TRY {
|
||||
BEGIN OUT;
|
||||
|
||||
yylex();
|
||||
|
||||
MateParser(pParser, 0, NULL,mc);
|
||||
|
||||
yyrestart(NULL);
|
||||
|
||||
MateParserFree(pParser, g_free );
|
||||
|
||||
g_free(current_frame->filename);
|
||||
g_free(current_frame);
|
||||
|
||||
g_ptr_array_free(mc->config_stack,FALSE);
|
||||
state = TRUE;
|
||||
} CATCH(MateConfigError) {
|
||||
state = FALSE;
|
||||
} CATCH_ALL {
|
||||
state = FALSE;
|
||||
g_string_sprintfa(mc->config_error,"An unexpected error occurred");
|
||||
}
|
||||
ENDTRY;
|
||||
|
||||
return state;
|
||||
}
|
|
@ -24,7 +24,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* this file is used temporarily to buid it as a plugin */
|
||||
/* this file is used temporarily to buid MATE as a plugin */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -40,6 +40,8 @@
|
|||
/* these two are in packet-mate.c */
|
||||
void proto_register_mate(void);
|
||||
void proto_reg_handoff_mate(void);
|
||||
|
||||
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
#ifndef ENABLE_STATIC
|
||||
|
@ -47,8 +49,9 @@ G_MODULE_EXPORT const gchar version[] = VERSION;
|
|||
|
||||
G_MODULE_EXPORT void plugin_register(void) {
|
||||
|
||||
/* register the new protocol, protocol fields, and subtrees */
|
||||
if (! initialized ) { /* execute protocol initialization only once */
|
||||
g_message("---");
|
||||
|
||||
if (! initialized ) {
|
||||
proto_register_mate();
|
||||
initialized = 1;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct _tmp_pdu_data {
|
|||
|
||||
|
||||
typedef struct _gogkey {
|
||||
guint8* key;
|
||||
gchar* key;
|
||||
mate_cfg_gop* cfg;
|
||||
} gogkey;
|
||||
|
||||
|
@ -58,28 +58,45 @@ static int* dbg_gop = &zero;
|
|||
static int* dbg_gog = &zero;
|
||||
static FILE* dbg_facility = NULL;
|
||||
|
||||
static void gog_remove_keys (mate_gog* gog);
|
||||
static gboolean destroy_mate_pdus(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_pdu* pdu = (mate_pdu*) v;
|
||||
if (pdu->avpl) delete_avpl(pdu->avpl,TRUE);
|
||||
g_mem_chunk_free(rd->mate_items,pdu);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean destroy_mate_items(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_item* mi = (mate_item*) v;
|
||||
static gboolean destroy_mate_gops(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_gop* gop = (mate_gop*) v;
|
||||
|
||||
if (mi->avpl) delete_avpl(mi->avpl,TRUE);
|
||||
|
||||
if (mi->gop_key) {
|
||||
if (g_hash_table_lookup(mi->cfg->gop_index,mi->gop_key) == mi) {
|
||||
g_hash_table_remove(mi->cfg->gop_index,mi->gop_key);
|
||||
if (gop->avpl) delete_avpl(gop->avpl,TRUE);
|
||||
|
||||
if (gop->gop_key) {
|
||||
if (g_hash_table_lookup(gop->cfg->gop_index,gop->gop_key) == gop) {
|
||||
g_hash_table_remove(gop->cfg->gop_index,gop->gop_key);
|
||||
}
|
||||
|
||||
g_free(mi->gop_key);
|
||||
}
|
||||
|
||||
|
||||
if (mi->gog_keys) {
|
||||
gog_remove_keys(mi);
|
||||
g_ptr_array_free(mi->gog_keys,FALSE);
|
||||
g_free(gop->gop_key);
|
||||
}
|
||||
|
||||
g_mem_chunk_free(rd->mate_items,mi);
|
||||
g_mem_chunk_free(rd->mate_items,gop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void gog_remove_keys (mate_gog* gog);
|
||||
|
||||
static gboolean destroy_mate_gogs(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_gog* gog = (mate_gog*) v;
|
||||
|
||||
if (gog->avpl) delete_avpl(gog->avpl,TRUE);
|
||||
|
||||
if (gog->gog_keys) {
|
||||
gog_remove_keys(gog);
|
||||
g_ptr_array_free(gog->gog_keys,FALSE);
|
||||
}
|
||||
|
||||
g_mem_chunk_free(rd->mate_items,gog);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -88,28 +105,34 @@ static gboolean return_true(gpointer k _U_, gpointer v _U_, gpointer p _U_) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void destroy_items_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_cfg_item* c = v;
|
||||
|
||||
if (c->gop_index) {
|
||||
g_hash_table_foreach_remove(c->gop_index,return_true,NULL);
|
||||
g_hash_table_destroy(c->gop_index);
|
||||
c->gop_index = g_hash_table_new(g_str_hash,g_str_equal);
|
||||
}
|
||||
|
||||
if (c->gog_index) {
|
||||
g_hash_table_foreach_remove(c->gog_index,return_true,NULL);
|
||||
g_hash_table_destroy(c->gog_index);
|
||||
c->gog_index = g_hash_table_new(g_str_hash,g_str_equal);
|
||||
}
|
||||
|
||||
g_hash_table_foreach_remove(c->items,destroy_mate_items,NULL);
|
||||
|
||||
static void destroy_pdus_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_cfg_pdu* c = v;
|
||||
g_hash_table_foreach_remove(c->items,destroy_mate_pdus,NULL);
|
||||
c->last_id = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void destroy_gops_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_cfg_gop* c = v;
|
||||
|
||||
g_hash_table_foreach_remove(c->gop_index,return_true,NULL);
|
||||
g_hash_table_destroy(c->gop_index);
|
||||
c->gop_index = g_hash_table_new(g_str_hash,g_str_equal);
|
||||
|
||||
g_hash_table_foreach_remove(c->gog_index,return_true,NULL);
|
||||
g_hash_table_destroy(c->gog_index);
|
||||
c->gog_index = g_hash_table_new(g_str_hash,g_str_equal);
|
||||
|
||||
g_hash_table_foreach_remove(c->items,destroy_mate_gops,NULL);
|
||||
c->last_id = 0;
|
||||
}
|
||||
|
||||
static void destroy_gogs_in_cfg(gpointer k _U_, gpointer v, gpointer p _U_) {
|
||||
mate_cfg_gog* c = v;
|
||||
g_hash_table_foreach_remove(c->items,destroy_mate_gogs,NULL);
|
||||
c->last_id = 0;
|
||||
}
|
||||
|
||||
extern void initialize_mate_runtime(void) {
|
||||
|
||||
dbg_print (dbg,5,dbg_facility,"initialize_mate: entering");
|
||||
|
@ -117,11 +140,11 @@ extern void initialize_mate_runtime(void) {
|
|||
if (( mc = mate_cfg() )) {
|
||||
if (rd == NULL ) {
|
||||
rd = g_malloc(sizeof(mate_runtime_data));
|
||||
rd->mate_items = g_mem_chunk_new("mate_items",sizeof(mate_item),1024,G_ALLOC_AND_FREE);
|
||||
rd->mate_items = g_mem_chunk_new("mate_items",sizeof(mate_max_size),1024,G_ALLOC_AND_FREE);
|
||||
} else {
|
||||
g_hash_table_foreach(mc->pducfgs,destroy_items_in_cfg,NULL);
|
||||
g_hash_table_foreach(mc->gopcfgs,destroy_items_in_cfg,NULL);
|
||||
g_hash_table_foreach(mc->gogcfgs,destroy_items_in_cfg,NULL);
|
||||
g_hash_table_foreach(mc->pducfgs,destroy_pdus_in_cfg,NULL);
|
||||
g_hash_table_foreach(mc->gopcfgs,destroy_gops_in_cfg,NULL);
|
||||
g_hash_table_foreach(mc->gogcfgs,destroy_gogs_in_cfg,NULL);
|
||||
|
||||
g_hash_table_destroy(rd->frames);
|
||||
}
|
||||
|
@ -141,68 +164,37 @@ extern void initialize_mate_runtime(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static mate_item* new_mate_item(mate_cfg_item* cfg) {
|
||||
mate_item* it = g_mem_chunk_alloc(rd->mate_items);
|
||||
|
||||
cfg->last_id++;
|
||||
|
||||
it->id = cfg->last_id;
|
||||
it->cfg = cfg;
|
||||
|
||||
it->avpl = NULL ;
|
||||
|
||||
it->next = NULL ;
|
||||
static mate_gop* new_gop(mate_cfg_gop* cfg, mate_pdu* pdu, gchar* key) {
|
||||
mate_gop* gop = g_mem_chunk_alloc(rd->mate_items);
|
||||
|
||||
it->expiration = 0.0;
|
||||
it->idle_expiration = 0.0;
|
||||
|
||||
it->start_time = 0.0;
|
||||
it->release_time = 0.0;
|
||||
it->last_time = 0.0;
|
||||
|
||||
it->frame = 0 ;
|
||||
it->gop = NULL;
|
||||
it->first = FALSE;
|
||||
it->is_start = FALSE;
|
||||
it->is_stop = FALSE;
|
||||
it->after_release = FALSE;
|
||||
it->rel_time = 0.0;
|
||||
it->time_in_gop = -1.0;
|
||||
it->next_in_frame = NULL;
|
||||
|
||||
it->gog = NULL;
|
||||
it->pdus = NULL;
|
||||
it->released = FALSE ;
|
||||
it->num_of_pdus = 0;
|
||||
it->num_of_after_release_pdus = 0;
|
||||
it->gop_key = NULL;
|
||||
|
||||
it->gops = NULL;
|
||||
it->num_of_gops = 0;
|
||||
it->num_of_counting_gops = 0;
|
||||
it->num_of_released_gops = 0;
|
||||
it->last_n = 0;
|
||||
it->gog_keys = NULL;
|
||||
it->last_gop = NULL;
|
||||
|
||||
rd->current_items++;
|
||||
|
||||
g_hash_table_insert(cfg->items,GUINT_TO_POINTER(it->id),it);
|
||||
return it;
|
||||
}
|
||||
|
||||
static mate_gop* new_gop(mate_cfg_gop* cfg, mate_pdu* pdu, guint8* key) {
|
||||
mate_gop* gop = new_mate_item(cfg);
|
||||
gop->id = ++(cfg->last_id);
|
||||
gop->cfg = cfg;
|
||||
|
||||
dbg_print (dbg_gop,1,dbg_facility,"new_gop: %s: ``%s:%d''",gop->cfg->name,gop->id,key);
|
||||
|
||||
|
||||
gop->gop_key = key;
|
||||
gop->avpl = new_avpl(cfg->name);
|
||||
gop->last_n = 0;
|
||||
|
||||
gop->gog = NULL;
|
||||
gop->next = NULL;
|
||||
|
||||
gop->expiration = 0.0;
|
||||
gop->idle_expiration = 0.0;
|
||||
gop->time_to_die = cfg->lifetime > 0.0 ? cfg->lifetime + rd->now : (float) -1.0 ;
|
||||
gop->time_to_timeout = 0.0;
|
||||
|
||||
gop->last_time = gop->start_time = rd->now;
|
||||
gop->release_time = 0.0;
|
||||
|
||||
gop->num_of_pdus = 1;
|
||||
gop->num_of_after_release_pdus = 0;
|
||||
|
||||
gop->pdus = pdu;
|
||||
gop->last_pdu = pdu;
|
||||
gop->gop_key = key;
|
||||
gop->start_time = rd->now;
|
||||
gop->time_to_die = cfg->lifetime > 0.0 ? cfg->lifetime + rd->now : (float) -1.0 ;
|
||||
|
||||
|
||||
pdu->gop = gop;
|
||||
pdu->next = NULL;
|
||||
pdu->is_start = TRUE;
|
||||
|
@ -211,7 +203,6 @@ static mate_gop* new_gop(mate_cfg_gop* cfg, mate_pdu* pdu, guint8* key) {
|
|||
return gop;
|
||||
}
|
||||
|
||||
|
||||
static void adopt_gop(mate_gog* gog, mate_gop* gop) {
|
||||
dbg_print (dbg_gog,5,dbg_facility,"adopt_gop: gog=%X gop=%X",gog,gop);
|
||||
|
||||
|
@ -237,43 +228,55 @@ static void adopt_gop(mate_gog* gog, mate_gop* gop) {
|
|||
}
|
||||
|
||||
static mate_gog* new_gog(mate_cfg_gog* cfg, mate_gop* gop) {
|
||||
mate_gog* gog = new_mate_item(cfg);
|
||||
mate_gog* gog = g_mem_chunk_alloc(rd->mate_items);
|
||||
|
||||
gog->id = ++(cfg->last_id);
|
||||
gog->cfg = cfg;
|
||||
|
||||
dbg_print (dbg_gog,1,dbg_facility,"new_gog: %s:%u for %s:%u",gog->cfg->name,gog->id,gop->cfg->name,gop->id);
|
||||
|
||||
gog->avpl = new_avpl(cfg->name);
|
||||
gog->last_n = 0;
|
||||
|
||||
gog->expiration = 0.0;
|
||||
gog->idle_expiration = 0.0;
|
||||
|
||||
gog->start_time = rd->now;
|
||||
gog->release_time = 0.0;
|
||||
gog->last_time = 0.0;
|
||||
|
||||
gog->gops = NULL;
|
||||
gog->last_gop = NULL;
|
||||
|
||||
gog->num_of_gops = 0;
|
||||
gog->num_of_counting_gops = 0;
|
||||
gog->num_of_released_gops = 0;
|
||||
|
||||
gog->gog_keys = g_ptr_array_new();
|
||||
gog->start_time = rd->now;
|
||||
|
||||
adopt_gop(gog,gop);
|
||||
|
||||
return gog;
|
||||
}
|
||||
static void apply_transforms(mate_item* item) {
|
||||
|
||||
static void apply_transforms(GPtrArray* transforms, AVPL* avpl) {
|
||||
AVPL_Transf* transform = NULL;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < item->cfg->transforms->len; i++) {
|
||||
transform = g_ptr_array_index(item->cfg->transforms,i);
|
||||
avpl_transform(item->avpl, transform);
|
||||
for (i = 0; i < transforms->len; i++) {
|
||||
transform = g_ptr_array_index(transforms,i);
|
||||
avpl_transform(avpl, transform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* applies the extras for which type to what avpl */
|
||||
static void apply_extras(AVPL* from, AVPL* to, mate_cfg_item* cfg) {
|
||||
AVPL* our_extras = NULL;
|
||||
|
||||
if (cfg->extra) {
|
||||
dbg_print (dbg,3,dbg_facility,"apply_extras: entering: from='%s' to='%s' for='%s'",from->name,to->name,cfg->name);
|
||||
|
||||
our_extras = new_avpl_loose_match("",from, cfg->extra, FALSE) ;
|
||||
|
||||
if (our_extras) {
|
||||
merge_avpl(to,our_extras,TRUE);
|
||||
delete_avpl(our_extras,FALSE);
|
||||
}
|
||||
static void apply_extras(AVPL* from, AVPL* to, AVPL* extras) {
|
||||
AVPL* our_extras = new_avpl_loose_match("",from, extras, FALSE) ;
|
||||
|
||||
if (our_extras) {
|
||||
merge_avpl(to,our_extras,TRUE);
|
||||
delete_avpl(our_extras,FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,11 +311,17 @@ static void reanalyze_gop(mate_gop* gop) {
|
|||
|
||||
dbg_print (dbg_gog,1,dbg_facility,"reanalize_gop: %s:%d",gop->cfg->name,gop->id);
|
||||
|
||||
apply_extras(gop->avpl,gog->avpl,gog->cfg);
|
||||
apply_extras(gop->avpl,gog->avpl,gog->cfg->extra);
|
||||
|
||||
/* XXX: Instead of using the length of the avpl to check if an avpl has changed,
|
||||
which is not accurate at all, we should have apply_extras,
|
||||
apply_transformations and other functions that can modify the avpl
|
||||
to flag the avpl if it has changed, then we'll check for the flag
|
||||
and clear it after analysis */
|
||||
|
||||
if (gog->last_n != gog->avpl->len) {
|
||||
|
||||
dbg_print (dbg_gog,2,dbg_facility,"analize_gop: gog has new attributes let's look for new keys");
|
||||
dbg_print (dbg_gog,2,dbg_facility,"reanalize_gop: gog has new attributes let's look for new keys");
|
||||
|
||||
gog_keys = gog->cfg->keys;
|
||||
|
||||
|
@ -335,7 +344,9 @@ static void reanalyze_gop(mate_gop* gop) {
|
|||
}
|
||||
|
||||
if (! gog_key ) {
|
||||
/* TODO: try mergeing the gogs */
|
||||
/* XXX: since these gogs actually share key info
|
||||
we should try to merge (non released) gogs
|
||||
that happen to have equal keys */
|
||||
} else {
|
||||
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: new key for gog=%s:%d : %s",gog->cfg->name,gog->id,gog_key->key);
|
||||
g_ptr_array_add(gog->gog_keys,gog_key);
|
||||
|
@ -363,7 +374,7 @@ static void analize_gop(mate_gop* gop) {
|
|||
void* cookie = NULL;
|
||||
AVPL* gogkey_match = NULL;
|
||||
mate_gog* gog = NULL;
|
||||
guint8* key = NULL;
|
||||
gchar* key = NULL;
|
||||
|
||||
if ( ! ( gog = gop->gog ) ) {
|
||||
/* no gog, let's either find one or create it if due */
|
||||
|
@ -376,14 +387,11 @@ static void analize_gop(mate_gop* gop) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* We'll look for any matching gogkeys */
|
||||
/* We have gog_keys! look for matching gogkeys */
|
||||
|
||||
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: got gog_keys: %s",gog_keys->name) ;
|
||||
|
||||
while (( curr_gogkey = get_next_avpl(gog_keys,&cookie) )) {
|
||||
|
||||
dbg_print (dbg_gog,2,dbg_facility,"analize_gop: about to match");
|
||||
|
||||
if (( gogkey_match = new_avpl_exact_match(gop->cfg->name,gop->avpl,curr_gogkey,TRUE) )) {
|
||||
|
||||
key = avpl_to_str(gogkey_match);
|
||||
|
@ -404,8 +412,6 @@ static void analize_gop(mate_gop* gop) {
|
|||
} else {
|
||||
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: this is our gog");
|
||||
|
||||
g_free(key);
|
||||
|
||||
if (! gop->gog ) adopt_gop(gog,gop);
|
||||
|
||||
break;
|
||||
|
@ -430,13 +436,19 @@ static void analize_gop(mate_gop* gop) {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
delete_avpl(gogkey_match,TRUE);
|
||||
gogkey_match = NULL;
|
||||
}
|
||||
|
||||
if (key) g_free(key);
|
||||
key = NULL;
|
||||
|
||||
dbg_print (dbg_gog,1,dbg_facility,"analize_gop: no gogkey_match: %s",key);
|
||||
}
|
||||
|
||||
if (key) g_free(key);
|
||||
|
||||
if (gogkey_match) delete_avpl(gogkey_match,TRUE);
|
||||
|
||||
reanalyze_gop(gop);
|
||||
|
@ -452,55 +464,27 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
*/
|
||||
mate_cfg_gop* cfg = NULL;
|
||||
mate_gop* gop = NULL;
|
||||
guint8* gop_key;
|
||||
guint8* orig_gop_key = NULL;
|
||||
AVPL* candidate_gop_key_match = NULL;
|
||||
gchar* gop_key;
|
||||
gchar* orig_gop_key = NULL;
|
||||
AVPL* candidate_start = NULL;
|
||||
AVPL* candidate_stop = NULL;
|
||||
AVPL* is_start = NULL;
|
||||
AVPL* is_stop = NULL;
|
||||
AVPL* gopkey_match = NULL;
|
||||
guint8* avpl_str = NULL;
|
||||
LoAL* gog_keys = NULL;
|
||||
AVPL* curr_gogkey = NULL;
|
||||
void* cookie = NULL;
|
||||
AVPL* gogkey_match = NULL;
|
||||
guint8* gogkey = NULL;
|
||||
gchar* gogkey = NULL;
|
||||
|
||||
dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: %s",pdu->cfg->name);
|
||||
|
||||
apply_transforms(pdu);
|
||||
|
||||
/* is there a gop type for this pdu type? */
|
||||
cfg = g_hash_table_lookup(mc->gops_by_pduname,pdu->cfg->name);
|
||||
|
||||
if (!cfg) return;
|
||||
|
||||
candidate_gop_key_match = cfg->key;
|
||||
|
||||
if (! candidate_gop_key_match) return;
|
||||
|
||||
dbg_print (dbg_gop,3,dbg_facility,"analize_pdu: got candidate key");
|
||||
|
||||
/* does the pdu matches the prematch candidate key for the gop type? */
|
||||
|
||||
gopkey_match = new_avpl_exact_match("gop_key_match",pdu->avpl,candidate_gop_key_match, TRUE);
|
||||
|
||||
if (gopkey_match) {
|
||||
if (! (cfg = g_hash_table_lookup(mc->gops_by_pduname,pdu->cfg->name)) )
|
||||
return;
|
||||
|
||||
if ((gopkey_match = new_avpl_exact_match("gop_key_match",pdu->avpl,cfg->key, TRUE))) {
|
||||
gop_key = avpl_to_str(gopkey_match);
|
||||
|
||||
candidate_start = cfg->start;
|
||||
|
||||
if (candidate_start) {
|
||||
dbg_print (dbg_gop,2,dbg_facility,"analize_pdu: got candidate start");
|
||||
is_start = new_avpl_exact_match("",pdu->avpl, candidate_start, FALSE);
|
||||
}
|
||||
|
||||
if (is_start) {
|
||||
dbg_print (dbg_gop,2,dbg_facility,"analize_pdu: got start match");
|
||||
delete_avpl(is_start,FALSE);
|
||||
}
|
||||
|
||||
|
||||
g_hash_table_lookup_extended(cfg->gop_index,(gconstpointer)gop_key,(gpointer*)&orig_gop_key,(gpointer*)&gop);
|
||||
|
||||
if ( gop ) {
|
||||
|
@ -521,15 +505,22 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
|
||||
dbg_print (dbg_gop,2,dbg_facility,"analize_pdu: got gop: %s",gop_key);
|
||||
|
||||
if (is_start) {
|
||||
if ( gop->released ) {
|
||||
dbg_print (dbg_gop,3,dbg_facility,"analize_pdu: start on released gop, a new gop");
|
||||
g_hash_table_remove(cfg->gop_index,gop_key);
|
||||
gop->gop_key = NULL;
|
||||
gop = new_gop(cfg,pdu,gop_key);
|
||||
g_hash_table_insert(cfg->gop_index,gop_key,gop);
|
||||
} else {
|
||||
dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: duplicate start on gop");
|
||||
if (( candidate_start = cfg->start )) {
|
||||
|
||||
dbg_print (dbg_gop,2,dbg_facility,"analize_pdu: got candidate start");
|
||||
|
||||
if (( is_start = new_avpl_exact_match("",pdu->avpl, candidate_start, FALSE) )) {
|
||||
delete_avpl(is_start,FALSE);
|
||||
if ( gop->released ) {
|
||||
dbg_print (dbg_gop,3,dbg_facility,"analize_pdu: start on released gop, let's create a new gop");
|
||||
|
||||
g_hash_table_remove(cfg->gop_index,gop_key);
|
||||
gop->gop_key = NULL;
|
||||
gop = new_gop(cfg,pdu,gop_key);
|
||||
g_hash_table_insert(cfg->gop_index,gop_key,gop);
|
||||
} else {
|
||||
dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: duplicate start on gop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,25 +536,21 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
} else {
|
||||
|
||||
dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: no gop already");
|
||||
|
||||
if (is_start) {
|
||||
|
||||
gop = new_gop(cfg,pdu,gop_key);
|
||||
g_hash_table_insert(cfg->gop_index,gop_key,gop);
|
||||
|
||||
} else if (! candidate_start) {
|
||||
|
||||
if ( ! cfg->start ) {
|
||||
/* there is no GopStart, we'll check for matching GogKeys
|
||||
if we have one we'll create the Gop */
|
||||
|
||||
apply_extras(pdu->avpl,gopkey_match,cfg);
|
||||
|
||||
if we have one we'll create the Gop */
|
||||
|
||||
apply_extras(pdu->avpl,gopkey_match,cfg->extra);
|
||||
|
||||
gog_keys = g_hash_table_lookup(mc->gogs_by_gopname,cfg->name);
|
||||
|
||||
|
||||
if (gog_keys) {
|
||||
|
||||
while (( curr_gogkey = get_next_avpl(gog_keys,&cookie) )) {
|
||||
if (( gogkey_match = new_avpl_exact_match(cfg->name,gopkey_match,curr_gogkey,FALSE) )) {
|
||||
gogkey = avpl_to_str(gogkey_match);
|
||||
|
||||
if (g_hash_table_lookup(cfg->gog_index,gogkey)) {
|
||||
gop = new_gop(cfg,pdu,gop_key);
|
||||
g_hash_table_insert(cfg->gop_index,gop_key,gop);
|
||||
|
@ -601,12 +588,8 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( gop ) {
|
||||
gop->num_of_pdus++;
|
||||
gop->time_to_timeout = cfg->idle_timeout > 0.0 ? cfg->idle_timeout + rd->now : (float) -1.0 ;
|
||||
} else {
|
||||
g_error("No GOP at this point is simply wrong!");
|
||||
}
|
||||
gop->num_of_pdus++;
|
||||
gop->time_to_timeout = cfg->idle_timeout > 0.0 ? cfg->idle_timeout + rd->now : (float) -1.0 ;
|
||||
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: merge with key");
|
||||
|
||||
|
@ -615,18 +598,14 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: apply extras");
|
||||
|
||||
apply_extras(pdu->avpl,gop->avpl,gop->cfg);
|
||||
|
||||
avpl_str = avpl_to_str(gop->avpl);
|
||||
dbg_print (dbg_gop,1,dbg_facility,"analize_pdu: Gop Attributes: %s",avpl_str);
|
||||
g_free(avpl_str);
|
||||
|
||||
apply_extras(pdu->avpl,gop->avpl,gop->cfg->extra);
|
||||
|
||||
gop->last_time = pdu->rel_time;
|
||||
|
||||
if ( ! gop->released) {
|
||||
candidate_stop = cfg->stop;
|
||||
|
||||
if (candidate_stop) {
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: got candidate stop");
|
||||
is_stop = new_avpl_exact_match("",pdu->avpl, candidate_stop,FALSE);
|
||||
} else {
|
||||
is_stop = new_avpl("");
|
||||
|
@ -642,14 +621,12 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
if (gop->gog && gop->cfg->start) gop->gog->num_of_released_gops++;
|
||||
}
|
||||
|
||||
if (candidate_stop) pdu->is_stop = TRUE;
|
||||
pdu->is_stop = TRUE;
|
||||
|
||||
} else {
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: is not a stop");
|
||||
}
|
||||
}
|
||||
|
||||
if (gop->last_n != gop->avpl->len) apply_transforms(gop);
|
||||
if (gop->last_n != gop->avpl->len) apply_transforms(gop->cfg->transforms,gop->avpl);
|
||||
|
||||
gop->last_n = gop->avpl->len;
|
||||
|
||||
|
@ -660,7 +637,7 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
}
|
||||
|
||||
} else {
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: no gop_key");
|
||||
dbg_print (dbg_gop,4,dbg_facility,"analize_pdu: no match for this pdu");
|
||||
|
||||
pdu->gop = NULL;
|
||||
}
|
||||
|
@ -668,7 +645,7 @@ static void analize_pdu(mate_pdu* pdu) {
|
|||
|
||||
static void get_pdu_fields(gpointer k, gpointer v, gpointer p) {
|
||||
int hfid = *((int*) k);
|
||||
guint8* name = (guint8*) v;
|
||||
gchar* name = (gchar*) v;
|
||||
tmp_pdu_data* data = (tmp_pdu_data*) p;
|
||||
GPtrArray* fis;
|
||||
field_info* fi;
|
||||
|
@ -677,11 +654,9 @@ static void get_pdu_fields(gpointer k, gpointer v, gpointer p) {
|
|||
guint start;
|
||||
guint end;
|
||||
AVP* avp;
|
||||
guint8* s;
|
||||
|
||||
/* no warning */
|
||||
k = p;
|
||||
|
||||
gchar* s;
|
||||
|
||||
|
||||
fis = (GPtrArray*) g_hash_table_lookup(data->interesting,(gpointer) hfid);
|
||||
|
||||
if (fis) {
|
||||
|
@ -692,20 +667,18 @@ static void get_pdu_fields(gpointer k, gpointer v, gpointer p) {
|
|||
start = fi->start;
|
||||
end = fi->start + fi->length;
|
||||
|
||||
dbg_print(dbg_pdu,6,dbg_facility,"get_pdu_fields: found field %i-%i",start,end);
|
||||
dbg_print(dbg_pdu,5,dbg_facility,"get_pdu_fields: found field %i-%i",start,end);
|
||||
|
||||
for (j = 0; j < data->ranges->len; j++) {
|
||||
|
||||
curr_range = (mate_range*) g_ptr_array_index(data->ranges,j);
|
||||
|
||||
dbg_print(dbg_pdu,6,dbg_facility,"get_pdu_fields: check if in range %i-%i",curr_range->start,curr_range->end);
|
||||
|
||||
if (curr_range->end >= end && curr_range->start <= start) {
|
||||
avp = new_avp_from_finfo(name, fi);
|
||||
|
||||
if (*dbg_pdu > 4) {
|
||||
s = avp_to_str(avp);
|
||||
dbg_print(dbg_pdu,5,dbg_facility,"get_pdu_fields: got %s",s);
|
||||
dbg_print(dbg_pdu,0,dbg_facility,"get_pdu_fields: got %s",s);
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
|
@ -720,7 +693,7 @@ static void get_pdu_fields(gpointer k, gpointer v, gpointer p) {
|
|||
}
|
||||
|
||||
static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto, GHashTable* interesting) {
|
||||
mate_pdu* pdu = new_mate_item(cfg);
|
||||
mate_pdu* pdu = g_mem_chunk_alloc(rd->mate_items);
|
||||
field_info* cfi;
|
||||
GPtrArray* ptrs;
|
||||
mate_range* range;
|
||||
|
@ -734,19 +707,25 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
|
|||
gint32 curr_end;
|
||||
int hfid;
|
||||
|
||||
dbg_print (dbg_pdu,2,dbg_facility,"new_pdu: type=%s framenum=%i",cfg->name,framenum);
|
||||
|
||||
dbg_print (dbg_pdu,1,dbg_facility,"new_pdu: type=%s framenum=%i",cfg->name,framenum);
|
||||
|
||||
pdu->id = ++(cfg->last_id);
|
||||
pdu->cfg = cfg;
|
||||
|
||||
pdu->avpl = new_avpl(cfg->name);
|
||||
pdu->gop = NULL;
|
||||
|
||||
pdu->frame = framenum;
|
||||
pdu->next_in_frame = NULL;
|
||||
pdu->rel_time = rd->now;
|
||||
|
||||
pdu->gop = NULL;
|
||||
pdu->next = NULL;
|
||||
pdu->time_in_gop = -1.0;
|
||||
|
||||
pdu->first = FALSE;
|
||||
pdu->is_start = FALSE;
|
||||
pdu->is_stop = FALSE;
|
||||
pdu->after_release = FALSE;
|
||||
pdu->frame = framenum;
|
||||
pdu->rel_time = rd->now;
|
||||
pdu->time_in_gop = -1.0;
|
||||
|
||||
data.ranges = g_ptr_array_new();
|
||||
data.pdu = pdu;
|
||||
|
@ -762,8 +741,8 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
|
|||
|
||||
last_start = proto_range->start;
|
||||
|
||||
/* first we move forward in the tranport */
|
||||
for (i = 0; i < cfg->transport_ranges->len; i++) {
|
||||
/* we move forward in the tranport */
|
||||
for (i = cfg->transport_ranges->len; i--; ) {
|
||||
hfid = *((int*)g_ptr_array_index(cfg->transport_ranges,i));
|
||||
ptrs = (GPtrArray*) g_hash_table_lookup(interesting,GINT_TO_POINTER(hfid));
|
||||
min_dist = 99999;
|
||||
|
@ -799,7 +778,7 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
|
|||
|
||||
first_end = proto_range->end;
|
||||
|
||||
for (i = cfg->payload_ranges->len - 1 ; i+1; i--) {
|
||||
for (i = 0 ; i < cfg->payload_ranges->len; i++) {
|
||||
hfid = *((int*)g_ptr_array_index(cfg->payload_ranges,i));
|
||||
ptrs = (GPtrArray*) g_hash_table_lookup(interesting,GINT_TO_POINTER(hfid));
|
||||
min_dist = 99999;
|
||||
|
@ -826,7 +805,7 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
|
|||
dbg_print(dbg_pdu,3,dbg_facility,"new_pdu: payload(%i) range %i-%i",hfid,range->start,range->end);
|
||||
} else {
|
||||
/* we missed a range */
|
||||
dbg_print(dbg_pdu,6,dbg_facility,"new_pdu: payload(%i) missed",hfid);
|
||||
dbg_print(dbg_pdu,5,dbg_facility,"new_pdu: payload(%i) missed",hfid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -835,17 +814,14 @@ static mate_pdu* new_pdu(mate_cfg_pdu* cfg, guint32 framenum, field_info* proto,
|
|||
|
||||
g_hash_table_foreach(cfg->hfids_attr,get_pdu_fields,&data);
|
||||
|
||||
apply_transforms(pdu->cfg->transforms,pdu->avpl);
|
||||
|
||||
g_ptr_array_free(data.ranges,TRUE);
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
||||
|
||||
static void delete_mate_pdu(mate_pdu* pdu) {
|
||||
if (pdu->avpl) delete_avpl(pdu->avpl,TRUE);
|
||||
g_mem_chunk_free(rd->mate_items,pdu);
|
||||
}
|
||||
|
||||
extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree) {
|
||||
mate_cfg_pdu* cfg;
|
||||
GPtrArray* protos;
|
||||
|
@ -879,28 +855,32 @@ extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree) {
|
|||
|
||||
if (cfg->criterium) {
|
||||
criterium_match = new_avpl_from_match(cfg->criterium_match_mode,"",pdu->avpl,cfg->criterium,FALSE);
|
||||
|
||||
if (criterium_match) {
|
||||
delete_avpl(criterium_match,FALSE);
|
||||
}
|
||||
|
||||
if ( (criterium_match && cfg->criterium->name == mc->reject )
|
||||
|| ( ! criterium_match && cfg->criterium->name == mc->accept )) {
|
||||
delete_mate_pdu(pdu);
|
||||
if ( (criterium_match && cfg->criterium_accept_mode == REJECT_MODE )
|
||||
|| ( ! criterium_match && cfg->criterium_accept_mode == ACCEPT_MODE )) {
|
||||
|
||||
delete_avpl(pdu->avpl,TRUE);
|
||||
g_mem_chunk_free(rd->mate_items,pdu);
|
||||
pdu = NULL;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
analize_pdu(pdu);
|
||||
|
||||
if ( ! pdu->gop && cfg->drop_pdu) {
|
||||
if ( ! pdu->gop && cfg->drop_unassigned) {
|
||||
delete_avpl(pdu->avpl,TRUE);
|
||||
g_mem_chunk_free(rd->mate_items,pdu);
|
||||
pdu = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( cfg->discard_pdu_attributes ) {
|
||||
if ( cfg->discard ) {
|
||||
delete_avpl(pdu->avpl,TRUE);
|
||||
pdu->avpl = NULL;
|
||||
}
|
||||
|
@ -915,7 +895,7 @@ extern void mate_analyze_frame(packet_info *pinfo, proto_tree* tree) {
|
|||
|
||||
}
|
||||
|
||||
if ( pdu && cfg->last_to_be_created ) break;
|
||||
if ( pdu && cfg->last_extracted ) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,8 +40,8 @@
|
|||
* fmt, ...: what to print
|
||||
*/
|
||||
|
||||
void dbg_print(const guint* which, guint how, FILE* where, guint8* fmt, ... ) {
|
||||
static guint8 debug_buffer[DEBUG_BUFFER_SIZE];
|
||||
void dbg_print(const gint* which, gint how, FILE* where, gchar* fmt, ... ) {
|
||||
static gchar debug_buffer[DEBUG_BUFFER_SIZE];
|
||||
va_list list;
|
||||
|
||||
if ( ! which || *which < how ) return;
|
||||
|
@ -130,8 +130,8 @@ extern SCS_collection* scs_init(void) {
|
|||
*
|
||||
* Return value: a pointer to the subscribed string.
|
||||
**/
|
||||
guint8* scs_subscribe(SCS_collection* c, guint8* s) {
|
||||
guint8* orig = NULL;
|
||||
gchar* scs_subscribe(SCS_collection* c, gchar* s) {
|
||||
gchar* orig = NULL;
|
||||
guint* ip = NULL;
|
||||
size_t len = 0;
|
||||
GMemChunk* chunk = NULL;
|
||||
|
@ -181,8 +181,8 @@ guint8* scs_subscribe(SCS_collection* c, guint8* s) {
|
|||
* decreases the count of subscribers, if zero frees the internal copy of
|
||||
* the string.
|
||||
**/
|
||||
void scs_unsubscribe(SCS_collection* c, guint8* s) {
|
||||
guint8* orig = NULL;
|
||||
void scs_unsubscribe(SCS_collection* c, gchar* s) {
|
||||
gchar* orig = NULL;
|
||||
guint* ip = NULL;
|
||||
size_t len = 0xffff;
|
||||
GMemChunk* chunk = NULL;
|
||||
|
@ -225,9 +225,9 @@ void scs_unsubscribe(SCS_collection* c, guint8* s) {
|
|||
* Return value: the stored copy of the formated string.
|
||||
*
|
||||
**/
|
||||
extern guint8* scs_subscribe_printf(SCS_collection* c, guint8* fmt, ...) {
|
||||
extern gchar* scs_subscribe_printf(SCS_collection* c, gchar* fmt, ...) {
|
||||
va_list list;
|
||||
static guint8 buf[SCS_HUGE_SIZE];
|
||||
static gchar buf[SCS_HUGE_SIZE];
|
||||
|
||||
va_start( list, fmt );
|
||||
g_vsnprintf(buf, SCS_HUGE_SIZE-1 ,fmt, list);
|
||||
|
@ -236,16 +236,16 @@ extern guint8* scs_subscribe_printf(SCS_collection* c, guint8* fmt, ...) {
|
|||
return scs_subscribe(c,buf);
|
||||
}
|
||||
|
||||
extern guint8* scs_subscribe_int(SCS_collection* c, int i) {
|
||||
static guint8 buf[SCS_SMALL_SIZE];
|
||||
extern gchar* scs_subscribe_int(SCS_collection* c, int i) {
|
||||
static gchar buf[SCS_SMALL_SIZE];
|
||||
|
||||
g_snprintf(buf, SCS_SMALL_SIZE-1 ,"%i", i);
|
||||
|
||||
return scs_subscribe(c,buf);
|
||||
}
|
||||
|
||||
extern guint8* scs_subscribe_float(SCS_collection* c, float f) {
|
||||
static guint8 buf[SCS_SMALL_SIZE];
|
||||
extern gchar* scs_subscribe_float(SCS_collection* c, float f) {
|
||||
static gchar buf[SCS_SMALL_SIZE];
|
||||
|
||||
g_snprintf(buf, SCS_SMALL_SIZE-1 ,"%f", f);
|
||||
|
||||
|
@ -346,9 +346,9 @@ extern void avp_init(void) {
|
|||
* Return value: a pointer to the newly created avp.
|
||||
*
|
||||
**/
|
||||
extern AVP* new_avp_from_finfo(guint8* name, field_info* finfo) {
|
||||
extern AVP* new_avp_from_finfo(gchar* name, field_info* finfo) {
|
||||
AVP* new = g_mem_chunk_alloc(avp_chunk);
|
||||
guint8* value;
|
||||
gchar* value;
|
||||
|
||||
new->n = scs_subscribe(avp_strings, name);
|
||||
|
||||
|
@ -397,7 +397,7 @@ extern AVP* new_avp_from_finfo(guint8* name, field_info* finfo) {
|
|||
* Return value: a pointer to the newly created avp.
|
||||
*
|
||||
**/
|
||||
extern AVP* new_avp(guint8* name, guint8* value, guint8 o) {
|
||||
extern AVP* new_avp(gchar* name, gchar* value, gchar o) {
|
||||
AVP* new = g_mem_chunk_alloc(avp_chunk);
|
||||
|
||||
new->n = scs_subscribe(avp_strings, name);
|
||||
|
@ -453,8 +453,8 @@ extern AVP* avp_copy(AVP* from) {
|
|||
}
|
||||
|
||||
|
||||
extern void rename_avp(AVP* avp, guint8* name) {
|
||||
guint8* s = avp->n;
|
||||
extern void rename_avp(AVP* avp, gchar* name) {
|
||||
gchar* s = avp->n;
|
||||
avp->n = scs_subscribe(avp_strings,name);
|
||||
scs_unsubscribe(avp_strings,s);
|
||||
}
|
||||
|
@ -468,14 +468,14 @@ extern void rename_avp(AVP* avp, guint8* name) {
|
|||
* Return value: a pointer to the newly created avpl.
|
||||
*
|
||||
**/
|
||||
extern AVPL* new_avpl(guint8* name) {
|
||||
extern AVPL* new_avpl(gchar* name) {
|
||||
AVPL* new_avpl = g_mem_chunk_alloc(avp_chunk);
|
||||
|
||||
#ifdef _AVP_DEBUGGING
|
||||
dbg_print(dbg_avpl_op,7,dbg_fp,"new_avpl: %X name=%s",new_avpl,name);
|
||||
#endif
|
||||
|
||||
new_avpl->name = scs_subscribe(avp_strings, name);
|
||||
new_avpl->name = name ? scs_subscribe(avp_strings, name) : scs_subscribe(avp_strings, "");
|
||||
new_avpl->len = 0;
|
||||
new_avpl->null.avp = NULL;
|
||||
new_avpl->null.next = &new_avpl->null;
|
||||
|
@ -485,7 +485,7 @@ extern AVPL* new_avpl(guint8* name) {
|
|||
return new_avpl;
|
||||
}
|
||||
|
||||
extern void rename_avpl(AVPL* avpl, guint8* name) {
|
||||
extern void rename_avpl(AVPL* avpl, gchar* name) {
|
||||
scs_unsubscribe(avp_strings,avpl->name);
|
||||
avpl->name = scs_subscribe(avp_strings,name);
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ extern gboolean insert_avp(AVPL* avpl, AVP* avp) {
|
|||
* Return value: a pointer to the next matching avp if there's one, else NULL.
|
||||
*
|
||||
**/
|
||||
extern AVP* get_avp_by_name(AVPL* avpl, guint8* name, void** cookie) {
|
||||
extern AVP* get_avp_by_name(AVPL* avpl, gchar* name, void** cookie) {
|
||||
AVPN* curr;
|
||||
AVPN* start = (AVPN*) *cookie;
|
||||
|
||||
|
@ -607,7 +607,7 @@ extern AVP* get_avp_by_name(AVPL* avpl, guint8* name, void** cookie) {
|
|||
* Return value: a pointer to extracted avp if there's one, else NULL.
|
||||
*
|
||||
**/
|
||||
extern AVP* extract_avp_by_name(AVPL* avpl, guint8* name) {
|
||||
extern AVP* extract_avp_by_name(AVPL* avpl, gchar* name) {
|
||||
AVPN* curr;
|
||||
AVP* avp = NULL;
|
||||
|
||||
|
@ -794,11 +794,11 @@ extern AVP* get_next_avp(AVPL* avpl, void** cookie) {
|
|||
* Return value: a pointer to the newly allocated string.
|
||||
*
|
||||
**/
|
||||
guint8* avpl_to_str(AVPL* avpl) {
|
||||
gchar* avpl_to_str(AVPL* avpl) {
|
||||
AVPN* c;
|
||||
GString* s = g_string_new("");
|
||||
guint8* avp_s;
|
||||
guint8* r;
|
||||
gchar* avp_s;
|
||||
gchar* r;
|
||||
|
||||
for(c=avpl->null.next; c->avp; c = c->next) {
|
||||
avp_s = avp_to_str(c->avp);
|
||||
|
@ -813,11 +813,11 @@ guint8* avpl_to_str(AVPL* avpl) {
|
|||
return r;
|
||||
}
|
||||
|
||||
extern guint8* avpl_to_dotstr(AVPL* avpl) {
|
||||
extern gchar* avpl_to_dotstr(AVPL* avpl) {
|
||||
AVPN* c;
|
||||
GString* s = g_string_new("");
|
||||
guint8* avp_s;
|
||||
guint8* r;
|
||||
gchar* avp_s;
|
||||
gchar* r;
|
||||
|
||||
for(c=avpl->null.next; c->avp; c = c->next) {
|
||||
avp_s = avp_to_str(c->avp);
|
||||
|
@ -913,7 +913,7 @@ extern void merge_avpl(AVPL* dst, AVPL* src, gboolean copy_avps) {
|
|||
* Return value: a pointer to the newly allocated string.
|
||||
*
|
||||
**/
|
||||
extern AVPL* new_avpl_from_avpl(guint8* name, AVPL* avpl, gboolean copy_avps) {
|
||||
extern AVPL* new_avpl_from_avpl(gchar* name, AVPL* avpl, gboolean copy_avps) {
|
||||
AVPL* newavpl = new_avpl(name);
|
||||
void* cookie = NULL;
|
||||
AVP* avp;
|
||||
|
@ -1043,7 +1043,7 @@ extern AVP* match_avp(AVP* src, AVP* op) {
|
|||
* Return value: a pointer to the newly created avpl containing the
|
||||
* matching avps.
|
||||
**/
|
||||
extern AVPL* new_avpl_loose_match(guint8* name,
|
||||
extern AVPL* new_avpl_loose_match(gchar* name,
|
||||
AVPL* src,
|
||||
AVPL* op,
|
||||
gboolean copy_avps) {
|
||||
|
@ -1121,19 +1121,26 @@ extern AVPL* new_avpl_loose_match(guint8* name,
|
|||
* Return value: a pointer to the newly created avpl containing the
|
||||
* matching avps.
|
||||
**/
|
||||
extern AVPL* new_avpl_every_match(guint8* name, AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
AVPL* newavpl = new_avpl(scs_subscribe(avp_strings, name));
|
||||
extern AVPL* new_avpl_every_match(gchar* name, AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
AVPL* newavpl;
|
||||
AVPN* co = NULL;
|
||||
AVPN* cs = NULL;
|
||||
gint c;
|
||||
AVP* m;
|
||||
AVP* copy;
|
||||
|
||||
gboolean matches;
|
||||
|
||||
#ifdef _AVP_DEBUGGING
|
||||
dbg_print(dbg_avpl_op,3,dbg_fp,"new_avpl_every_match: %X src=%X op=%X name='%s'",newavpl,src,op,name);
|
||||
#endif
|
||||
|
||||
gboolean matches = TRUE;
|
||||
if (src->len == 0) return NULL;
|
||||
|
||||
newavpl = new_avpl(scs_subscribe(avp_strings, name));
|
||||
|
||||
if (op->len == 0)
|
||||
return newavpl;
|
||||
|
||||
matches = TRUE;
|
||||
|
||||
cs = src->null.next;
|
||||
co = op->null.next;
|
||||
|
@ -1205,7 +1212,7 @@ extern AVPL* new_avpl_every_match(guint8* name, AVPL* src, AVPL* op, gboolean co
|
|||
* Return value: a pointer to the newly created avpl containing the
|
||||
* matching avps.
|
||||
**/
|
||||
extern AVPL* new_avpl_exact_match(guint8* name,AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
extern AVPL* new_avpl_exact_match(gchar* name,AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
AVPL* newavpl = new_avpl(name);
|
||||
AVPN* co = NULL;
|
||||
AVPN* cs = NULL;
|
||||
|
@ -1219,7 +1226,12 @@ extern AVPL* new_avpl_exact_match(guint8* name,AVPL* src, AVPL* op, gboolean cop
|
|||
|
||||
if (op->len == 0)
|
||||
return newavpl;
|
||||
|
||||
|
||||
if (src->len == 0) {
|
||||
delete_avpl(newavpl,FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cs = src->null.next;
|
||||
co = op->null.next;
|
||||
while(1) {
|
||||
|
@ -1271,7 +1283,7 @@ extern AVPL* new_avpl_exact_match(guint8* name,AVPL* src, AVPL* op, gboolean cop
|
|||
return NULL;
|
||||
}
|
||||
|
||||
extern AVPL* new_avpl_from_match(avpl_match_mode mode, guint8* name,AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
extern AVPL* new_avpl_from_match(avpl_match_mode mode, gchar* name,AVPL* src, AVPL* op, gboolean copy_avps) {
|
||||
AVPL* avpl = NULL;
|
||||
|
||||
switch (mode) {
|
||||
|
@ -1300,7 +1312,7 @@ extern AVPL* new_avpl_from_match(avpl_match_mode mode, guint8* name,AVPL* src, A
|
|||
*
|
||||
* Return value: a pointer to the newly created avpl transformation
|
||||
**/
|
||||
extern AVPL_Transf* new_avpl_transform(guint8* name, AVPL* mixed, avpl_match_mode match_mode, avpl_replace_mode replace_mode) {
|
||||
extern AVPL_Transf* new_avpl_transform(gchar* name, AVPL* mixed, avpl_match_mode match_mode, avpl_replace_mode replace_mode) {
|
||||
AVPL_Transf* t = g_malloc(sizeof(AVPL_Transf));
|
||||
AVP* avp;
|
||||
|
||||
|
@ -1423,7 +1435,7 @@ extern void avpl_transform(AVPL* src, AVPL_Transf* op) {
|
|||
*
|
||||
* Return value: a pointer to the newly created loal.
|
||||
**/
|
||||
extern LoAL* new_loal(guint8* name) {
|
||||
extern LoAL* new_loal(gchar* name) {
|
||||
LoAL* new_loal = g_mem_chunk_alloc(avp_chunk);
|
||||
|
||||
if (! name) {
|
||||
|
@ -1602,11 +1614,11 @@ extern void delete_loal(LoAL* loal, gboolean avpls_too, gboolean avps_too) {
|
|||
* load_loal_error:
|
||||
* Used by loal_from_file to handle errors while loading.
|
||||
**/
|
||||
LoAL* load_loal_error(FILE* fp, LoAL* loal, AVPL* curr, int linenum, guint8* fmt, ...) {
|
||||
LoAL* load_loal_error(FILE* fp, LoAL* loal, AVPL* curr, int linenum, gchar* fmt, ...) {
|
||||
va_list list;
|
||||
guint8* desc;
|
||||
gchar* desc;
|
||||
LoAL* ret = NULL;
|
||||
guint8* err;
|
||||
gchar* err;
|
||||
|
||||
va_start( list, fmt );
|
||||
desc = g_strdup_vprintf(fmt, list);
|
||||
|
@ -1652,15 +1664,15 @@ case '7': case '8': case '9': case '.'
|
|||
* Return value: if successful a pointer to the new populated loal, else NULL.
|
||||
*
|
||||
**/
|
||||
extern LoAL* loal_from_file(guint8* filename) {
|
||||
extern LoAL* loal_from_file(gchar* filename) {
|
||||
FILE *fp = NULL;
|
||||
guint8 c;
|
||||
gchar c;
|
||||
int i = 0;
|
||||
guint32 linenum = 1;
|
||||
guint8 linenum_buf[MAX_ITEM_LEN];
|
||||
guint8 name[MAX_ITEM_LEN];
|
||||
guint8 value[MAX_ITEM_LEN];
|
||||
guint8 op = '?';
|
||||
gchar linenum_buf[MAX_ITEM_LEN];
|
||||
gchar name[MAX_ITEM_LEN];
|
||||
gchar value[MAX_ITEM_LEN];
|
||||
gchar op = '?';
|
||||
LoAL *loal = new_loal(filename);
|
||||
AVPL* curr = NULL;
|
||||
AVP* avp;
|
||||
|
@ -1682,7 +1694,7 @@ extern LoAL* loal_from_file(guint8* filename) {
|
|||
state = START;
|
||||
|
||||
if (( fp = fopen(filename,"r") )) {
|
||||
while(( c = (guint8) fgetc(fp) )){
|
||||
while(( c = (gchar) fgetc(fp) )){
|
||||
|
||||
if ( feof(fp) ) {
|
||||
if ( ferror(fp) ) {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
/******* dbg_print *********/
|
||||
#define DEBUG_BUFFER_SIZE 4096
|
||||
extern void dbg_print(const guint* which, guint how, FILE* where, guint8* fmt, ... );
|
||||
extern void dbg_print(const gint* which, gint how, FILE* where, gchar* fmt, ... );
|
||||
|
||||
|
||||
/******* single copy strings *********/
|
||||
|
@ -56,9 +56,9 @@ typedef struct _scs_collection SCS_collection;
|
|||
|
||||
extern void destroy_scs_collection(SCS_collection* c);
|
||||
extern SCS_collection* scs_init(void);
|
||||
extern guint8* scs_subscribe(SCS_collection* collection, guint8* s);
|
||||
extern void scs_unsubscribe(SCS_collection* collection, guint8* s);
|
||||
extern guint8* scs_subscribe_printf(SCS_collection* collection, guint8* fmt, ...);
|
||||
extern gchar* scs_subscribe(SCS_collection* collection, gchar* s);
|
||||
extern void scs_unsubscribe(SCS_collection* collection, gchar* s);
|
||||
extern gchar* scs_subscribe_printf(SCS_collection* collection, gchar* fmt, ...);
|
||||
|
||||
/******* AVPs & Co. *********/
|
||||
#define AVP_CHUNK_SIZE 4096
|
||||
|
@ -78,9 +78,9 @@ extern guint8* scs_subscribe_printf(SCS_collection* collection, guint8* fmt, ...
|
|||
|
||||
/* an avp is an object made of a name a value and an operator */
|
||||
typedef struct _avp {
|
||||
guint8* n;
|
||||
guint8* v;
|
||||
guint8 o;
|
||||
gchar* n;
|
||||
gchar* v;
|
||||
gchar o;
|
||||
} AVP;
|
||||
|
||||
/* avp nodes are used in avp lists */
|
||||
|
@ -92,7 +92,7 @@ typedef struct _avp_node {
|
|||
|
||||
/* an avp list is a sorted set of avps */
|
||||
typedef struct _avp_list {
|
||||
guint8* name;
|
||||
gchar* name;
|
||||
guint32 len;
|
||||
AVPN null;
|
||||
} AVPL;
|
||||
|
@ -116,7 +116,7 @@ typedef enum _avpl_replace_mode {
|
|||
typedef struct _avpl_transf AVPL_Transf;
|
||||
|
||||
struct _avpl_transf {
|
||||
guint8* name;
|
||||
gchar* name;
|
||||
|
||||
AVPL* match;
|
||||
AVPL* replace;
|
||||
|
@ -138,7 +138,7 @@ typedef struct _loal_node {
|
|||
|
||||
/* a loal is a list of avp lists */
|
||||
typedef struct _loal {
|
||||
guint8* name;
|
||||
gchar* name;
|
||||
guint len;
|
||||
LoALnode null;
|
||||
} LoAL;
|
||||
|
@ -157,13 +157,13 @@ extern void setup_avp_debug(FILE* fp, int* general, int* avp, int* avp_op, int*
|
|||
*/
|
||||
|
||||
/* creates a new avp */
|
||||
extern AVP* new_avp(guint8* name, guint8* value, guint8 op);
|
||||
extern AVP* new_avp(gchar* name, gchar* value, gchar op);
|
||||
|
||||
/* creates a copy od an avp */
|
||||
extern AVP* avp_copy(AVP* from);
|
||||
|
||||
/* creates an avp from a field_info record */
|
||||
extern AVP* new_avp_from_finfo(guint8* name, field_info* finfo);
|
||||
extern AVP* new_avp_from_finfo(gchar* name, field_info* finfo);
|
||||
|
||||
/*
|
||||
* avp destructor
|
||||
|
@ -185,26 +185,26 @@ extern AVP* match_avp(AVP* src, AVP* op);
|
|||
*/
|
||||
|
||||
/* creates an empty avp list */
|
||||
extern AVPL* new_avpl(guint8* name);
|
||||
extern AVPL* new_avpl(gchar* name);
|
||||
|
||||
|
||||
/* creates a copy of an avp list */
|
||||
extern AVPL* new_avpl_from_avpl(guint8* name, AVPL* avpl, gboolean copy_avps);
|
||||
extern AVPL* new_avpl_from_avpl(gchar* name, AVPL* avpl, gboolean copy_avps);
|
||||
|
||||
/* creates an avp list containing any avps in src matching any avps in op
|
||||
it will eventually create an empty list in none match */
|
||||
extern AVPL* new_avpl_loose_match(guint8* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
extern AVPL* new_avpl_loose_match(gchar* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
|
||||
/* creates an avp list containing any avps in src matching every avp in op
|
||||
it will not create a list if there is not a match for every attribute in op */
|
||||
extern AVPL* new_avpl_every_match(guint8* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
extern AVPL* new_avpl_every_match(gchar* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
|
||||
/* creates an avp list containing every avp in src matching every avp in op
|
||||
it will not create a list unless every avp in op is matched only once to avery avp in op */
|
||||
extern AVPL* new_avpl_exact_match(guint8* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
extern AVPL* new_avpl_exact_match(gchar* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
|
||||
/* uses mode to call one of the former matches. NO_MATCH = merge(merge(copy(src),op)) */
|
||||
extern AVPL* new_avpl_from_match(avpl_match_mode mode, guint8* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
extern AVPL* new_avpl_from_match(avpl_match_mode mode, gchar* name,AVPL* src, AVPL* op, gboolean copy_avps);
|
||||
|
||||
|
||||
|
||||
|
@ -221,14 +221,14 @@ extern void delete_avpl(AVPL* avpl, gboolean avps_too);
|
|||
extern gboolean insert_avp(AVPL* avpl, AVP* avp);
|
||||
|
||||
/* renames an avpl */
|
||||
extern void rename_avpl(AVPL* avpl, guint8* name);
|
||||
extern void rename_avpl(AVPL* avpl, gchar* name);
|
||||
|
||||
/* it will add all the avps in src which don't match(*) any attribute in dest */
|
||||
extern void merge_avpl(AVPL* dest, AVPL* src, gboolean copy);
|
||||
|
||||
/* it will return the first avp in an avpl whose name matches the given name.
|
||||
will return NULL if there is not anyone matching */
|
||||
extern AVP* get_avp_by_name(AVPL* avpl, guint8* name, void** cookie);
|
||||
extern AVP* get_avp_by_name(AVPL* avpl, gchar* name, void** cookie);
|
||||
|
||||
/* it will get the next avp from an avpl, using cookie to keep state */
|
||||
extern AVP* get_next_avp(AVPL* avpl, void** cookie);
|
||||
|
@ -241,11 +241,11 @@ extern AVP* extract_last_avp(AVPL* avpl);
|
|||
|
||||
/* it will extract the first avp in an avpl whose name matches the given name.
|
||||
it will not extract any and return NULL if there is not anyone matching */
|
||||
extern AVP* extract_avp_by_name(AVPL* avpl, guint8* name);
|
||||
extern AVP* extract_avp_by_name(AVPL* avpl, gchar* name);
|
||||
|
||||
/* returns a newly allocated string containing a representation of the avp list */
|
||||
extern guint8* avpl_to_str(AVPL* avpl);
|
||||
extern guint8* avpl_to_dotstr(AVPL*);
|
||||
extern gchar* avpl_to_str(AVPL* avpl);
|
||||
extern gchar* avpl_to_dotstr(AVPL*);
|
||||
|
||||
/* deletes an avp list and eventually it's contents */
|
||||
extern void delete_avpl(AVPL* avpl, gboolean avps_too);
|
||||
|
@ -253,7 +253,6 @@ extern void delete_avpl(AVPL* avpl, gboolean avps_too);
|
|||
/*
|
||||
* AVPL transformations
|
||||
*/
|
||||
extern AVPL_Transf* new_avpl_transform(guint8* name, AVPL* mixed, avpl_match_mode match_mode, avpl_replace_mode replace_mode);
|
||||
extern void delete_avpl_transform(AVPL_Transf* it);
|
||||
extern void avpl_transform(AVPL* src, AVPL_Transf* op);
|
||||
|
||||
|
@ -263,11 +262,11 @@ extern void avpl_transform(AVPL* src, AVPL_Transf* op);
|
|||
*/
|
||||
|
||||
/* creates an empty list of avp lists */
|
||||
extern LoAL* new_loal(guint8* name);
|
||||
extern LoAL* new_loal(gchar* name);
|
||||
|
||||
/* given a file loads all the avpls contained in it
|
||||
every line is formatted as it is the output of avplist_to_string */
|
||||
extern LoAL* loal_from_file(guint8* filename);
|
||||
extern LoAL* loal_from_file(gchar* filename);
|
||||
|
||||
/* inserts an avplist into a LoAL */
|
||||
extern void loal_append(LoAL* loal, AVPL* avpl);
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
#endif
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.0.4"
|
||||
#define VERSION "1.0.0a"
|
||||
|
||||
|
|
|
@ -37,27 +37,69 @@ static mate_config* mc = NULL;
|
|||
|
||||
static int proto_mate = -1;
|
||||
|
||||
static char* pref_mate_config_filename = "";
|
||||
static char* current_mate_config_filename = NULL;
|
||||
static gchar* pref_mate_config_filename = "";
|
||||
static gchar* current_mate_config_filename = NULL;
|
||||
|
||||
static proto_item *mate_i = NULL;
|
||||
|
||||
void attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_item* item) {
|
||||
void pdu_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_pdu* pdu) {
|
||||
AVPN* c;
|
||||
proto_item *avpl_i;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
||||
avpl_i = proto_tree_add_text(tree,tvb,0,0,"%s Attributes",item->cfg->name);
|
||||
avpl_t = proto_item_add_subtree(avpl_i, item->cfg->ett_attr);
|
||||
|
||||
for ( c = item->avpl->null.next; c->avp; c = c->next) {
|
||||
hfi_p = g_hash_table_lookup(item->cfg->my_hfids,(char*)c->avp->n);
|
||||
|
||||
avpl_i = proto_tree_add_text(tree,tvb,0,0,"%s Attributes",pdu->cfg->name);
|
||||
avpl_t = proto_item_add_subtree(avpl_i, pdu->cfg->ett_attr);
|
||||
|
||||
for ( c = pdu->avpl->null.next; c->avp; c = c->next) {
|
||||
hfi_p = g_hash_table_lookup(pdu->cfg->my_hfids,(char*)c->avp->n);
|
||||
|
||||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",item->cfg->name,c->avp->n);
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",pdu->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gop_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
||||
AVPN* c;
|
||||
proto_item *avpl_i;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
||||
avpl_i = proto_tree_add_text(tree,tvb,0,0,"%s Attributes",gop->cfg->name);
|
||||
avpl_t = proto_item_add_subtree(avpl_i, gop->cfg->ett_attr);
|
||||
|
||||
for ( c = gop->avpl->null.next; c->avp; c = c->next) {
|
||||
hfi_p = g_hash_table_lookup(gop->cfg->my_hfids,(char*)c->avp->n);
|
||||
|
||||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",gop->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gog_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog) {
|
||||
AVPN* c;
|
||||
proto_item *avpl_i;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
||||
avpl_i = proto_tree_add_text(tree,tvb,0,0,"%s Attributes",gog->cfg->name);
|
||||
avpl_t = proto_item_add_subtree(avpl_i, gog->cfg->ett_attr);
|
||||
|
||||
for ( c = gog->avpl->null.next; c->avp; c = c->next) {
|
||||
hfi_p = g_hash_table_lookup(gog->cfg->my_hfids,(char*)c->avp->n);
|
||||
|
||||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",gog->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +128,7 @@ void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop
|
|||
gog_item = proto_tree_add_uint(tree,gog->cfg->hfid,tvb,0,0,gog->id);
|
||||
gog_tree = proto_item_add_subtree(gog_item,gog->cfg->ett);
|
||||
|
||||
attrs_tree(gog_tree,tvb,gog);
|
||||
gog_attrs_tree(gog_tree,tvb,gog);
|
||||
|
||||
if (gog->cfg->show_times) {
|
||||
gog_time_item = proto_tree_add_text(gog_tree,tvb,0,0,"%s Times",gog->cfg->name);
|
||||
|
@ -104,12 +146,12 @@ void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop
|
|||
for (gog_gops = gog->gops; gog_gops; gog_gops = gog_gops->next) {
|
||||
|
||||
if (gop != gog_gops) {
|
||||
if (gog->cfg->gop_as_subtree == mc->full_tree) {
|
||||
if (gog->cfg->gop_tree_mode == GOP_FULL_TREE) {
|
||||
mate_gop_tree(gog_gops_tree, tvb, gog_gops);
|
||||
} else {
|
||||
gog_gop_item = proto_tree_add_uint(gog_gops_tree,gog_gops->cfg->hfid,tvb,0,0,gog_gops->id);
|
||||
|
||||
if (gog->cfg->gop_as_subtree == mc->basic_tree) {
|
||||
if (gog->cfg->gop_tree_mode == GOP_BASIC_TREE) {
|
||||
gog_gop_tree = proto_item_add_subtree(gog_gop_item, gog->cfg->ett_gog_gop);
|
||||
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "Started at: %f", gog_gops->start_time);
|
||||
|
@ -124,7 +166,7 @@ void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop
|
|||
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "Number of Pdus: %u",gog_gops->num_of_pdus);
|
||||
|
||||
if (gop->pdus && gop->cfg->show_pdu_tree == mc->frame_tree) {
|
||||
if (gop->pdus && gop->cfg->pdu_tree_mode != GOP_NO_TREE) {
|
||||
proto_tree_add_uint(gog_gop_tree,gog->cfg->hfid_gog_gopstart,tvb,0,0,gog_gops->pdus->frame);
|
||||
|
||||
for (pdu = gog_gops->pdus->next ; pdu; pdu = pdu->next) {
|
||||
|
@ -163,7 +205,7 @@ void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
|||
|
||||
if (gop->gop_key) proto_tree_add_text(gop_tree,tvb,0,0,"GOP Key: %s",gop->gop_key);
|
||||
|
||||
attrs_tree(gop_tree,tvb,gop);
|
||||
gop_attrs_tree(gop_tree,tvb,gop);
|
||||
|
||||
if (gop->cfg->show_times) {
|
||||
gop_time_item = proto_tree_add_text(gop_tree,tvb,0,0,"%s Times",gop->cfg->name);
|
||||
|
@ -181,17 +223,17 @@ void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
|||
|
||||
gop_pdu_item = proto_tree_add_uint(gop_tree, gop->cfg->hfid_gop_num_pdus, tvb, 0, 0,gop->num_of_pdus);
|
||||
|
||||
if (gop->cfg->show_pdu_tree != mc->no_tree) {
|
||||
if (gop->cfg->pdu_tree_mode != GOP_NO_TREE) {
|
||||
|
||||
gop_pdu_tree = proto_item_add_subtree(gop_pdu_item, gop->cfg->ett_children);
|
||||
|
||||
rel_time = gop_time = gop->start_time;
|
||||
|
||||
type_str = (gop->cfg->show_pdu_tree == mc->frame_tree ) ? "in frame:" : "id:";
|
||||
type_str = (gop->cfg->pdu_tree_mode == GOP_FRAME_TREE ) ? "in frame:" : "id:";
|
||||
|
||||
for (gop_pdus = gop->pdus; gop_pdus; gop_pdus = gop_pdus->next) {
|
||||
|
||||
pdu_item = (gop->cfg->show_pdu_tree == mc->frame_tree ) ? gop_pdus->frame : gop_pdus->id;
|
||||
pdu_item = (gop->cfg->pdu_tree_mode == GOP_FRAME_TREE ) ? gop_pdus->frame : gop_pdus->id;
|
||||
|
||||
if (gop_pdus->is_start) {
|
||||
pdu_str = "Start ";
|
||||
|
@ -249,7 +291,7 @@ void mate_pdu_tree(mate_pdu *pdu, tvbuff_t *tvb, proto_tree* tree) {
|
|||
}
|
||||
|
||||
if (pdu->avpl) {
|
||||
attrs_tree(pdu_tree,tvb,pdu);
|
||||
pdu_attrs_tree(pdu_tree,tvb,pdu);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,52 +317,47 @@ static int mate_packet(void *prs _U_, packet_info* tree _U_, epan_dissect_t *ed
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void init_mate(void) {
|
||||
GString* tap_error = NULL;
|
||||
|
||||
if ( ! mate_tap_data ) {
|
||||
tap_error = register_tap_listener("frame", &mate_tap_data,
|
||||
(char*) mc->tap_filter,
|
||||
(tap_reset_cb) NULL,
|
||||
mate_packet,
|
||||
(tap_draw_cb) NULL);
|
||||
}
|
||||
|
||||
if ( tap_error ) {
|
||||
g_warning("mate: couldn't (re)register tap: %s",tap_error->str);
|
||||
g_string_free(tap_error, TRUE);
|
||||
mate_tap_data = 0;
|
||||
return;
|
||||
} else {
|
||||
mate_tap_data = 1;
|
||||
}
|
||||
|
||||
initialize_mate_runtime();
|
||||
}
|
||||
|
||||
extern
|
||||
void
|
||||
proto_reg_handoff_mate(void)
|
||||
{
|
||||
GString* tap_error = NULL;
|
||||
|
||||
if ( *pref_mate_config_filename != '\0' ) {
|
||||
|
||||
if (current_mate_config_filename) {
|
||||
report_failure("Mate cannot reconfigure itself.\n"
|
||||
"for changes to be applied you have to save the preferences and restart ethereal\n");
|
||||
"for changes to be applied you have to restart ethereal\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mc) {
|
||||
mc = mate_make_config((char*)pref_mate_config_filename,proto_mate);
|
||||
mc = mate_make_config(pref_mate_config_filename,proto_mate);
|
||||
|
||||
if (mc) {
|
||||
/* XXX: alignment warnings, what do they mean? */
|
||||
proto_register_field_array(proto_mate, (hf_register_info*) mc->hfrs->data, mc->hfrs->len );
|
||||
proto_register_subtree_array((gint**) mc->ett->data, mc->ett->len);
|
||||
register_init_routine(init_mate);
|
||||
if (current_mate_config_filename == NULL) initialize_mate_runtime();
|
||||
register_init_routine(initialize_mate_runtime);
|
||||
|
||||
g_warning("filter: %s",mc->tap_filter);
|
||||
|
||||
tap_error = register_tap_listener("frame", &mate_tap_data,
|
||||
(char*) mc->tap_filter,
|
||||
(tap_reset_cb) NULL,
|
||||
mate_packet,
|
||||
(tap_draw_cb) NULL);
|
||||
|
||||
if ( tap_error ) {
|
||||
g_warning("mate: couldn't (re)register tap: %s",tap_error->str);
|
||||
g_string_free(tap_error, TRUE);
|
||||
mate_tap_data = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
initialize_mate_runtime();
|
||||
}
|
||||
|
||||
|
||||
current_mate_config_filename = pref_mate_config_filename;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue