6
6
* (c) 2006, Luis E. Garcia Ontanon <luis.ontanon@gmail.com>
8
* $Id: wslua_field.c 19595 2006-10-18 18:45:24Z lego $
8
* $Id: wslua_field.c 19992 2006-11-26 18:31:53Z wmeier $
10
10
* Wireshark - Network traffic analyzer
11
11
* By Gerald Combs <gerald@wireshark.org>
38
38
WSLUA_METAMETHOD FieldInfo__len(lua_State* L) {
40
The Length of the field
40
Obtain the Length of the field
42
42
FieldInfo fi = checkFieldInfo(L,1);
43
43
lua_pushnumber(L,fi->length);
47
47
WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) {
49
The Offset of the field
49
Obtain the Offset of the field
51
51
FieldInfo fi = checkFieldInfo(L,1);
52
52
lua_pushnumber(L,fi->start);
139
139
WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) {
140
/* the string representation of the field */
140
141
FieldInfo fi = checkFieldInfo(L,1);
142
143
if (fi->value.ftype->val_to_string_repr)
150
WSLUA_ATTR_GET FieldInfo_get_data_source(lua_State* L) {
151
FieldInfo fi = checkFieldInfo(L,1);
152
pushTvb(L,fi->ds_tvb);
156
151
WSLUA_ATTR_GET FieldInfo_get_range(lua_State* L) {
152
/* the TvbRange covering this field */
157
153
FieldInfo fi = checkFieldInfo(L,1);
158
154
TvbRange r = ep_alloc(sizeof(struct _wslua_tvbrange));
169
WSLUA_ATTR_GET FieldInfo_get_hidden(lua_State* L) {
170
FieldInfo fi = checkFieldInfo(L,1);
171
lua_pushboolean(L,FI_GET_FLAG(fi, FI_HIDDEN));
175
164
WSLUA_ATTR_GET FieldInfo_get_generated(lua_State* L) {
165
/* Whether this field was marked as generated. */
176
166
FieldInfo fi = checkFieldInfo(L,1);
177
167
lua_pushboolean(L,FI_GET_FLAG(fi, FI_GENERATED));
181
171
WSLUA_ATTR_GET FieldInfo_get_name(lua_State* L) {
172
/* the filter name of this field. */
182
173
FieldInfo fi = checkFieldInfo(L,1);
183
174
lua_pushstring(L,fi->hfinfo->abbrev);
187
178
static const luaL_reg FieldInfo_get[] = {
188
{"data_source", FieldInfo_get_data_source },
179
/* {"data_source", FieldInfo_get_data_source }, */
189
180
{"range", FieldInfo_get_range},
190
{"hidden", FieldInfo_get_hidden},
181
/* {"hidden", FieldInfo_get_hidden}, */
191
182
{"generated", FieldInfo_get_generated},
192
183
{"name", FieldInfo_get_name},
193
184
{"label", FieldInfo__tostring},
218
209
WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) {
210
/* checks whether lhs is within rhs */
219
211
FieldInfo l = checkFieldInfo(L,1);
220
212
FieldInfo r = checkFieldInfo(L,2);
233
225
WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
226
/* checks whether the end byte of lhs is before the end of rhs */
234
227
FieldInfo l = checkFieldInfo(L,1);
235
228
FieldInfo r = checkFieldInfo(L,2);
237
230
if (l->ds_tvb != r->ds_tvb)
238
WSLUA_ERROR(FieldInfo__eq,"data source must be the same for both fields");
240
233
if (r->start + r->length <= l->start + r->length) {
241
234
lua_pushboolean(L,1);
248
241
WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) {
242
/* checks whether the end byte of rhs is before the beginning of rhs */
249
243
FieldInfo l = checkFieldInfo(L,1);
250
244
FieldInfo r = checkFieldInfo(L,2);
384
379
WSLUA_METAMETHOD Field__call (lua_State* L) {
380
/* obtain all values (see FieldInfo) for this field. */
385
381
Field f = checkField(L,1);
386
382
header_field_info* in = *f;
387
383
int items_found = 0;