static void header_fields_update_cb(void *r, const char **err) { header_field_t *rec = (header_field_t *)r; char c; if (rec->header_name == NULL) { *err = ep_strdup_printf("Header name can't be empty"); return; } g_strstrip(rec->header_name); if (rec->header_name[0] == 0) { *err = ep_strdup_printf("Header name can't be empty"); return; } /* Check for invalid characters (to avoid asserting out when * registering the field). */ c = proto_check_field_name(rec->header_name); if (c) { *err = ep_strdup_printf("Header name can't contain '%c'", c); return; } *err = NULL; }
/* -------------------------- */ static int time_stamp(tvbuff_t *tvb, proto_tree *nasdaq_itch_tree, int id, int offset, int size) { if (nasdaq_itch_tree) { guint32 ms, val; const char *display = ""; const char *str_value = tvb_get_ephemeral_string(tvb, offset, size); ms = val = strtoul(str_value, NULL, 10); switch (size) { case 3: display = ep_strdup_printf(" %03u" , val); break; case 5: ms = val *1000; case 8: /* 0 86 400 000 */ display = ep_strdup_printf(" %u (%02u:%02u:%02u.%03u)", val, ms/3600000, (ms % 3600000)/60000, (ms % 60000)/1000, ms %1000); break; } proto_tree_add_uint_format_value(nasdaq_itch_tree, id, tvb, offset, size, val, "%s", display); } return offset+size; }
static void dissect_UDPR1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *adwin_tree, proto_tree *adwin_debug_tree, gchar** info_string) { const gchar *status_string; guint32 seq_num, status; status = tvb_get_letohl(tvb, 0); status_string = match_strval_ext(status, &error_code_mapping_ext); if (status_string) { *info_string = ep_strdup_printf("UDPR1 Status: %s", status_string); } else { *info_string = ep_strdup_printf("UDPR1 Undefined error code %d", status); } /* Get the transaction identifier */ seq_num = tvb_get_letohl(tvb, 4); adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE); if (! adwin_tree) return; SET_PACKET_TYPE(adwin_tree, APT_UDPR1); ADWIN_ADD_LE(adwin_tree, status, 0, 4); ADWIN_ADD_LE(adwin_tree, packet_index, 4, 4); ADWIN_ADD_LE(adwin_tree, val1, 8, 4); ADWIN_ADD_LE(adwin_tree, val1f, 8, 4); ADWIN_ADD_LE(adwin_tree, val2, 12, 4); ADWIN_ADD_LE(adwin_tree, val3, 16, 4); ADWIN_ADD_LE(adwin_tree, val4, 20, 4); ADWIN_ADD_LE(adwin_debug_tree, unused, 24, 8); }
gint decode_visit(tvbuff_t *tvb, proto_tree *tree, gint offset) { guint32 to_visit_len; guint32 visited_len; guint32 i; to_visit_len = tvb_get_ntohl(tvb, offset); proto_tree_add_uint(tree, hf_scribe_to_visit_len, tvb, offset, 4, to_visit_len); offset += 4; for (i = 0; i < to_visit_len; ++i){ offset = decode_nodehandle(tvb, tree, offset, ep_strdup_printf("NodeHandle to visit #%d", i+1)); if (offset == -1){ return -1; } }/*end for each to_visit*/ visited_len = tvb_get_ntohl(tvb, offset); proto_tree_add_uint(tree, hf_scribe_visited_len, tvb, offset, 4, visited_len); offset += 4; for (i = 0; i < visited_len; ++i){ offset = decode_nodehandle(tvb, tree, offset, ep_strdup_printf("Visited NodeHandle #%d", i+1)); if (offset == -1){ return -1; } }/*end for each visited*/ return offset; }
gboolean uat_save(uat_t* uat, char** error) { guint i; gchar* fname = uat_get_actual_filename(uat,TRUE); FILE* fp; if (! fname ) return FALSE; fp = ws_fopen(fname,"w"); if (!fp && errno == ENOENT) { /* Parent directory does not exist, try creating first */ gchar *pf_dir_path = NULL; if (create_persconffile_dir(&pf_dir_path) != 0) { *error = ep_strdup_printf("uat_save: error creating '%s'", pf_dir_path); g_free (pf_dir_path); return FALSE; } fp = ws_fopen(fname,"w"); } if (!fp) { *error = ep_strdup_printf("uat_save: error opening '%s': %s",fname,g_strerror(errno)); return FALSE; } *error = NULL; g_free (fname); fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n"); for ( i = 0 ; i < uat->user_data->len ; i++ ) { void* rec = uat->user_data->data + (uat->record_size * i); uat_field_t* f; guint j; f = uat->fields; for( j=0 ; j < uat->ncols ; j++ ) { putfld(fp, rec, &(f[j])); fputs((j == uat->ncols - 1) ? "\n" : "," ,fp); } } fclose(fp); uat->changed = FALSE; return TRUE; }
/* * For PIM v1, see * * ftp://ftp.usc.edu/pub/csinfo/tech-reports/papers/95-599.ps.Z * * NOTE: There is still some doubt that this is THE definitive PIMv1 * specification. Of note, the type1vals entry, { 8, "Mode" }, does * not appear as a valid code in the referenced document above. * * This one is likely closer to the last PIMv1 spec: * http://tools.ietf.org/id/draft-ietf-idmr-pim-spec-02.txt */ static const char * dissect_pimv1_addr(tvbuff_t *tvb, int offset) { guint16 flags_masklen; flags_masklen = tvb_get_ntohs(tvb, offset); if (flags_masklen & 0x0180) { return ep_strdup_printf("(%s%s%s) ", flags_masklen & 0x0100 ? "S" : "", flags_masklen & 0x0080 ? "W" : "", flags_masklen & 0x0040 ? "R" : ""); } else { return ep_strdup_printf("%s/%u", tvb_ip_to_str(tvb, offset + 2), flags_masklen & 0x3f); } }
static void dissect_UDPR2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *adwin_tree, proto_tree *adwin_debug_tree, gchar** info_string) { const gchar *status_string; guint32 i, status, seq_num; status = tvb_get_letohl(tvb, 0); status_string = match_strval_ext(status, &error_code_mapping_ext); if (status_string) { *info_string = ep_strdup_printf("UDPR2 Status: %s", status_string); } else { *info_string = ep_strdup_printf("UDPR2 Undefined error code %d", status); } /* Get the transaction identifier */ seq_num = tvb_get_letohl(tvb, 4); adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE); if (! adwin_tree) return; SET_PACKET_TYPE(adwin_tree, APT_UDPR2); ADWIN_ADD_LE(adwin_tree, status, 0, 4); ADWIN_ADD_LE(adwin_tree, packet_index, 4, 4); if (! global_adwin_dissect_data) { proto_tree_add_text(adwin_debug_tree, tvb, 8, 250 * 4, "Data"); return; } for (i = 0; i < 250; i++) { proto_item *item; guint32 offset = 8 + i * sizeof(guint32); gint32 value = tvb_get_letohl(tvb, offset); void * fvalue = &value; proto_tree_add_text(adwin_debug_tree, tvb, offset, 4, "Data[%3d]: %10d - %10f - 0x%08x", i, value, *(float*)fvalue, value); item = ADWIN_ADD_LE(adwin_debug_tree, data_int, offset, 4); PROTO_ITEM_SET_HIDDEN(item); item = ADWIN_ADD_LE(adwin_debug_tree, data_float, offset, 4); PROTO_ITEM_SET_HIDDEN(item); item = ADWIN_ADD_LE(adwin_debug_tree, data_hex, offset, 4); PROTO_ITEM_SET_HIDDEN(item); } }
static void header_fields_update_cb(void *r, const char **err) { header_field_t *rec = r; if (rec->header_name == NULL) { *err = ep_strdup_printf("Header name can't be empty"); } else { g_strstrip(rec->header_name); if (rec->header_name[0] == 0) { *err = ep_strdup_printf("Header name can't be empty"); } else { *err = NULL; } } }
void parseByteString(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, int hfIndex) { char *szValue; int iOffset = *pOffset; gint32 iLen = tvb_get_letohl(tvb, iOffset); iOffset += 4; if (iLen == -1) { proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA); proto_item_append_text(item, "[OpcUa Null ByteString]"); proto_item_set_end(item, tvb, *pOffset + 4); } else if (iLen == 0) { proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA); proto_item_append_text(item, "[OpcUa Empty ByteString]"); proto_item_set_end(item, tvb, *pOffset + 4); } else if (iLen > 0) { proto_tree_add_item(tree, hfIndex, tvb, iOffset, iLen, ENC_NA); iOffset += iLen; /* eat the whole bytestring */ } else { proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA); szValue = ep_strdup_printf("[Invalid ByteString] Invalid length: %d", iLen); proto_item_append_text(item, "%s", szValue); proto_item_set_end(item, tvb, *pOffset + 4); } *pOffset = iOffset; }
/* dissect a bt dht error from tvb, start at offset. it's like "li201e9:error msge" */ static int dissect_bt_dht_error(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, char **result, char *label ) { proto_item *ti; proto_tree *sub_tree; char *error_no, *error_msg; error_no = NULL; error_msg = NULL; ti = proto_tree_add_item( tree, hf_bt_dht_error, tvb, offset, 0, ENC_NA ); sub_tree = proto_item_add_subtree( ti, ett_bt_dht_error); /* we have confirmed that the first byte is 'l' */ offset += 1; /* dissect bt-dht error number and message */ offset = dissect_bencoded_int( tvb, pinfo, sub_tree, offset, &error_no, "Error ID" ); offset = dissect_bencoded_string( tvb, pinfo, sub_tree, offset, &error_msg, FALSE, "Error Message" ); proto_item_set_text( ti, "%s: error %s, %s", label, error_no, error_msg ); col_append_fstr( pinfo->cinfo, COL_INFO, "error_no=%s error_msg=%s ", error_no, error_msg ); *result = ep_strdup_printf("error %s, %s", error_no, error_msg ); return offset; }
WSLUA_METAMETHOD NSTime__tostring(lua_State* L) { NSTime nstime = checkNSTime(L,1); lua_pushstring(L,ep_strdup_printf("%ld.%09d", (long)nstime->secs, nstime->nsecs)); WSLUA_RETURN(1); /* The string representing the nstime. */ }
static gboolean diam_tree_to_csv(proto_node* node, gpointer data) { char* val_str=NULL; char* val_tmp=NULL; ftenum_t ftype; field_info* fi; header_field_info *hfi; if(!node) { fprintf(stderr,"traverse end: empty node. node='%p' data='%p'\n",(void *)node,(void *)data); return FALSE; } fi=node->finfo; hfi=fi ? fi->hfinfo : NULL; if(!hfi) { fprintf(stderr,"traverse end: hfi not found. node='%p'\n",(void *)node); return FALSE; } ftype=fvalue_type_ftenum(&fi->value); if (ftype!=FT_NONE&&ftype!=FT_PROTOCOL) { /* convert value to string */ val_tmp=fvalue_to_string_repr(&fi->value,FTREPR_DISPLAY,NULL); if(val_tmp) { val_str=ep_strdup(val_tmp); g_free(val_tmp); } else val_str=ep_strdup_printf("unsupported type: %s",ftype_name(ftype)); /*printf("traverse: name='%s', abbrev='%s',desc='%s', val='%s'\n",hfi->name,hfi->abbrev,ftype_name(hfi->type),val_str);*/ printf("%s='%s' ",hfi->name,val_str); } return FALSE; }
static void cmpp_msg_id(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset) { guint8 month,day,hour,minute,second; guint32 ismg_code; proto_item *pi; proto_tree *sub_tree; char *strval; pi = proto_tree_add_item(tree, field, tvb, offset, 8, ENC_BIG_ENDIAN); sub_tree = proto_item_add_subtree(pi, ett_msg_id); month = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4; day = (tvb_get_ntohs(tvb, offset) & 0x0F80) >> 7; hour = (tvb_get_guint8(tvb, offset + 1) & 0x7C) >> 2; minute = (tvb_get_ntohs(tvb, offset + 1) & 0x03F0) >> 4; second = (tvb_get_ntohs(tvb, offset + 2) & 0x0FC0) >> 6; strval = ep_strdup_printf("%02u/%02u %02u:%02u:%02u", month, day, hour, minute, second); ismg_code = (tvb_get_ntohl(tvb, offset + 3) & 0x3FFFFF00) >> 16; proto_tree_add_string(sub_tree, hf_msg_id_timestamp, tvb, offset, 4, strval); proto_tree_add_uint(sub_tree, hf_msg_id_ismg_code, tvb, offset + 3, 3, ismg_code); cmpp_uint2(sub_tree, tvb, hf_msg_id_sequence_id, offset + 6); }
/** plugin entry functions. * This registers the OpcUa protocol. */ void proto_register_opcua(void) { module_t *opcua_module; proto_opcua = proto_register_protocol( "OpcUa Binary Protocol", /* name */ "OpcUa", /* short name */ "opcua" /* abbrev */ ); registerTransportLayerTypes(proto_opcua); registerSecurityLayerTypes(proto_opcua); registerApplicationLayerTypes(proto_opcua); registerSimpleTypes(proto_opcua); registerEnumTypes(proto_opcua); registerComplexTypes(); registerServiceTypes(); registerFieldTypes(proto_opcua); proto_register_subtree_array(ett, array_length(ett)); range_convert_str(&global_tcp_ports_opcua, ep_strdup_printf("%u", OPCUA_PORT), 65535); /* register user preferences */ opcua_module = prefs_register_protocol(proto_opcua, proto_reg_handoff_opcua); prefs_register_range_preference(opcua_module, "tcp_ports", "OPC UA TCP Ports", "The TCP ports for the OPC UA TCP Binary Protocol", &global_tcp_ports_opcua, 65535); }
static void k12_update_cb(void* r, const char** err) { k12_handles_t* h = r; gchar** protos; guint num_protos, i; protos = ep_strsplit(h->protos,":",0); for (num_protos = 0; protos[num_protos]; num_protos++) g_strstrip(protos[num_protos]); g_free(h->handles); h->handles = g_malloc0(sizeof(dissector_handle_t)*(num_protos < 2 ? 2 : num_protos)); for (i = 0; i < num_protos; i++) { if ( ! (h->handles[i] = find_dissector(protos[i])) ) { h->handles[i] = data_handle; *err = ep_strdup_printf("Could not find dissector for: '%s'",protos[i]); return; } } *err = NULL; }
static int call_dop_oid_callback(char *base_string, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *col_info) { char* binding_param; binding_param = ep_strdup_printf("%s.%s", base_string, binding_type ? binding_type : ""); if (col_info && (check_col(pinfo->cinfo, COL_INFO))) col_append_fstr(pinfo->cinfo, COL_INFO, " %s", col_info); if (dissector_try_string(dop_dissector_table, binding_param, tvb, pinfo, tree)) { offset += tvb_length_remaining (tvb, offset); } else { proto_item *item=NULL; proto_tree *next_tree=NULL; item = proto_tree_add_text(tree, tvb, 0, tvb_length_remaining(tvb, offset), "Dissector for parameter %s OID:%s not implemented. Contact Wireshark developers if you want this supported", base_string, binding_type ? binding_type : "<empty>"); if (item) { next_tree = proto_item_add_subtree(item, ett_dop_unknown); } offset = dissect_unknown_ber(pinfo, tvb, offset, next_tree); expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "Unknown binding-parameter"); } return offset; }
static void xmpp_error(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, element_t *element) { proto_item *error_item; proto_tree *error_tree; element_t *text_element, *cond_element; attr_info attrs_info[] = { {"type", hf_xmpp_error_type, TRUE, TRUE, NULL, NULL}, {"code", hf_xmpp_error_code, FALSE, TRUE, NULL, NULL}, {"condition", hf_xmpp_error_condition, TRUE, TRUE, NULL, NULL} /*TODO: validate list to the condition element*/ }; gchar *error_info; attr_t *fake_condition = NULL; error_info = ep_strdup("Stanza error"); error_item = proto_tree_add_item(tree, hf_xmpp_error, tvb, element->offset, element->length, FALSE); error_tree = proto_item_add_subtree(error_item, ett_xmpp_query_item); cond_element = steal_element_by_attr(element, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas"); if(cond_element) { fake_condition = ep_init_attr_t(cond_element->name, cond_element->offset, cond_element->length); g_hash_table_insert(element->attrs,"condition", fake_condition); error_info = ep_strdup_printf("%s: %s;", error_info, cond_element->name); } display_attrs(error_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); while((text_element = steal_element_by_name(element, "text")) != NULL) { xmpp_error_text(error_tree, tvb, text_element); error_info = ep_strdup_printf("%s Text: %s", error_info, text_element->data?text_element->data->value:""); } expert_add_info_format(pinfo, error_item, PI_RESPONSE_CODE, PI_CHAT,"%s", error_info); xmpp_unknown(error_tree, tvb, pinfo, element); }
/* dissect a bt dht values list from tvb, start at offset. it's like "l6:....6:....e" */ static int dissect_bt_dht_values(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, char **result, char *label ) { proto_item *ti; proto_tree *sub_tree; proto_item *value_ti; proto_tree *value_tree; address addr; guint peer_index; guint string_len_start; guint string_len; guint16 port; ti = proto_tree_add_item( tree, hf_bt_dht_peers, tvb, offset, 0, ENC_NA ); sub_tree = proto_item_add_subtree( ti, ett_bt_dht_peers); peer_index = 0; /* we has confirmed that the first byte is 'l' */ offset += 1; /* dissect bt-dht values */ while( tvb_get_guint8(tvb,offset)!='e' ) { string_len_start = offset; while( tvb_get_guint8(tvb,offset) != ':' ) offset += 1; string_len = atoi( tvb_get_ephemeral_string(tvb,string_len_start,offset-string_len_start) ); /* skip the ':' */ offset += 1; /* 4 bytes ip, 2 bytes port */ for( ; string_len>=6; string_len-=6, offset+=6 ) { peer_index += 1; SET_ADDRESS( &addr, AT_IPv4, 4, tvb_get_ptr( tvb, offset, 4) ); port = tvb_get_letohl( tvb, offset+4 ); value_ti = proto_tree_add_none_format( sub_tree, hf_bt_dht_peer, tvb, offset, 6, "%d\t%s:%u", peer_index, ep_address_to_str( &addr ), port ); value_tree = proto_item_add_subtree( value_ti, ett_bt_dht_peers); proto_tree_add_item( value_tree, hf_ip, tvb, offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item( value_tree, hf_port, tvb, offset+4, 2, ENC_BIG_ENDIAN); } /* truncated data */ if( string_len>0 ) { proto_tree_add_item( tree, hf_truncated_data, tvb, offset, string_len, ENC_NA ); offset += string_len; } } proto_item_set_text( ti, "%s: %d peers", label, peer_index ); col_append_fstr( pinfo->cinfo, COL_INFO, "reply=%d peers ", peer_index ); *result = ep_strdup_printf("%d peers", peer_index); return offset; }
static guint8 *unhexbytes(const char *si, guint len, guint *len_p, const char** err) { guint8 *buf; guint8 *p; const guint8 *s = (const guint8 *)si; guint i; if (len % 2) { *err = ep_strdup_printf("Uneven number of chars hex string %u \n'%s'", len, si); return NULL; } buf = (guint8 *)ep_alloc(len/2+1); p = buf; for (i = 0; i<len ; i += 2) { guint8 lo = s[i+1]; guint8 hi = s[i]; if (hi >= '0' && hi <= '9') { hi -= '0'; } else if (hi >= 'a' && hi <= 'f') { hi -= 'a'; hi += 0xa; } else if (hi >= 'A' && hi <= 'F') { hi -= 'A'; hi += 0xa; } else { goto on_error; } if (lo >= '0' && lo <= '9') { lo -= '0'; } else if (lo >= 'a' && lo <= 'f') { lo -= 'a'; lo += 0xa; } else if (lo >= 'A' && lo <= 'F') { lo -= 'A'; lo += 0xa; } else { goto on_error; } *(p++) = (hi*0x10) + lo; } len /= 2; if (len_p) *len_p = len; buf[len] = '\0'; *err = NULL; return buf; on_error: *err = "Error parsing hex string"; return NULL; }
static void xmpp_failure_text(proto_tree *tree, tvbuff_t *tvb, element_t *element) { attr_t *lang = get_attr(element,"xml:lang"); proto_tree_add_text(tree, tvb, element->offset, element->length, "TEXT%s: %s", lang?ep_strdup_printf("(%s)",lang->value):"", element->data?element->data->value:""); }
static void uat_key_record_update_cb(void* r, const char** err) { uat_key_record_t* rec = (uat_key_record_t *)r; if (rec->string == NULL) { *err = ep_strdup_printf("Key can't be blank"); } else { g_strstrip(rec->string); if (rec->string[0] != 0) { *err = NULL; if ( !zbee_security_parse_key(rec->string, rec->key, rec->byte_order) ) { *err = ep_strdup_printf("Expecting %d hexadecimal bytes or\n" "a %d character double-quoted string", ZBEE_SEC_CONST_KEYSIZE, ZBEE_SEC_CONST_KEYSIZE); } } else { *err = ep_strdup_printf("Key can't be blank"); } } }
static int dissect_bt_dht_nodes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, char **result, char *label ) { proto_item *ti; proto_tree *sub_tree; proto_item *node_ti; proto_tree *node_tree; guint node_index; guint string_len_start; guint string_len; address addr; guint16 port; guint8 *id; ti = proto_tree_add_item( tree, hf_bt_dht_nodes, tvb, offset, 0, ENC_NA ); sub_tree = proto_item_add_subtree( ti, ett_bt_dht_nodes); node_index = 0; string_len_start = offset; while( tvb_get_guint8(tvb,offset) != ':' ) offset += 1; string_len = atoi( tvb_get_ephemeral_string(tvb,string_len_start,offset-string_len_start) ); /* skip the ':' */ offset += 1; /* 20 bytes id, 4 bytes ip, 2 bytes port */ for( ; string_len>=26; string_len-=26, offset+=26 ) { node_index += 1; id = tvb_bytes_to_str(tvb, offset, 20 ); SET_ADDRESS( &addr, AT_IPv4, 4, tvb_get_ptr( tvb, offset, 4) ); port = tvb_get_letohl( tvb, offset+24 ); node_ti = proto_tree_add_none_format( sub_tree, hf_bt_dht_node, tvb, offset, 26, "%d\t%s %s:%u", node_index, id, ep_address_to_str( &addr ), port ); node_tree = proto_item_add_subtree( node_ti, ett_bt_dht_peers); proto_tree_add_item( node_tree, hf_bt_dht_id, tvb, offset, 20, ENC_NA); proto_tree_add_item( node_tree, hf_ip, tvb, offset+20, 4, ENC_BIG_ENDIAN); proto_tree_add_item( node_tree, hf_port, tvb, offset+24, 2, ENC_BIG_ENDIAN); } if( string_len>0 ) { proto_tree_add_item( tree, hf_truncated_data, tvb, offset, string_len, ENC_NA ); offset += string_len; } proto_item_set_text( ti, "%s: %d nodes", label, node_index ); col_append_fstr( pinfo->cinfo, COL_INFO, "reply=%d nodes ", node_index ); *result = ep_strdup_printf("%d", node_index); return offset; }
WSLUA_METAMETHOD Listener_tostring(lua_State* L) { Listener tap = checkListener(L,1); gchar* str; if (!tap) return 0; str = ep_strdup_printf("Listener(%s) filter: %s",tap->name, tap->filter ? tap->filter : "NONE"); lua_pushstring(L,str); return 1; }
static int ProgDlg__tostring(lua_State* L) { ProgDlg pd = checkProgDlg(L,1); if (pd) { lua_pushstring(L,ep_strdup_printf("%sstopped",pd->stopped?"":"not ")); } else { luaL_error(L, "ProgDlg__tostring has being passed something else!"); } return 0; }
WSLUA_METAMETHOD Tvb__tostring(lua_State* L) { /* Convert the bytes of a Tvb into a string, to be used for debugging purposes as '...' will be appended in case the string is too long. */ Tvb tvb = checkTvb(L,1); int len; gchar* str; len = tvb_length(tvb->ws_tvb); str = ep_strdup_printf("TVB(%i) : %s",len,tvb_bytes_to_ep_str(tvb->ws_tvb,0,len)); lua_pushstring(L,str); WSLUA_RETURN(1); /* The string. */ }
static const gchar * key_to_val(const gchar *key, int keylen, const value_string_keyval *kv, const gchar *fmt) { int i = 0; while (kv[i].key) { if (!strncmp(kv[i].key, key, keylen)) { return(kv[i].val); } i++; } return ep_strdup_printf(fmt, key); }
/* Tries to match val against each element in the value_string array vs. Returns the associated string ptr on a match. Formats val with fmt, and returns the resulting string, on failure. */ const gchar* str_to_str(const gchar *val, const string_string *vs, const char *fmt) { const gchar *ret; g_assert(fmt != NULL); ret = match_strstr(val, vs); if (ret != NULL) return ret; return ep_strdup_printf(fmt, val); }
gchar* gcp_msg_to_str(gcp_msg_t* m, gboolean persistent) { gcp_trx_msg_t* t; gchar* s = ""; if ( !m ) return "-"; for (t = m->trxs; t; t = t->next) { s = ep_strdup_printf("%s %s",s,gcp_trx_to_str(m,t->trx, persistent)); } return s; }
gchar * p_get_proto_name_and_key(wmem_allocator_t *scope, struct _packet_info* pinfo, guint pfd_index){ frame_proto_data *temp; if (scope == pinfo->pool) { temp = (frame_proto_data*)g_slist_nth_data(pinfo->proto_data, pfd_index); } else { temp = (frame_proto_data*)g_slist_nth_data(pinfo->fd->pfd, pfd_index); } return ep_strdup_printf("[%s, key %u]",proto_get_protocol_name(temp->proto), temp->key); }
WSLUA_METAMETHOD Listener__tostring(lua_State* L) { /* Generates a string of debug info for the tap listener */ Listener tap = checkListener(L,1); gchar* str; if (!tap) return 0; str = ep_strdup_printf("Listener(%s) filter: %s",tap->name, tap->filter ? tap->filter : "NONE"); lua_pushstring(L,str); return 1; }