This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Hello, I want to ask some questions about diameter protocol :

I have donwloaded the source code of wireshark and I go into the folder wireshark-2.0.2/epan to see the file diam_dict.l

  1. I want to know why wireshark has used lex and yacc (or flex and bison) but not other xml parser (like libxml2) to parse the diameter protocol dictionary (wireshark-2.0.2/diameter/dictionary.xml)
  2. And I want to know why wireshark has put the lex file and the yacc file together, so that there is just one file (in other words wireshark-2.0.2/epan/diam_dict.l). Normally, we have lex files (like diam_dict.l ==> lex.yy.c) and yacc files (diam_dict.y ==> y.tab.h & y.tab.c)
  3. In fact, I am now doing a project to try to replace the role of lex and yacc (the role of xml parser (in particulary I only want to paser the file wireshark-2.0.2/diameter/dictionary.xml)), to replace it with another xml parser (libxml2), do you have any advice ? (Now I am studying the functions of the file wireshark-2.0.2/epan/diam_dict.l, so that I can write by myself another file using the libxml2 library to do exactly the same thing)

asked 21 Apr '16, 07:40

bohao's gravatar image

bohao
16226
accept rate: 0%


I want to know why wireshark has used lex and yacc (or flex and bison)

No, just Flex (and it's required Flex for a while now; the version in the trunk not only requires Flex, it requires a version new enough to support reentrant parsers). There's no YACC/Bison/Berkeley YACC parser there.

And I want to know why wireshark has put the lex file and the yacc file together

They're not together - there is no YACC file.

to replace it with another xml parser (libxml2), do you have any advice ?

In addition to making sure that an XML parser will actually accept the dictionary, also make sure that libxml2 can be made to work on all our supported platforms, including Windows, and that you don't depend on features of libxml2 only available in versions of libxml2 not present in commonly-used versions of {Linux distributions, *BSDs, OS X, other commercial UN*Xes} that bundle libxml2 (it'd be best if Wireshark could build on those versions without the user having to install a newer version of libxml2).

permanent link

answered 21 Apr '16, 14:01

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

Thank you so much for your answer, that really helped me a lot.

  So you mean that wireshark has used flex (rather than other xml parsers) because that it is compatible on diffrent operating systems (if there is another reason for this, please tell me) ?

  And, in fact, I haven't decided which xml parser to use yet, libxml2 is just a tool that someone advised me to use. I want to just use a xml parser for language c because this is the language that I use the most frequetly. So if you know another better xml parser for language c you can tell me :)

  (at this moment I am studying the functions and the data structure of the file wireshark-2.0.2/epan/diam_dict.l, so that I can imitate the functions of this file by replacing the original paser (flex) by another xml parser. )

Good day.

(22 Apr '16, 00:02) bohao

I think to know why we'd have to ask the original author who hasn't been working on Wireshark in some time. IOW I don't think it will be easy to find out. But, see the next paragraph.

For question (3) I'd suggest first checking if the the XML is actually syntactically correct. A while back I ran xmllint on it and cleaned up a lot of the errors but there were still a large number left--mostly things that, frankly, it didn't seem worth fixing. IOW a proper XML parser may not be happy with our (pseudo-?) XML. This may be part of the reason we don't use a proper XML parser.

Oh, actually the first commit of diam_dict.l indicates that we used to use libxml but that it was intentionally dropped:

commit b0bd83c868af357fffc971157f4bae2b7060073d
Author: Luis Ontanon <[email protected]>
Date:   Mon Jul 16 05:41:58 2007 +0000

    Rewrite of the diameter dissector to use the dictionary for creating hfids, drop libxml dependency.

A little more research suggests that the lack of a (fully supported or at least working) Windows version may have been what killed our use of it off. (There are other messages on the mailing lists suggesting plenty of people being unhappy because the Diameter dissector didn't work on Windows.)

permanent link

answered 21 Apr '16, 11:53

JeffMorriss's gravatar image

JeffMorriss ♦
6.2k572
accept rate: 27%

Thank you.

(22 Apr '16, 00:25) bohao
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

Question tags:

×124
×58
×13

question asked: 21 Apr '16, 07:40

question was seen: 1,358 times

last updated: 22 Apr '16, 00:27

p​o​w​e​r​e​d by O​S​Q​A