I am trying to adapt an old code packet-gtpcdr.c into new version of wireshark but failed during compilation.

  1. If I rename the u_char to gchar the complilation continue. I am not sure if this is correct.

    /* TAG undefined */
    int decode_tlv_undefined (tvbuff_t *tvb, proto_tree *tree, int offset) {
        proto_tree  *tlv_tree;
        proto_item  *te;
        u_char  length, tag;
        tag = tvb_get_guint8 (tvb, offset);
        length = tvb_get_guint8 (tvb, offset + 1);
        te = proto_tree_add_text (tree, tvb, offset, length + 2, "TAG %d (undefined)", tag);
        tlv_tree = proto_item_add_subtree (te, ett_gtp_cdr_undefined);
        proto_tree_add_text (tlv_tree, tvb, offset, 1, "Type: %d", tag);
        proto_tree_add_text (tlv_tree, tvb, offset + 1, 1, "Length: %d", length);
        proto_tree_add_text (tlv_tree, tvb, offset + 2, length, "Value");
    
  2. Which additional value should I add for abs_time_to_str?

    static gchar *
    time_int_to_str (guint32 time)
    {
        static nstime_t nstime;
        nstime.secs = time;
        nstime.nsecs = 0;
        return abs_time_to_str (&nstime);
    

See the compile error

packet-gtpcdr.c
plugin.c
packet-gtpcdr.c(2573) : error C2198: 'abs_time_to_str' : too few arguments for call
packet-gtpcdr.c(3901) : error C2065: 'uchar' : undeclared identifier
packet-gtpcdr.c(3901) : error C2146: syntax error : missing ';' before identifier 'length'
packet-gtpcdr.c(3901) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3901) : error C2065: 'tag' : undeclared identifier
packet-gtpcdr.c(3903) : error C2065: 'tag' : undeclared identifier
packet-gtpcdr.c(3904) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3906) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3906) : error C2065: 'tag' : undeclared identifier
packet-gtpcdr.c(3909) : error C2065: 'tag' : undeclared identifier
packet-gtpcdr.c(3910) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3911) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3913) : error C2065: 'length' : undeclared identifier
packet-gtpcdr.c(3921) : error C2065: 'uchar' : undeclared identifier
packet-gtpcdr.c(3921) : error C2146: syntax error : missing ';' before identifier 'length'

Thanks

asked 27 Mar '13, 14:59

steve21's gravatar image

steve21
11235
accept rate: 0%

edited 27 Mar '13, 15:42

Guy%20Harris's gravatar image

Guy Harris ♦♦
11.0k226140

First of all thanks for your support. Now compile failed because version already defined in packet in packet-gtpcdr.obj Can you help me?

    link -dll /out:gtpcdr.dll /NOLOGO /INCREMENTAL:no /DEBUG /MACHINE:x86 /SafeSEH /DYNAMICBASE /FIXED:no  packet-gtpcdr.obj  plugin.obj ..\..\epan\libwireshark.lib  C:\wireshark-win32-libs-1.8\gtk2\lib\glib-2.0.lib  C:\wireshark-win32-libs-1.8\gtk2\lib\gmodule-2.0.lib  C:\wireshark-win32-libs-1.8\gtk2\lib\gobject-2.0.lib gtpcdr.res plugin.obj : error LNK2005: _version already defined in packet-gtpcdr.obj
   Creating library gtpcdr.lib and object gtpcdr.exp
gtpcdr.dll : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : return code '0x491'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
(28 Mar '13, 04:44) steve21

You should replace your u_char by guint8. Moreover the prototype of abs_time_to_str is now:

gchar* abs_time_to_str(const nstime_t*, const absolute_time_display_e fmt, gboolean show_zone);

so your code should be:

static gchar *
time_int_to_str (guint32 time)
{
    static nstime_t nstime;
    nstime.secs = time;
    nstime.nsecs = 0;
    return abs_time_to_str (&nstime, ABSOLUTE_TIME_UTC, FALSE);
}
link

answered 27 Mar '13, 15:51

Pascal%20Quantin's gravatar image

Pascal Quantin
717111
accept rate: 23%

If I rename the u_char to gchar the complilation continue. I am not sure if this is correct.

uchar, u_char, etc. are types defined by the operating system on which you're compiling; they should be avoided, so that the code can compile on several operating systems (including Windows, which is what you're compiling on).

Instead, the GLib types should be used; for example, for an 8-bit unsigned integral quantity, use guint8. (Oh, and since it's unsigned, format it with %u, not %d.)

Which additional value should I add for abs_time_to_str?

You should add, as the second argument:

  • ABSOLUTE_TIME_LOCAL, if you want the time stamp displayed as local date and time, with the date shown as a month, day, and year;
  • ABSOLUTE_TIME_UTC, if you want the time stamp displayed as UTC date and time, with the date shown as a month, day, and year;
  • ABSOLUTE_TIME_DOY_UTC, if you want the time stamp displayed as UTC date and time, with the date shown as day-of-year and year, with January 1 being day-of-year 1.
link

answered 27 Mar '13, 15:55

Guy%20Harris's gravatar image

Guy Harris ♦♦
11.0k226140
accept rate: 17%

edited 27 Mar '13, 15:56

@steve21, I'd already converted your "answer" to a comment under your original question as it wasn't clear which actual answer your "answer" was referring to, and in addition, it was really an extension of your original question.

(28 Mar '13, 07:43) grahamb ♦

It's an extension only in that it's presumably an issue with the same dissector, but it's a completely different issue, so I made it into a separate question. This is a Q&A site, not a forum, so each item in the site should cover a separate question, so that people searching the site to see whether somebody else already asked the same question and got an answer can more easily find the question.

(28 Mar '13, 11:33) Guy Harris ♦♦

Hi,

Sorry I did not know it.

(28 Mar '13, 14:23) steve21
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1
×1

Asked: 27 Mar '13, 14:59

Seen: 491 times

Last updated: 28 Mar '13, 14:23

Related questions

powered by OSQA