File: debugger_act.c

package info (click to toggle)
kamailio 4.2.0-2%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (146 lines) | stat: -rw-r--r-- 4,419 bytes parent folder | download | duplicates (4)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
 * $Id$
 *
 * Copyright (C) 2010 Daniel-Constantin Mierla (asipto.com)
 *
 * This file is part of Kamailio, a free SIP server.
 *
 * This file 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 file 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include "../../dprint.h"
#include "../../sr_module.h"

#include "debugger_act.h"

typedef struct _dbg_action {
	int type;
	str name;
} dbg_action_t;

static str _dbg_action_special[] = {
	str_init("unknown"),   /* 0 */
	str_init("exit"),      /* 1 */
	str_init("drop"),      /* 2 */
	str_init("return"),    /* 3 */
	{0, 0}
};

static dbg_action_t _dbg_action_list[] = {
	{ FORWARD_T, str_init("forward") },
	{ LOG_T, str_init("log") },
	{ ERROR_T, str_init("error") },
	{ ROUTE_T, str_init("route") },
	{ EXEC_T, str_init("exec") },
	{ SET_HOST_T, str_init("sethost") },
	{ SET_HOSTPORT_T, str_init("sethostport") },
	{ SET_USER_T, str_init("setuser") },
	{ SET_USERPASS_T, str_init("setuserpass") },
	{ SET_PORT_T, str_init("setport") },
	{ SET_URI_T, str_init("seturi") },
	{ SET_HOSTPORTTRANS_T, str_init("sethostporttrans") },
	{ SET_HOSTALL_T, str_init("sethostall") },
	{ SET_USERPHONE_T, str_init("setuserphone") },
	{ IF_T, str_init("if") },
	{ SWITCH_T, str_init("switch") },
	{ BLOCK_T, str_init("block") },
	{ EVAL_T, str_init("eval") },
	{ SWITCH_JT_T, str_init("switch") },
	{ SWITCH_COND_T, str_init("switch") },
	{ MATCH_COND_T, str_init("case") },
	{ WHILE_T, str_init("while") },
	{ SETFLAG_T, str_init("setflag") },
	{ RESETFLAG_T, str_init("resetflag") },
	{ ISFLAGSET_T, str_init("isflagset") },
	{ AVPFLAG_OPER_T, str_init("avpflag") },
	{ LEN_GT_T, str_init("lengt") },
	{ PREFIX_T, str_init("prefix") },
	{ STRIP_T, str_init("strip") },
	{ STRIP_TAIL_T, str_init("striptail") },
	{ APPEND_BRANCH_T, str_init("append_branch") },
	{ REVERT_URI_T, str_init("reverturi") },
	{ FORWARD_TCP_T, str_init("forward_tcp") },
	{ FORWARD_UDP_T, str_init("forward_udp") },
	{ FORWARD_TLS_T, str_init("forward_tls") },
	{ FORWARD_SCTP_T, str_init("forward_sctp") },
	{ FORCE_RPORT_T, str_init("force_rport") },
	{ ADD_LOCAL_RPORT_T, str_init("add_local_rport") },
	{ SET_ADV_ADDR_T, str_init("set_adv_addr") },
	{ SET_ADV_PORT_T, str_init("set_adv_port") },
	{ FORCE_TCP_ALIAS_T, str_init("force_tcp_alias") },
	{ LOAD_AVP_T, str_init("load_avp") },
	{ AVP_TO_URI_T, str_init("avp_to_uri") },
	{ FORCE_SEND_SOCKET_T, str_init("force_send_socket") },
	{ ASSIGN_T, str_init("assign") },
	{ ADD_T, str_init("add") },
	{ UDP_MTU_TRY_PROTO_T, str_init("udp_mtu_try_proto") },
	{ SET_FWD_NO_CONNECT_T, str_init("set_fwd_no_connect") },
	{ SET_RPL_NO_CONNECT_T, str_init("set_rpl_no_connect") },
	{ SET_FWD_CLOSE_T, str_init("set_fwd_close") },
	{ SET_RPL_CLOSE_T, str_init("set_rpl_close") },
	{ 0, {0, 0} }
};

str* dbg_get_action_name(struct action *a)
{
	int i;
	static str aname;
	cmd_export_common_t *cmd;

	if(a==NULL)
		return &_dbg_action_special[0];

	switch(a->type) {
		case DROP_T:
			if(a->val[1].u.number&DROP_R_F)
				return &_dbg_action_special[2];
			if(a->val[1].u.number&RETURN_R_F)
				return &_dbg_action_special[3];
			return &_dbg_action_special[1];
		case MODULE0_T:
		case MODULE1_T:
		case MODULE2_T:
		case MODULE3_T:
		case MODULE4_T:
		case MODULE5_T:
		case MODULE6_T:
		case MODULEX_T:
		case MODULE1_RVE_T:
		case MODULE2_RVE_T:
		case MODULE3_RVE_T:
		case MODULE4_RVE_T:
		case MODULE5_RVE_T:
		case MODULE6_RVE_T:
		case MODULEX_RVE_T:
			cmd = (cmd_export_common_t*)(a->val[0].u.data);
			aname.s = cmd->name;
			aname.len = strlen(aname.s);
			return &aname;
		default:
			for(i=0; _dbg_action_list[i].type!=0; i++)
			{
				if(_dbg_action_list[i].type==a->type)
					return &_dbg_action_list[i].name;
			}
	}

	return &_dbg_action_special[0];
}