1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#!/bin/sh
#
# File : idl2wrs
#
# Author : Frank Singleton (frank.singleton@ericsson.com)
#
# Copyright (C) 2001 Frank Singleton, Ericsson Inc.
#
# This file is a simple shell script wrapper for the IDL to
# Wireshark dissector code.
#
# ie: wireshark_be.py and wireshark_gen.py
#
# This file is used to generate "Wireshark" dissectors from IDL descriptions.
# The output language generated is "C". It will generate code to use the
# GIOP/IIOP get_CDR_XXX API.
#
# Please see packet-giop.h in Wireshark distro for API description.
# Wireshark is available at https://www.wireshark.org/
#
# Omniidl is part of the OmniOrb distribution, and is available at
# http://omniorb.sourceforge.net/
#
# 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.
#
# Must at least supply an IDL file
if [ $# -lt 1 ]; then
echo "idl2wrs Error: no IDL file specified."
echo "Usage: idl2wrs idl_file_name"
exit 1;
fi
# Check the file name for valid characters.
# Implementation based on Dave Taylor's validalnum shell script from his book,
# "Wicked Cool Shell Scripts", as well as Mark Rushakoff's answer he provided
# to the question posted at stackoverflow.com entitled, "How can I use the
# UNIX shell to count the number of times a letter appears in a text file?"
file=$(basename $1)
compressed="$(echo $file | sed 's/[^[:alnum:]._]//g')"
if [ "$compressed" != "$file" ]; then
echo "idl2wrs Error: Invalid file name: $file"
exit 1;
fi
# Only allow one '.' at most.
count=$(echo $compressed | awk -F. '{c += NF - 1} END {print c}')
if [ $count -gt 1 ] ; then
echo "idl2wrs Error: Invalid file name: $file"
exit 1;
fi
#
# Run wireshark backend, looking for wireshark_be.py and wireshark_gen.py
# in pythons's "site-packages" directory. If cannot find that, then
# try looking in current directory. If still cannot, then exit with
# error.
if [ -f $PYTHONPATH/site-packages/wireshark_be.py ] && [ -f $PYTHONPATH/site-packages/wireshark_gen.py ]; then
exec omniidl -p $PYTHONPATH/site-packages -b wireshark_be $@
/* not reached */
fi
# Try current directory.
if [ -f ./wireshark_be.py ] && [ -f ./wireshark_gen.py ]; then
exec omniidl -p ./ -b wireshark_be $@
/* not reached */
fi
# Could not find both wireshark_be.py AND wireshark_gen.py
# So let's just try to run it without -p, hoping that the installation
# set up a valid path.
exec omniidl -b wireshark_be $@
old code: not reached
echo "idl2wrs Error: Could not find both wireshark_be.py AND wireshark_gen.py."
echo "Please ensure you have the PYTHONPATH variable set, or that wireshark_be.py "
echo "and wireshark_gen.py exist in the current directory. "
echo
echo "On this system, PYTHONPATH is : $PYTHONPATH"
echo
exit 2
#
# Editor modelines - https://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=4 expandtab:
# :indentSize=4:noTabs=true:
#
|