-/*
+/* idl2wrs.c
+ * DCE RPC IDL to Wireshark dissector compiler
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
TODO
check that every cnf defined type,hffield,rename,... has been referenced
at least once and if not, abort with an error
- need to distinguish between NTTIME (absolute time) and relative time
+ need to distinguish between NTTIME (absolute time) and relative time
prune_xxx should only act inside of '[' ']'
NTTIME_hyper A 64 bit integer representing a NTTIME
NTTIME_1sec
- unistr A conformant and varying unicode string
+ unistr A conformant and varying unicode string
- ascstr A conformant and varying ascii string
+ ascstr A conformant and varying ascii string
- SID A SID structure.
+ SID A SID structure.
uuid_t A 16 byte FT_GUID blob.
- GUID
+ GUID
policy_handle
NTTIME
*/
-/* All field dissectors that call a normal type
+/* All field dissectors that call a normal type
(i.e. not a pointer, not an array)
has a local variable guint param declared which is passed on to the
type dissector.
#include <stdlib.h>
#include <stdarg.h>
-FILE *fh, *tfh, *eth_code, *eth_hdr, *eth_hf, *eth_hfarr, *eth_ett, *eth_ettarr, *eth_ft, *eth_handoff;
-char *uuid=NULL;
-char *version=NULL;
-char *pointer_default=NULL;
-char *ifname=NULL;
-char hf_status[256];
-int lineno,linepos;
-char line[1024];
+#undef IDL2WRS_DEBUG
+
+static FILE *tfh, *eth_code, *eth_hdr, *eth_hf, *eth_hfarr, *eth_ett, *eth_ettarr, *eth_ft, *eth_handoff;
+static char *uuid=NULL;
+static char *version=NULL;
+static const char *pointer_default=NULL;
+static char *ifname=NULL;
+static char hf_status[256];
+static int lineno,linepos;
+static char line[1024];
-void FPRINTF(FILE *fh, const char *format, ...)
+static void FPRINTF(FILE *fh, const char *format, ...)
{
va_list args;
+
+#ifdef IDL2WRS_DEBUG
va_start(args, format);
vfprintf (stderr, format, args);
- if (fh)
- vfprintf (fh, format, args);
va_end(args);
+#endif
+ if (fh) {
+ va_start(args, format);
+ vfprintf (fh, format, args);
+ va_end(args);
+ }
}
typedef struct _pointer_item_t {
struct _pointer_item_t *next;
- char *type;
+ const char *type;
} pointer_item_t;
#define BI_CASE 0x00000001
#define BI_BITMAP32 0x00000200
#define BI_SWITCH_TYPE 0x00000400
typedef struct _bracket_item_t {
- long int flags;
- char *case_name;
+ unsigned int flags;
+ const char *case_name;
pointer_item_t *pointer_list;
int union_tag_size;
} bracket_item_t;
struct _no_emit_item_t *next;
char *name;
} no_emit_item_t;
-no_emit_item_t *no_emit_list=NULL;
+static no_emit_item_t *no_emit_list=NULL;
typedef struct _hf_rename_item_t {
struct _hf_rename_item_t *next;
char *old_name;
char *new_name;
} hf_rename_item_t;
-hf_rename_item_t *hf_rename_list=NULL;
+static hf_rename_item_t *hf_rename_list=NULL;
typedef struct _enum_list_t {
struct _enum_list_t *next;
int val;
} enum_list_t;
-
typedef struct _token_item_t {
struct _token_item_t *next;
char *str;
} token_item_t;
-token_item_t *token_list=NULL;
-token_item_t *last_token_item=NULL;
-
+static token_item_t *token_list=NULL;
+static token_item_t *last_token_item=NULL;
typedef struct _type_item_t {
struct _type_item_t *next;
char *vals;
int alignment;
} type_item_t;
-type_item_t *type_list=NULL;
+static type_item_t *type_list=NULL;
typedef struct _union_tag_size_item_t {
struct _union_tag_size_item_t *next;
char *name;
int size;
} union_tag_size_item_t;
-union_tag_size_item_t *union_tag_size_list=NULL;
+static union_tag_size_item_t *union_tag_size_list=NULL;
typedef struct _hf_field_item_t {
struct _hf_field_item_t *next;
char *name;
char *ft_type;
} hf_field_item_t;
-hf_field_item_t *hf_field_list=NULL;
+static hf_field_item_t *hf_field_list=NULL;
typedef struct _dissector_param_value_t {
struct _dissector_param_value_t *next;
char *name;
char *value;
} dissector_param_value_t;
-dissector_param_value_t *dissector_param_list=NULL;
+static dissector_param_value_t *dissector_param_list=NULL;
static type_item_t *find_type(char *name);
+static int Exit(int code);
-void
+static void
register_dissector_param_value(char *name, char *value)
{
dissector_param_value_t *dpv;
- dpv=malloc(sizeof(dissector_param_value_t));
+ dpv=(dissector_param_value_t*)malloc(sizeof(dissector_param_value_t));
dpv->next=dissector_param_list;
dissector_param_list=dpv;
dpv->name=strdup(name);
dpv->value=strdup(value);
}
-char *
+static const char *
find_dissector_param_value(char *name)
{
dissector_param_value_t *dpv;
return "0";
}
-pointer_item_t *
+static pointer_item_t *
prepend_pointer_list(pointer_item_t *ptrs, int num_pointers)
{
pointer_item_t *pi;
}
if(!pi)pi=ptrs;
while(num_pointers--){
- pi=malloc(sizeof(pointer_item_t));
+ pi=(pointer_item_t*)malloc(sizeof(pointer_item_t));
pi->next=ptrs;
pi->type=pointer_default;
ptrs=pi;
return ptrs;
}
-char *
-ptr_to_define(char *pointer_type)
+static const char *
+ptr_to_define(const char *pointer_type)
{
if(!strcmp(pointer_type, "unique")){
return "NDR_POINTER_UNIQUE";
return "NDR_POINTER_PTR";
}
- fprintf(stderr, "prt_to_define, weirdo pointer :%s\n", pointer_type);
+ fprintf(stderr, "prt_to_define, weirdo pointer :%s\n", pointer_type);
exit(10);
}
-int
+static int
get_union_tag_size(char *name)
{
union_tag_size_item_t *utsi;
}
}
fprintf(stderr, "ERROR: size of tag for union:%s is not known\n", name);
- fprintf(stderr, " use the UNION_TAG_SIZE directive to specify it in teh conformance file\n", name);
+ fprintf(stderr, " use the UNION_TAG_SIZE directive to specify it in teh conformance file\n");
exit(10);
}
/* this function will add an entry to the hf_rename list */
-void
+static void
register_hf_rename(char *old_name, char *new_name)
{
hf_rename_item_t *new_item;
- new_item=malloc(sizeof(hf_rename_item_t));
+ new_item=(hf_rename_item_t*)malloc(sizeof(hf_rename_item_t));
new_item->next=hf_rename_list;
hf_rename_list=new_item;
new_item->refcount=0;
}
/* this function checks that all hf_rename fields have actually been referenced
- if not out conformance file is stale
+ if not out conformance file is stale
*/
-void
+static void
check_hf_rename_refcount(void)
{
hf_rename_item_t *hri;
}
}
-hf_field_item_t *
+static hf_field_item_t *
find_hf_field(char *name)
{
hf_field_item_t *hfi;
for(hfi=hf_field_list;hfi;hfi=hfi->next){
if(!strcmp(hfi->name, name)){
- return hfi;
+ break;
}
}
- fprintf(stderr, "find_hf_field: unknown hf_field:%s\n",name);
- Exit(10);
+ if (!hfi) {
+ fprintf(stderr, "find_hf_field: unknown hf_field:%s\n",name);
+ Exit(10);
+ }
+
+ return hfi;
}
from this function.
for fields that are to be renamed no code is generated
*/
-char *
-register_hf_field(char *hf_name, char *title, char *filter_name, char *ft_type, char *base_type, char *valsstring, char *mask, char *blurb)
+static const char *
+register_hf_field(const char *hf_name, const char *title, const char *filter_name, const char *ft_type, const char *base_type, const char *valsstring, const char *mask, const char *blurb)
{
hf_field_item_t *hfi;
hf_rename_item_t *hri;
}
}
- hfi=malloc(sizeof(hf_field_item_t));
+ hfi=(hf_field_item_t*)malloc(sizeof(hf_field_item_t));
hfi->next=hf_field_list;
hf_field_list=hfi;
hfi->name=strdup(hf_name);
hfi->ft_type=strdup(ft_type);
FPRINTF(eth_hf, "static int %s = -1;\n", hf_name);
- FPRINTF(eth_hfarr, " { &%s,\n", hf_name);
- FPRINTF(eth_hfarr, " { \"%s\", \"%s\", %s, %s,\n", title, filter_name, ft_type, base_type);
- FPRINTF(eth_hfarr, " %s, %s,\n", valsstring, mask);
+ FPRINTF(eth_hfarr, " { &%s,\n", hf_name);
+ FPRINTF(eth_hfarr, " { \"%s\", \"%s\", %s, %s,\n", title, filter_name, ft_type, base_type);
+ FPRINTF(eth_hfarr, " %s, %s,\n", valsstring, mask);
if (strlen(blurb) > 0)
- FPRINTF(eth_hfarr, " \"%s\", HFILL }},\n", blurb);
+ FPRINTF(eth_hfarr, " \"%s\", HFILL }},\n", blurb);
else
- FPRINTF(eth_hfarr, " NULL, HFILL }},\n");
+ FPRINTF(eth_hfarr, " NULL, HFILL }},\n");
FPRINTF(eth_hfarr, "\n");
return hf_name;
}
-/* this function will parse the no emit list and decide whether code should
+/* this function will parse the no emit list and decide whether code should
be generated for this dissector or if we should only register the type.
*/
-int
+static int
check_if_to_emit(char *name)
{
no_emit_item_t *nel;
return 1;
}
-
-void
+#if 0
+static void
prune_keywords(char *name)
{
- token_item_t *ti, *prevti;
+ token_item_t *ti;
for(ti=token_list;ti;ti=ti->next){
if(!ti->next){
}
}
}
-void
-rename_tokens(char *old_name, char *new_name)
+#endif
+
+static void
+rename_tokens(const char *old_name, const char *new_name)
{
token_item_t *ti;
}
}
-void
-prune_keyword_parameters(char *name)
+static void
+prune_keyword_parameters(const char *name)
{
token_item_t *ti, *tmpti;
}
/* this function will parse a bracket item
- [ ... ]
+ [ ... ]
it will return the token of the next item following the ']'
*/
-token_item_t *
+static token_item_t *
parsebrackets(token_item_t *ti, bracket_item_t **bracket){
bracket_item_t *br;
type_item_t *type_item;
}
ti=ti->next;
- br=malloc(sizeof(bracket_item_t));
+ br=(bracket_item_t*)malloc(sizeof(bracket_item_t));
*bracket=br;
br->flags=0;
br->case_name=NULL;
pointer_item_t *newpi;
br->flags|=BI_POINTER;
- newpi=malloc(sizeof(pointer_item_t));
+ newpi=(pointer_item_t*)malloc(sizeof(pointer_item_t));
newpi->next=NULL;
newpi->type=ti->str;
newpi->next=br->pointer_list;
fprintf(stderr, "ERROR: parsebrackets should not be reached unknown tag:%s\n", ti->str);
Exit(10);
}
+
+ return NULL;
}
-
+
/* this function will register a new type learnt from the IDL file
*/
-static type_item_t *
-register_new_type(char *name, char *dissectorname, char *ft_type, char *base_type, char *mask, char *valsstring, int alignment){
+static type_item_t *
+register_new_type(const char *name, const char *dissectorname, const char *ft_type, const char *base_type, const char *mask, const char *valsstring, int alignment){
type_item_t *new_type;
FPRINTF(NULL,"XXX new type:%s dissector:%s Type:%s Base:%s Mask:%s Vals:%s alignment:%d\n", name, dissectorname, ft_type, base_type, mask, valsstring, alignment);
- new_type=malloc(sizeof(type_item_t));
+ new_type=(type_item_t*)malloc(sizeof(type_item_t));
new_type->next=type_list;
new_type->name=strdup(name);
new_type->dissector=strdup(dissectorname);
/* this function will print the remaining content of the token list
*/
-void printtokenlist(int count)
+static void printtokenlist(int count)
{
token_item_t *ti;
fprintf(stderr, "TOKENLIST:\n");
fprintf(stderr, "Token \"%s\"\n",ti->str);
}
if(!count){
- fprintf(stderr, " ...\n");
+ fprintf(stderr, " ...\n");
}
}
* [ <fields> ] inteface <ifname> {
*
* we are interested in the fields:
- * uuid
- * version
- * pointer_default
+ * uuid
+ * version
+ * pointer_default
*
* this function will also remove the header from the token list
*/
-void parseheader(void)
+static void parseheader(void)
{
char filter_name[256];
token_item_t *ti;
ti=token_list;
if(!ti){
- fprintf(stderr, "ERRO: no tokens\n");
+ fprintf(stderr, "ERROR: no tokens\n");
Exit(10);
}
register_hf_field(hf_status, "Return code", filter_name, "FT_UINT32", "BASE_HEX", "VALS(NT_errors)", "0", "");
FPRINTF(eth_ett, "static gint ett_%s = -1;\n", ifname);
- FPRINTF(eth_ettarr, " &ett_%s,\n", ifname);
+ FPRINTF(eth_ettarr, " &ett_%s,\n", ifname);
/* the body must start with { */
if(strcmp(token_list->str, "{")){
Exit(10);
}
FPRINTF(eth_code,"static e_uuid_t uuid_dcerpc_%s = {\n", ifname);
- FPRINTF(eth_code," 0x%c%c%c%c%c%c%c%c, 0x%c%c%c%c, 0x%c%c%c%c,\n",uuid[1],uuid[2],uuid[3],uuid[4],uuid[5],uuid[6],uuid[7],uuid[8],uuid[10],uuid[11],uuid[12],uuid[13],uuid[15],uuid[16],uuid[17],uuid[18]);
- FPRINTF(eth_code," { 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c}\n",uuid[20],uuid[21],uuid[22],uuid[23],uuid[25],uuid[26],uuid[27],uuid[28],uuid[29],uuid[30],uuid[31],uuid[32],uuid[33],uuid[34],uuid[35],uuid[36]);
+ FPRINTF(eth_code," 0x%c%c%c%c%c%c%c%c, 0x%c%c%c%c, 0x%c%c%c%c,\n",uuid[1],uuid[2],uuid[3],uuid[4],uuid[5],uuid[6],uuid[7],uuid[8],uuid[10],uuid[11],uuid[12],uuid[13],uuid[15],uuid[16],uuid[17],uuid[18]);
+ FPRINTF(eth_code," { 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c, 0x%c%c}\n",uuid[20],uuid[21],uuid[22],uuid[23],uuid[25],uuid[26],uuid[27],uuid[28],uuid[29],uuid[30],uuid[31],uuid[32],uuid[33],uuid[34],uuid[35],uuid[36]);
FPRINTF(eth_code,"};\n");
FPRINTF(eth_code,"\n");
FPRINTF(eth_code,"static guint16 ver_%s = %d;\n", ifname, major);
FPRINTF(eth_code,"\n");
- FPRINTF(eth_handoff, " dcerpc_init_uuid(proto_%s, ett_%s,\n", ifname, ifname);
- FPRINTF(eth_handoff, " &uuid_dcerpc_%s, ver_%s,\n", ifname, ifname);
- FPRINTF(eth_handoff, " function_dissectors, hf_%s_opnum);\n", ifname);
+ FPRINTF(eth_handoff, " dcerpc_init_uuid(proto_%s, ett_%s,\n", ifname, ifname);
+ FPRINTF(eth_handoff, " &uuid_dcerpc_%s, ver_%s,\n", ifname, ifname);
+ FPRINTF(eth_handoff, " function_dissectors, hf_%s_opnum);\n", ifname);
}
-/* this helper function is called by the tokenizer and will just append the
+/* this helper function is called by the tokenizer and will just append the
current token to the linked list
*/
-void pushtoken(char *token)
+static void pushtoken(char *token)
{
token_item_t *new_token_item;
- new_token_item=malloc(sizeof(token_item_t));
+ new_token_item=(token_item_t*)malloc(sizeof(token_item_t));
new_token_item->next=NULL;
new_token_item->str=token;
if(!token_list){
/* this function reads the idl file and translates it into tokens.
the tokens are stored in a linked list token_list of type token_item_t
*/
-void tokenize(void)
+static void tokenize(FILE *fh)
{
int ch;
int fullinecomment=0;
int normalcomment=0;
int insidequote=0;
char qs[1024];
- int qspos;
+ int qspos=0;
int insidetoken=0;
char token[1024];
- int tokenpos;
+ int tokenpos=0;
while(!feof(fh)){
ch=fgetc(fh);
if(nextch=='*'){
normalcomment=1;
continue;
- }
+ }
ungetc(nextch, fh);
}
} else {
if(nextch=='/'){
normalcomment=0;
continue;
- }
+ }
ungetc(nextch, fh);
}
continue;
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("int32", dissectorname, "FT_INT32", "BASE_DEC", "0", "NULL", 4);
- tmptype=register_new_type("long", dissectorname, "FT_INT32", "BASE_DEC", "0", "NULL", 4);
+ if (!strcmp(name,"int32"))
+ tmptype=register_new_type("int32", dissectorname, "FT_INT32", "BASE_DEC", "0", "NULL", 4);
+ else
+ tmptype=register_new_type("long", dissectorname, "FT_INT32", "BASE_DEC", "0", "NULL", 4);
} else if( (!strcmp(name,"uint8")) ){
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("int8", dissectorname, "FT_INT8", "BASE_DEC", "0", "NULL", 1);
- tmptype=register_new_type("char", dissectorname, "FT_INT8", "BASE_DEC", "0", "NULL", 1);
+ if (!strcmp(name,"int8"))
+ tmptype=register_new_type("int8", dissectorname, "FT_INT8", "BASE_DEC", "0", "NULL", 1);
+ else
+ tmptype=register_new_type("char", dissectorname, "FT_INT8", "BASE_DEC", "0", "NULL", 1);
} else if(!strcmp(name,"bool8")){
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_cvstring(tvb, offset, pinfo, tree, drep, 2, hf_index, FALSE, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_cvstring(tvb, offset, pinfo, tree, di, drep, 2, hf_index, FALSE, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_cvstring(tvb, offset, pinfo, tree, drep, 1, hf_index, FALSE, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_cvstring(tvb, offset, pinfo, tree, di, drep, 1, hf_index, FALSE, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uuid_t(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static proto_item *hnd_item;\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset = dissect_nt_policy_hnd(tvb, offset, pinfo, tree, drep,\n");
- FPRINTF(eth_code, " hf_index, &policy_hnd, &hnd_item,\n");
- FPRINTF(eth_code, " param&0x01, param&0x02);\n");
+ FPRINTF(eth_code, " offset = dissect_nt_policy_hnd(tvb, offset, pinfo, tree, di, drep,\n");
+ FPRINTF(eth_code, " hf_index, &policy_hnd, &hnd_item,\n");
+ FPRINTF(eth_code, " param&0x01, param&0x02);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, hf_index);\n");
+ FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, hf_index);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("NTTIME", dissectorname, "FT_ABSOLUTE_TIME", "BASE_NONE", "0", "NULL", 4);
+ tmptype=register_new_type("NTTIME", dissectorname, "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", "0", "NULL", 4);
} else if(!strcmp(name,"NTTIME_hyper")){
/* 8 bytes, aligned to 8 bytes */
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " ALIGN_TO_8_BYTES;\n");
- FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, hf_index);\n");
+ FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, hf_index);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("NTTIME_hyper", dissectorname, "FT_ABSOLUTE_TIME", "BASE_NONE", "0", "NULL", 4);
+ tmptype=register_new_type("NTTIME_hyper", dissectorname, "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", "0", "NULL", 4);
} else if(!strcmp(name,"NTTIME_1sec")){
/* 8 bytes, aligned to 8 bytes */
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " ALIGN_TO_8_BYTES;\n");
- FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, hf_index);\n");
+ FPRINTF(eth_code, " offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, hf_index);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("NTTIME_1sec", dissectorname, "FT_ABSOLUTE_TIME", "BASE_NONE", "0", "NULL", 4);
+ tmptype=register_new_type("NTTIME_1sec", dissectorname, "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", "0", "NULL", 4);
} else if(!strcmp(name,"udlong")){
/* 8 bytes, aligned to 4 bytes */
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, "\n");
- FPRINTF(eth_code, " offset=dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_duint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, "\n");
- FPRINTF(eth_code, " offset=dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_duint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " \n");
FPRINTF(eth_code, " ALIGN_TO_8_BYTES;\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint64(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint64(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " \n");
- FPRINTF(eth_code, " offset=dissect_ndr_time_t(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_time_t(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
- tmptype=register_new_type("time_t", dissectorname, "FT_ABSOLUTE_TIME", "BASE_NONE", "0", "NULL", 4);
+ tmptype=register_new_type("time_t", dissectorname, "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", "0", "NULL", 4);
} else if(!strcmp(name,"SID")){
sprintf(dissectorname, "%s_dissect_%s", ifname, name);
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param)\n", dissectorname);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " dcerpc_info *di = (dcerpc_info *)pinfo->private_data;\n");
- FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " di->hf_index=hf_index;\n");
- FPRINTF(eth_code, " offset=dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, drep, param);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, di, drep, param);\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
FPRINTF(NULL,"\nAutogenerating built-in type:%s\n------------\n",name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " \n");
- FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
/* this function will skip past an entire declare ... ; statement */
-void skipdeclare(void)
+static void skipdeclare(void)
{
token_item_t *ti;
}
/* this function will parse a
- const
+ const
and generate the appropriate code
const must be followed by a suitable keyword [uint16|uint32|...]
the const will later be removed from the token list
the function assumes that the const is the first object in the token_list
*/
-void parseconst(void)
+static void parseconst(void)
{
token_item_t *ti;
- type_item_t *type_item;
char *name, *value;
/* first must be the keyword const */
}
ti=ti->next;
- /* just skip second token */
+ /* just skip second token */
ti=ti->next;
/* third is a variable and not a type */
}
name=ti->str;
ti=ti->next;
-
+
/* fourth is '=' */
if(strcmp(ti->str, "=")){
fprintf(stderr, "ERROR: const fourth token is not '='\n");
}
/* this function will parse a
- typedef struct {
+ typedef struct {
construct and generate the appropriate code.
the typedef will be removed from the token_list once it has been processed
the function assumes that the typedef is the first object in the token_list
the function will be called twice, once with pass=0 and once with pass=1
- which controls whether subdissectors are to be generated or whether the
- struct dissector itself is to be generated
+ which controls whether subdissectors are to be generated or whether the
+ struct dissector itself is to be generated
*/
-void parsetypedefstruct(int pass)
+static void parsetypedefstruct(int pass)
{
token_item_t *ti, *tmpti;
char *struct_name;
char hf_index[256];
bracket_item_t *bi=NULL;
pointer_item_t *pi;
- char *pointer_type;
+ const char *pointer_type;
char *field_name;
int fixed_array_size;
int is_array_of_pointers;
continue;
}
}
+ if(!tmpti || !tmpti->next){
+ fprintf(stderr, "ERROR: typedefstruct missing matching '}'\n");
+ Exit(10);
+ }
+
struct_name=tmpti->next->str;
sprintf(dissectorname, "%s_dissect_%s", ifname, struct_name);
/* pass 1 generate header for the struct dissector */
if(pass==1){
FPRINTF(eth_ett, "static gint ett_%s_%s = -1;\n", ifname, struct_name);
- FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, struct_name);
- FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
+ FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, struct_name);
+ FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " proto_item *item=NULL;\n");
FPRINTF(eth_code, " proto_tree *tree=NULL;\n");
}
FPRINTF(eth_code, " old_offset=offset;\n");
FPRINTF(eth_code, " if(parent_tree){\n");
- FPRINTF(eth_code, " item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, TRUE);\n");
- FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, struct_name);
+ FPRINTF(eth_code, " item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, ENC_NA);\n");
+ FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, struct_name);
FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, "\n");
}
Exit(10);
}
}
-
+
/* handle the type, verify that we KNOW this type */
type_item=find_type(ti->str);
if(!type_item){
/* pass 0 generate subdissectors */
if(pass==0){
char filter_name[256];
- char *hf;
+ const char *hf;
sprintf(tmpstr, "%s_dissect_%s_%s", ifname, struct_name, field_name);
ptmpstr=strdup(tmpstr);
sprintf(filter_name, "%s.%s.%s", ifname, struct_name, field_name);
hf=register_hf_field(hf_index, field_name, filter_name, type_item->ft_type, type_item->base_type, type_item->vals, type_item->mask, "");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", ptmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", ptmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " guint32 param=%s;\n",find_dissector_param_value(ptmpstr));
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep, %s, param);\n", type_item->dissector, hf);
- FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, " guint32 param=%s;\n",find_dissector_param_value(ptmpstr));
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep, %s, param);\n", type_item->dissector, hf);
+ FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
} else {
sprintf(tmpstr, "%s_%s", pointer_type, ptmpstr);
if(check_if_to_emit(tmpstr)){
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), field_name);
- FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, di, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), field_name);
+ FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
} else {
FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
}
-
+
ptmpstr=strdup(tmpstr);
} else if(fixed_array_size){
sprintf(tmpstr, "fixedarray_%s", ptmpstr);
if(check_if_to_emit(tmpstr)){
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " int count=%d;\n",fixed_array_size);
- FPRINTF(eth_code, " while(count--){\n");
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
- FPRINTF(eth_code, " }\n");
+ FPRINTF(eth_code, " int count=%d;\n",fixed_array_size);
+ FPRINTF(eth_code, " while(count--){\n");
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep);\n", ptmpstr);
+ FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, "\n");
- FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
} else {
if(bi){
switch(bi->flags&(BI_SIZE_IS|BI_LENGTH_IS)){
case 0:
- break;
+ break;
case BI_SIZE_IS:
- sprintf(tmpstr, "ucarray_%s", ptmpstr);
- if(check_if_to_emit(tmpstr)){
- FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
- FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep, %s);\n", ptmpstr);
- FPRINTF(eth_code, " return offset;\n");
- FPRINTF(eth_code, "}\n");
- FPRINTF(eth_code, "\n");
- } else {
- FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
- }
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucarray_%s", ptmpstr);
+ if(check_if_to_emit(tmpstr)){
+ FPRINTF(eth_code, "static int\n");
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "{\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_ucarray(tvb, offset, pinfo, tree, di, drep, %s);\n", ptmpstr);
+ FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, "}\n");
+ FPRINTF(eth_code, "\n");
+ } else {
+ FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
+ }
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_LENGTH_IS:
- sprintf(tmpstr, "uvarray_%s", ptmpstr);
- if(check_if_to_emit(tmpstr)){
- FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
- FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_uvarray(tvb, offset, pinfo, tree, drep, %s);\n", ptmpstr);
- FPRINTF(eth_code, " return offset;\n");
- FPRINTF(eth_code, "}\n");
- FPRINTF(eth_code, "\n");
- } else {
- FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
- }
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "uvarray_%s", ptmpstr);
+ if(check_if_to_emit(tmpstr)){
+ FPRINTF(eth_code, "static int\n");
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "{\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uvarray(tvb, offset, pinfo, tree, di, drep, %s);\n", ptmpstr);
+ FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, "}\n");
+ FPRINTF(eth_code, "\n");
+ } else {
+ FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
+ }
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_SIZE_IS|BI_LENGTH_IS:
- sprintf(tmpstr, "ucvarray_%s", ptmpstr);
- if(check_if_to_emit(tmpstr)){
- FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
- FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep, %s);\n", ptmpstr);
- FPRINTF(eth_code, " return offset;\n");
- FPRINTF(eth_code, "}\n");
- FPRINTF(eth_code, "\n");
- } else {
- FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
- }
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucvarray_%s", ptmpstr);
+ if(check_if_to_emit(tmpstr)){
+ FPRINTF(eth_code, "static int\n");
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "{\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_ucvarray(tvb, offset, pinfo, tree, di, drep, %s);\n", ptmpstr);
+ FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, "}\n");
+ FPRINTF(eth_code, "\n");
+ } else {
+ FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
+ }
+ ptmpstr=strdup(tmpstr);
+ break;
default:
- fprintf(stderr, "ERROR: typedefstruct can not handle this combination of sizeis/lengthis\n");
- Exit(10);
+ fprintf(stderr, "ERROR: typedefstruct can not handle this combination of sizeis/lengthis\n");
+ Exit(10);
}
}
sprintf(tmpstr, "%s_%s", pointer_type, ptmpstr);
if(check_if_to_emit(tmpstr)){
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), field_name);
- FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, di, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), field_name);
+ FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
} else {
FPRINTF(NULL,"NOEMIT Skipping this struct item :%s\n",tmpstr);
}
-
+
ptmpstr=strdup(tmpstr);
}
}
if(bi){
switch(bi->flags&(BI_SIZE_IS|BI_LENGTH_IS)){
case 0:
- break;
+ break;
case BI_SIZE_IS:
- sprintf(tmpstr, "ucarray_%s", ptmpstr);
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucarray_%s", ptmpstr);
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_LENGTH_IS:
- sprintf(tmpstr, "uvarray_%s", ptmpstr);
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "uvarray_%s", ptmpstr);
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_SIZE_IS|BI_LENGTH_IS:
- sprintf(tmpstr, "ucvarray_%s", ptmpstr);
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucvarray_%s", ptmpstr);
+ ptmpstr=strdup(tmpstr);
+ break;
default:
- fprintf(stderr, "ERROR: typedefstruct can not handle this combination of sizeis/lengthis\n");
- Exit(10);
+ fprintf(stderr, "ERROR: typedefstruct can not handle this combination of sizeis/lengthis\n");
+ Exit(10);
}
}
sprintf(tmpstr, "%s_%s", pointer_type, ptmpstr);
ptmpstr=strdup(tmpstr);
}
-
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
+
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep);\n", ptmpstr);
FPRINTF(eth_code, "\n");
}
typedef_struct_finished:
FPRINTF(NULL,"\nEND STRUCT:%s pass:%d\n-------\n",struct_name,pass);
-
+
/* only advance token_list for pass==1
ti now points to the '}' token
*/
if(pass==1){
- if(strcmp(ti->str,"}")){
+ if(!ti || strcmp(ti->str,"}")){
fprintf(stderr, "ERROR: struct does not end with '}'\n");
Exit(10);
}
/* just skip the name */
ti=ti->next;
- if(strcmp(ti->str,";")){
+ if(!ti || strcmp(ti->str,";")){
fprintf(stderr, "ERROR: struct does not end with ';'\n");
Exit(10);
}
ti=ti->next;
-
+
token_list=ti;
}
}
/* this function will parse a
- typedef bitmap {
+ typedef bitmap {
construct and generate the appropriate code.
the typedef will be removed from the token_list once it has been processed
the function assumes that the typedef is the first object in the token_list
the function will be called twice, once with pass=0 and once with pass=1
- which controls whether subdissectors are to be generated or whether the
- bitmap dissector itself is to be generated
+ which controls whether subdissectors are to be generated or whether the
+ bitmap dissector itself is to be generated
bitmaps are by default 32 bits
*/
-void parsetypedefbitmap(int pass)
+static void parsetypedefbitmap(int pass)
{
token_item_t *ti, *tmpti;
char *bitmap_name;
char dissectorname[256], hf_bitname[256];
- int alignment, val;
+ int alignment;
+ unsigned int val;
char *name, *value;
bracket_item_t *bi=NULL;
- char tmpstr[256], *ptmpstr;
- type_item_t *type_item;
- char hf_index[256];
-
ti=token_list;
if(strcmp(ti->str, "typedef")){
fprintf(stderr, "ERROR: typedefbitmap first token is not 'typedef'\n");
ti=ti->next;
alignment=4; /* default size is 32 bits */
-
+
if(!strcmp(ti->str, "[")){
ti=parsebrackets(ti, &bi);
}
alignment=1;
}
}
-
+
if(strcmp(ti->str, "bitmap")){
fprintf(stderr, "ERROR: typedefbitmap second token is not 'bitmap'\n");
break;
}
}
+ if (!tmpti || !tmpti->next){
+ fprintf(stderr, "ERROR: typedefbitmap missing matching '}'\n");
+ Exit(10);
+ }
bitmap_name=tmpti->next->str;
sprintf(dissectorname, "%s_dissect_%s", ifname, bitmap_name);
/* pass 1 generate header for the struct dissector */
if(pass==1){
FPRINTF(eth_ett, "static gint ett_%s_%s = -1;\n", ifname, bitmap_name);
- FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, bitmap_name);
- FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
+ FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, bitmap_name);
+ FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " proto_item *item=NULL;\n");
FPRINTF(eth_code, " proto_tree *tree=NULL;\n");
}
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " if(parent_tree){\n");
- FPRINTF(eth_code, " item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, %d, TRUE);\n", alignment);
- FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, bitmap_name);
+ FPRINTF(eth_code, " item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, %d, ENC_LITTLE_ENDIAN);\n", alignment);
+ FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, bitmap_name);
FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, "\n");
switch(alignment){
case 1:
- FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, NULL, drep, -1, &flags);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint8(tvb, offset, pinfo, NULL, di, drep, -1, &flags);\n");
FPRINTF(eth_code, "\n");
break;
case 4:
- FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, NULL, drep, -1, &flags);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, NULL, di, drep, -1, &flags);\n");
FPRINTF(eth_code, "\n");
break;
default:
value=ti->str;
ti=ti->next;
+ val=0;
if(!strncmp(value, "0x", 2)){
sscanf(value, "0x%x", &val);
} else {
if(pass==0){
char filter_name[256], base_name[256], tfs_name[256];
- char *hf;
+
sprintf(filter_name, "%s.%s.%s", ifname, bitmap_name, name);
sprintf(base_name, "%d", alignment*8);
sprintf(tfs_name, "TFS(&%s_tfs)", name);
- hf=register_hf_field(hf_bitname, name, filter_name, "FT_BOOLEAN", base_name, tfs_name, value, "");
+ register_hf_field(hf_bitname, name, filter_name, "FT_BOOLEAN", base_name, tfs_name, value, "");
FPRINTF(eth_code, "static const true_false_string %s_tfs = {\n",name);
FPRINTF(eth_code, " \"%s is SET\",\n", name);
if(pass==1){
FPRINTF(eth_code, " proto_tree_add_boolean(tree, %s, tvb, offset-%d, %d, flags);\n", hf_bitname, alignment, alignment);
FPRINTF(eth_code, " if(flags&%s){\n", value);
- FPRINTF(eth_code, " proto_item_append_text(item, \" %s\");\n", name);
+ FPRINTF(eth_code, " proto_item_append_text(item, \" %s\");\n", name);
FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, " flags&=(~%s);\n", value);
FPRINTF(eth_code, "\n");
if(pass==1){
FPRINTF(eth_code, " if(flags){\n");
- FPRINTF(eth_code, " proto_item_append_text(item, \"UNKNOWN-FLAGS\");\n");
+ FPRINTF(eth_code, " proto_item_append_text(item, \"UNKNOWN-FLAGS\");\n");
FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " return offset;\n");
}
FPRINTF(NULL,"\nEND BITMAP:%s pass:%d\n-------\n",bitmap_name,pass);
-
+
/* only advance token_list for pass==1
ti now points to the '}' token
*/
if(pass==1){
- if(strcmp(ti->str,"}")){
+ if(!ti || strcmp(ti->str,"}")){
fprintf(stderr, "ERROR: bitmap does not end with '}'\n");
Exit(10);
}
/* just skip the name */
ti=ti->next;
- if(strcmp(ti->str,";")){
+ if(!ti || strcmp(ti->str,";")){
fprintf(stderr, "ERROR: bitmap does not end with ';'\n");
Exit(10);
}
ti=ti->next;
-
+
token_list=ti;
}
}
/* a case tag might be a negative number, i.e. contain a '-' sign which
is not valid inside a symbol name in c.
*/
-char *
-case2str(char *str)
+static const char *
+case2str(const char *str)
{
char *newstr;
if(str[0]!='-'){
- return str;
+ return str;
}
newstr=strdup(str);
newstr[0]='m';
}
/* this function will parse a
- typedef union {
+ typedef union {
construct and generate the appropriate code.
the typedef will be removed from the token_list once it has been processed
the function assumes that the typedef is the first object in the token_list
the function will be called twice, once with pass=0 and once with pass=1
- which controls whether subdissectors are to be generated or whether the
- union dissector itself is to be generated
+ which controls whether subdissectors are to be generated or whether the
+ union dissector itself is to be generated
*/
-void parsetypedefunion(int pass)
+static void parsetypedefunion(int pass)
{
char *union_name;
token_item_t *ti, *tmpti;
continue;
}
}
+
+ if (!tmpti || !tmpti->next){
+ fprintf(stderr, "ERROR: typedefunion missing matching '}'\n");
+ Exit(10);
+ }
union_name=tmpti->next->str;
sprintf(dissectorname, "%s_dissect_union_%s", ifname, union_name);
}
/* this is pass 0 so reset alignment to the minimum possible value
- and update as items are processed.
- we need alignment when pass 1 is run
+ and update as items are processed.
+ we need alignment when pass 1 is run
*/
if(pass==0){
alignment=tag_alignment;
/* pass 1 generate header for the struct dissector */
if(pass==1){
FPRINTF(eth_ett, "static gint ett_%s_%s = -1;\n", ifname, union_name);
- FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, union_name);
+ FPRINTF(eth_ettarr, " &ett_%s_%s,\n", ifname, union_name);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " proto_item *item=NULL;\n");
FPRINTF(eth_code, " proto_tree *tree=NULL;\n");
FPRINTF(eth_code, "\n");
break;
case 4:
- FPRINTF(eth_code, " guint32 level;\n");
+ FPRINTF(eth_code, " guint32 level = 0;\n");
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, " ALIGN_TO_4_BYTES;\n");
FPRINTF(eth_code, "\n");
}
FPRINTF(eth_code, " old_offset=offset;\n");
FPRINTF(eth_code, " if(parent_tree){\n");
- FPRINTF(eth_code, " item=proto_tree_add_text(parent_tree, tvb, offset, -1, \"%s\");\n", union_name);
- FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, union_name);
+ FPRINTF(eth_code, " item=proto_tree_add_text(parent_tree, tvb, offset, -1, \"%s\");\n", union_name);
+ FPRINTF(eth_code, " tree=proto_item_add_subtree(item, ett_%s_%s);\n", ifname, union_name);
FPRINTF(eth_code, " }\n");
FPRINTF(eth_code, "\n");
switch(tag_alignment){
break;
case 2:
FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree,\n");
- FPRINTF(eth_code, " drep, hf_index, &level);\n");
+ FPRINTF(eth_code, " di, drep, hf_index, &level);\n");
break;
case 4:
FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree,\n");
- FPRINTF(eth_code, " drep, hf_index, &level);\n");
+ FPRINTF(eth_code, " di, drep, hf_index, &level);\n");
break;
default:
fprintf(stderr, "ERROR: typedefunion 2 can not handle alignment:%d\n",alignment);
/* pass 0 generate subdissectors */
if(pass==0){
char filter_name[256];
- char *hf;
+ const char *hf;
+
sprintf(tmpstr, "%s_dissect_union_%s_%s_%s", ifname, union_name, case2str(bi->case_name), ti->str);
ptmpstr=strdup(tmpstr);
sprintf(filter_name, "%s.%s.%s", ifname, union_name, ti->str);
hf=register_hf_field(hf_index, ti->str, filter_name, type_item->ft_type, type_item->base_type, type_item->vals, type_item->mask, "");
-
+
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", ptmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", ptmpstr);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " guint32 param=%s;\n",find_dissector_param_value(ptmpstr));
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep, %s, param);\n", type_item->dissector, hf);
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep, %s, param);\n", type_item->dissector, hf);
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
while(num_pointers--){
sprintf(tmpstr, "%s_%s", ptmpstr, "unique");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, drep, %s, NDR_POINTER_UNIQUE, \"%s\", -1);\n", ptmpstr, ti->str);
+ FPRINTF(eth_code, " offset=dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, di, drep, %s, NDR_POINTER_UNIQUE, \"%s\", -1);\n", ptmpstr, ti->str);
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
-
+
ptmpstr=strdup(tmpstr);
-
+
}
}
sprintf(tmpstr, "%s_%s", ptmpstr, "unique");
ptmpstr=strdup(tmpstr);
}
-
+
if(bi->flags&BI_CASE_DEFAULT){
FPRINTF(eth_code, " default:\n");
} else {
case 1:
break;
case 2:
- FPRINTF(eth_code, " ALIGN_TO_2_BYTES;\n");
+ FPRINTF(eth_code, " ALIGN_TO_2_BYTES;\n");
break;
case 4:
- FPRINTF(eth_code, " ALIGN_TO_4_BYTES;\n");
+ FPRINTF(eth_code, " ALIGN_TO_4_BYTES;\n");
break;
case 8:
- FPRINTF(eth_code, " ALIGN_TO_8_BYTES;\n");
+ FPRINTF(eth_code, " ALIGN_TO_8_BYTES;\n");
break;
default:
fprintf(stderr, "ERROR: typedefunion 3 can not handle alignment:%d\n",item_alignment);
Exit(10);
}
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
- FPRINTF(eth_code, " break;\n");
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep);\n", ptmpstr);
+ FPRINTF(eth_code, " break;\n");
FPRINTF(eth_code, "\n");
}
ti=ti->next;
}
FPRINTF(NULL,"\nEND UNION:%s pass:%d\n-------\n",union_name,pass);
-
+
/* only advance token_list for pass==1
ti now points to the '}' token
*/
if(pass==1){
- if(strcmp(ti->str,"}")){
+ if(!ti || strcmp(ti->str,"}")){
fprintf(stderr, "ERROR: union does not end with '}'\n");
Exit(10);
}
/* just skip the name */
ti=ti->next;
- if(strcmp(ti->str,";")){
+ if(!ti || strcmp(ti->str,";")){
fprintf(stderr, "ERROR: union does not end with ';'\n");
Exit(10);
}
ti=ti->next;
-
+
token_list=ti;
}
}
/* this function will parse a
- WERROR function (
+ WERROR function (
construct and generate the appropriate code.
the function will be removed from the token_list once it has been processed
the function assumes that the function is the first object in the token_list
the function will be called three times with
- pass=0 generate subdissectors and entries for the function table
- pass=1 generate code for the REQUEST
- pass=2 generate code for the REPLY
+ pass=0 generate subdissectors and entries for the function table
+ pass=1 generate code for the REQUEST
+ pass=2 generate code for the REPLY
*/
-void parsefunction(int pass)
+static void parsefunction(int pass)
{
char *function_name;
static int funcno=0;
token_item_t *ti;
bracket_item_t *bi=NULL;
pointer_item_t *pi;
- char *pointer_type;
+ const char *pointer_type;
char tmpstr[256], *ptmpstr;
int level, num_pointers;
FPRINTF(NULL,"\nFUNCTION:%s pass:%d\n-------\n",function_name,pass);
if(pass==0){
- FPRINTF(eth_ft, " { %d, \"%s\",\n",funcno,function_name);
- FPRINTF(eth_ft, " %s_dissect_%s_request,\n", ifname, function_name);
- FPRINTF(eth_ft, " %s_dissect_%s_response },\n", ifname, function_name);
+ FPRINTF(eth_ft, " { %d, \"%s\",\n",funcno,function_name);
+ FPRINTF(eth_ft, " %s_dissect_%s_request,\n", ifname, function_name);
+ FPRINTF(eth_ft, " %s_dissect_%s_response },\n", ifname, function_name);
funcno++;
}
if((pass==1)||(pass==2)){
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s_dissect_%s_%s(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)\n", ifname, function_name, (pass==1)?"request":"response");
+ FPRINTF(eth_code, "%s_dissect_%s_%s(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)\n", ifname, function_name, (pass==1)?"request":"response");
FPRINTF(eth_code, "{\n");
}
/* pass 0 generate subdissectors */
if(pass==0){
char filter_name[256];
- char *hf;
+ const char *hf;
sprintf(tmpstr, "%s_dissect_%s_%s", ifname, function_name, ti->str);
ptmpstr=strdup(tmpstr);
-
sprintf(filter_name, "%s.%s.%s", ifname, function_name, ti->str);
hf=register_hf_field(hf_index, ti->str, filter_name, type_item->ft_type, type_item->base_type, type_item->vals, type_item->mask, "");
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", ptmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", ptmpstr);
FPRINTF(eth_code, "{\n");
FPRINTF(eth_code, " guint32 param=%s;\n",find_dissector_param_value(ptmpstr));
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep, %s, param);\n", type_item->dissector, hf);
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, di, drep, %s, param);\n", type_item->dissector, hf);
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
if(bi){
switch(bi->flags&(BI_SIZE_IS|BI_LENGTH_IS)){
case 0:
- break;
+ break;
case BI_SIZE_IS|BI_LENGTH_IS:
- sprintf(tmpstr, "ucvarray_%s", ptmpstr);
- FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
- FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_ucvarray(tvb, offset, pinfo, tree, drep, %s);\n", ptmpstr);
- FPRINTF(eth_code, " return offset;\n");
- FPRINTF(eth_code, "}\n");
- FPRINTF(eth_code, "\n");
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucvarray_%s", ptmpstr);
+ FPRINTF(eth_code, "static int\n");
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "{\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_ucvarray(tvb, offset, pinfo, tree, di, drep, %s);\n", ptmpstr);
+ FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, "}\n");
+ FPRINTF(eth_code, "\n");
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_SIZE_IS:
- sprintf(tmpstr, "ucarray_%s", ptmpstr);
- FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
- FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_ucarray(tvb, offset, pinfo, tree, drep, %s);\n", ptmpstr);
- FPRINTF(eth_code, " return offset;\n");
- FPRINTF(eth_code, "}\n");
- FPRINTF(eth_code, "\n");
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucarray_%s", ptmpstr);
+ FPRINTF(eth_code, "static int\n");
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "{\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_ucarray(tvb, offset, pinfo, tree, di, drep, %s);\n", ptmpstr);
+ FPRINTF(eth_code, " return offset;\n");
+ FPRINTF(eth_code, "}\n");
+ FPRINTF(eth_code, "\n");
+ ptmpstr=strdup(tmpstr);
+ break;
default:
- fprintf(stderr, "ERROR: typedeffunction can not handle this combination of sizeis/lengthis\n");
- Exit(10);
+ fprintf(stderr, "ERROR: typedeffunction can not handle this combination of sizeis/lengthis\n");
+ Exit(10);
}
}
pi=pi->next;
sprintf(tmpstr, "%s_%s", pointer_type, ptmpstr);
FPRINTF(eth_code, "static int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n", tmpstr);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep)\n", tmpstr);
FPRINTF(eth_code, "{\n");
- FPRINTF(eth_code, " offset=dissect_ndr_toplevel_pointer(tvb, offset, pinfo, tree, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), ti->str);
+ FPRINTF(eth_code, " offset=dissect_ndr_toplevel_pointer(tvb, offset, pinfo, tree, di, drep, %s, %s, \"%s\", -1);\n", ptmpstr, ptr_to_define(pointer_type), ti->str);
FPRINTF(eth_code, " return offset;\n");
FPRINTF(eth_code, "}\n");
FPRINTF(eth_code, "\n");
-
+
ptmpstr=strdup(tmpstr);
-
+
}
}
if(bi){
switch(bi->flags&(BI_SIZE_IS|BI_LENGTH_IS)){
case 0:
- break;
+ break;
case BI_SIZE_IS|BI_LENGTH_IS:
- sprintf(tmpstr, "ucvarray_%s", ptmpstr);
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucvarray_%s", ptmpstr);
+ ptmpstr=strdup(tmpstr);
+ break;
case BI_SIZE_IS:
- sprintf(tmpstr, "ucarray_%s", ptmpstr);
- ptmpstr=strdup(tmpstr);
- break;
+ sprintf(tmpstr, "ucarray_%s", ptmpstr);
+ ptmpstr=strdup(tmpstr);
+ break;
default:
- fprintf(stderr, "ERROR: typedeffunction can not handle this combination of sizeis/lengthis\n");
- Exit(10);
+ fprintf(stderr, "ERROR: typedeffunction can not handle this combination of sizeis/lengthis\n");
+ Exit(10);
}
}
sprintf(tmpstr, "%s_%s", pointer_type, ptmpstr);
ptmpstr=strdup(tmpstr);
}
-
- if((pass==1)&&(bi->flags&BI_IN)){
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
- FPRINTF(eth_code, " offset=dissect_deferred_pointers(pinfo, tvb, offset, drep);\n");
+
+ if((pass==1)&&(bi->flags&BI_IN)){
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
+ FPRINTF(eth_code, " offset=dissect_deferred_pointers(pinfo, tvb, offset, di, drep);\n");
FPRINTF(eth_code, "\n");
}
- if((pass==2)&&(bi->flags&BI_OUT)){
- FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
- FPRINTF(eth_code, " offset=dissect_deferred_pointers(pinfo, tvb, offset, drep);\n");
+ if((pass==2)&&(bi->flags&BI_OUT)){
+ FPRINTF(eth_code, " offset=%s(tvb, offset, pinfo, tree, drep);\n", ptmpstr);
+ FPRINTF(eth_code, " offset=dissect_deferred_pointers(pinfo, tvb, offset, di, drep);\n");
FPRINTF(eth_code, "\n");
}
}
if((pass==1)||(pass==2)){
if(pass==2){
- FPRINTF(eth_code, " offset=dissect_ntstatus(tvb, offset, pinfo, tree, drep, %s, NULL);\n", hf_status);
+ FPRINTF(eth_code, " offset=dissect_ntstatus(tvb, offset, pinfo, tree, di, drep, %s, NULL);\n", hf_status);
FPRINTF(eth_code, "\n");
}
FPRINTF(eth_code, "\n");
}
FPRINTF(NULL,"\nEND FUNCTION:%s pass:%d\n-------\n",function_name,pass);
-
+
/* only advance token_list for pass==2
ti now points to the ')' token
*/
if(pass==2){
- if(strcmp(ti->str,")")){
+ if(!ti || strcmp(ti->str,")")){
fprintf(stderr, "ERROR: function does not end with ')'\n");
Exit(10);
}
ti=ti->next;
- if(strcmp(ti->str,";")){
+ if(!ti || strcmp(ti->str,";")){
fprintf(stderr, "ERROR: function does not end with ';'\n");
Exit(10);
}
ti=ti->next;
-
+
token_list=ti;
}
}
/* this function will parse a
- typedef enum {
+ typedef enum {
or a
- typedef [ v1_enum ] enum {
+ typedef [ v1_enum ] enum {
construct and generate the appropriate code.
the typedef will be removed from the token_list once it has been processed
the function assumes that the typedef is the first object in the token_list
*/
-void parsetypedefenum(void)
+static void parsetypedefenum(void)
{
token_item_t *ti;
enum_list_t *enum_list, *el, *lastel;
+ char *p;
+ long val;
int eval, enumsize;
char dissectorname[256], valsstring[256], hfvalsstring[256];
* 3, CONST = value}
* 4, CONST}
*/
- el=malloc(sizeof(enum_list_t));
+ el=(enum_list_t*)malloc(sizeof(enum_list_t));
el->next=NULL;
if(!enum_list){
enum_list=el;
if(!strcmp(ti->str,"=")){
ti=ti->next;
/* grab value */
- el->val=atoi(ti->str);
+ val=strtol(ti->str,&p,0);
+ if (p==ti->str||*p) {
+ fprintf(stderr, "ERROR: typedefenum value is not a number\n");
+ Exit(10);
+ }
+ el->val=val;
ti=ti->next;
} else {
el->val=eval;
FPRINTF(eth_hdr, "\n");
FPRINTF(eth_hdr, "extern const value_string %s[];\n", valsstring);
- FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
+ FPRINTF(eth_hdr, "int %s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param);\n", dissectorname);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "const value_string %s[] = {\n", valsstring);
FPRINTF(eth_code, "\n");
FPRINTF(eth_code, "int\n");
- FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
+ FPRINTF(eth_code, "%s(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep, int hf_index, guint32 param _U_)\n", dissectorname);
FPRINTF(eth_code, "{\n");
switch(enumsize){
case 16:
- FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
break;
case 32:
- FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf_index, NULL);\n");
+ FPRINTF(eth_code, " offset=dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, NULL);\n");
break;
default:
fprintf(stderr,"ERROR enum unknown size\n");
struct _trimmed_prefixes_t *next;
char *name;
} trimmed_prefixes_t;
-trimmed_prefixes_t *prefixes_to_trim=NULL;
+static trimmed_prefixes_t *prefixes_to_trim=NULL;
-void preparetrimprefix(char *prefix_name)
+static void preparetrimprefix(char *prefix_name)
{
trimmed_prefixes_t *new_prefix;
- new_prefix=malloc(sizeof(trimmed_prefixes_t));
+ new_prefix=(trimmed_prefixes_t*)malloc(sizeof(trimmed_prefixes_t));
new_prefix->next=prefixes_to_trim;
prefixes_to_trim=new_prefix;
new_prefix->name=strdup(prefix_name);
}
-void
+
+static void
trimprefix(void)
{
token_item_t *ti;
trimmed_prefixes_t *pfx;
- int len;
+ size_t len;
for(pfx=prefixes_to_trim;pfx;pfx=pfx->next){
len=strlen(pfx->name);
}
}
-int Exit(int code)
+static int Exit(int code)
{
fprintf(stderr, "The tokens remaining when aborting:\n");
printtokenlist(10);
exit(code);
}
-void usage(void)
+static void usage(void)
{
fprintf(stderr, "Usage: idl2wrs <interface>\n");
}
-void
-mergefile(char *name, FILE *outfile)
+static void
+mergefile(const char *name, FILE *outfile)
{
FILE *infile;
-char *
+static char *
str_read_string(char *str, char **name)
{
char tmpstr[256], *strptr;
return ++str;
}
*strptr++ = *str++;
- }
+ }
return NULL;
}
-void
+static void
readcnffile(FILE *fh)
{
char cnfline[1024];
FPRINTF(NULL, "Reading conformance file\n=======================\n");
while(!feof(fh)){
cnfline[0]=0;
- fgets(cnfline, 1023, fh);
- if(!cnfline[0]){
- continue;
- }
+ if(!fgets(cnfline, 1023, fh) || !cnfline[0]){
+ continue;
+ }
if(cnfline[0]=='#'){
- /* ignore all comments */
+ /* ignore all comments */
} else if(!strncmp(cnfline, "NOEMIT", 6)){
no_emit_item_t *nei;
char *str, *name;
str=cnfline+6;
str=str_read_string(str, &name);
- nei=malloc(sizeof(no_emit_item_t));
+ nei=(no_emit_item_t*)malloc(sizeof(no_emit_item_t));
nei->next=no_emit_list;
no_emit_list=nei;
nei->name=name;
str=str_read_string(str, &union_tag);
union_tag_size=atoi(union_tag);
FPRINTF(NULL, "UNION_TAG_SIZE: %s == %d\n", union_name, union_tag_size);
- utsi=malloc(sizeof(union_tag_size_item_t));
+ utsi=(union_tag_size_item_t*)malloc(sizeof(union_tag_size_item_t));
utsi->next=union_tag_size_list;
union_tag_size_list=utsi;
utsi->name=strdup(union_name);
int main(int argc, char *argv[])
{
char idlfile[256];
- char cnffile[256];
char tmplfile[256];
char prefix_str[256];
bracket_item_t *bi;
+ FILE *fh;
if(argc!=2){
usage();
lineno=0;
linepos=0;
- tokenize();
+ tokenize(fh);
prune_keyword_parameters("size_is");
prune_keyword_parameters("length_is");
rename_tokens("NTSTATUS", "WERROR");
the appropriate handler
*/
while(1) {
- /* just skip any [ ] that starts a new construct */
+ /* just skip any [ ] that starts a new construct */
if( !strcmp(token_list->str, "[") ){
token_list=parsebrackets(token_list, &bi);
continue;
/* typedef struct { */
if( !strcmp(token_list->str,"typedef") ){
token_item_t *tmpti;
-
+
tmpti=token_list->next;
if( !strcmp(tmpti->str, "[") ){
tmpti=parsebrackets(tmpti, &bi);
/* typedef union { */
if( !strcmp(token_list->str,"typedef") ){
token_item_t *tmpti;
-
+
tmpti=token_list->next;
if( !strcmp(tmpti->str, "[") ){
tmpti=parsebrackets(tmpti, &bi);
/* typedef bitmap { */
if( !strcmp(token_list->str,"typedef") ){
token_item_t *tmpti;
-
+
tmpti=token_list->next;
if( !strcmp(tmpti->str, "[") ){
tmpti=parsebrackets(tmpti, &bi);
continue;
}
-
+
break;
};
/* unless the token_list now only contains a single token : '}'
we have failed to compile the idl file properly
- */
+ */
if( strcmp(token_list->str, "}") || token_list->next){
fprintf(stderr, "ERROR: we did not process all tokens. Compiler is incomplete.\n===========================================\n");
printtokenlist(10);
}
while(!feof(tfh)){
line[0]=0;
- fgets(line, 1024, tfh);
+ if(!fgets(line, 1024, tfh) || !line[0]){
+ continue;
+ }
if(!strncmp(line, "ETH_CODE", 8)){
mergefile("ETH_CODE",fh);
} else if(!strncmp(line, "ETH_HDR", 7)){
fclose(fh);
fclose(tfh);
-
sprintf(line, "packet-dcerpc-%s.h", ifname);
fh=fopen(line, "w");
sprintf(tmplfile, "packet-dcerpc-%s-template.h", argv[1]);
exit(10);
}
while(!feof(tfh)){
- line[0]=0;
- fgets(line, 1024, tfh);
+ line[0]=0;
+ if(!fgets(line, 1024, tfh) || !line[0]){
+ continue;
+ }
if(!strncmp(line, "ETH_CODE", 8)){
mergefile("ETH_CODE",fh);
} else if(!strncmp(line, "ETH_HDR", 7)){
fclose(fh);
fclose(tfh);
+ remove("ETH_CODE");
+ remove("ETH_HDR");
+ remove("ETH_HFARR");
+ remove("ETH_HF");
+ remove("ETH_ETTARR");
+ remove("ETH_ETT");
+ remove("ETH_FT");
+ remove("ETH_HANDOFF");
+
return 0;
}