-
Notifications
You must be signed in to change notification settings - Fork 4
Design
eventh edited this page Sep 17, 2011
·
9 revisions
An attempt at giving an overall design for the program, and its different parts.
- Its better with a smart data structure surrounded by dumb code than a dumb data structure and smart code!!
- Clear and clean separation of the front-end and the back-end so in the future other parsers can be used to generate dissectors
- Try to be pythonic, follow PEP8 and PEP20.
- Now is better than never. Don't be afraid to write stupid or ugly code, we can always fix it later.
- The first version is never perfect, so don't wait until its perfect before you commit. Commit often!
- The program is split into several parts.
- The part which the user runs, should accept arguments which specifies which files to parse and config files to use. It should ask the configuration to parse config files, then ask the front-end to parse c files, and finally ask the back-end to generate Wireshark dissectors.
- Configuration should parse config files and feed information to the other parts, or they should request informations when they need it.
- Front-end C parser should parse C files and look for struct definitions, which they will fill into some data-structures that the back-end will use.
- The data structures should store the information the back-end needs to generate Wireshark dissectors.
- The back end should use information in the data structures to generate Wireshark dissectors written in Lua.
- Should probably use argparse module from python standard library.
- Needs to parse commands given when the program is started, and supply them to other parts of the program who needs them.
- It must fulfill the following requirements:
- FR7-A Command line shall support parameters for c-header file
- FR7-B Command line shall support for configuration file
- FR7-C Command line shall support batch mode of c-header and configuration file
- This simply means it should accept arguments for 0, 1, or more C code files, and/or 0 or 1 configuration file.
- It would be useful if it could also support:
- -v or -verbose: which should print information about AST tree etc.
- -d or -debug: which should print which steps are happening in the process
- -nocpp: option to disable the C preprocessor
- option(s) to specify which folders to include in the C preprocessor step
- option which specifies where the output should be saved
- printing of help/usage information if one gives it no commands or wrong command
- Parse one (or more?) configuration files which can be used to modify the process of generation dissectors.
- Should maybe only modify data structures?
- Challenging part is designing how do we support the different scope of configuration:
- Can refer to a specific named struct
- Can refer to a specific C file?
- Can refer to all structs
- Can refer to a specific type like time_t
- Must fulfill the following requirements:
- Must support valid ranges for struct members
- Must support integer members which represent enumerated named value or a bit string
- Must support custom handling of specific data types
- A struct may have a header and/or trailer (other registered protocol). The configuration must support the use of integer members to indicate the number of other structs that will follow in the trailer
- Use pycparser and PLY libraries for parsing of C files.
- Use cpp and fake libc include files, which comes with pycparser, for C preprocessor step as long as possible.
- Should accept C header/code files and create an abtract syntax tree, which it then traverses and finds struct defintions and their members.
- Should fill in the necessary information into the data structures, so that the dissector generator can create dissectors for the structs.
- Must fulfill the following requirements:
- Must be able to read basic C language struct definitions from C header files
- Must support the following basic data types: int, float, char and boolean
- Must support members of type enums, structs, unions and arrays
- Must support C preprocessor directives and macros: #include, #define, #if, WIN32, _WIN32, _WIN64, sparc, __sparc and sun
- Should be focused on what data is needed to create Wireshark dissectors.
- Should support configuration modifying it.
- Should be smart, but not magic.
- Should accept data structures and create Wireshark dissectors written in Lua.
- Must fulfill the following requirements:
- Must be able to generate lua-script for Wireshark dissectors for the binary representation of C structs.
- Shall be able to display simple structs and structs within structs
- Must support Wiresharks built-in filter and search on attributes
- Shall be able to recognize invalid values for a struct member
- I dont know yet how we will do this
- Flags?
