1 /*
2  * Copyright (c) 2004-2006 Maxim Sobolev <sobomax@FreeBSD.org>
3  * Copyright (c) 2006-2014 Sippy Software, Inc., http://www.sippysoft.com
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _RTPP_COMMAND_PRIVATE_H_
30 #define _RTPP_COMMAND_PRIVATE_H_
31 
32 struct rtpp_command_stat {
33     uint64_t cnt;
34     int cnt_idx;
35 };
36 
37 struct rtpp_command_stats {
38     struct rtpp_command_stat ncmds_rcvd;
39     struct rtpp_command_stat ncmds_rcvd_ndups;
40     struct rtpp_command_stat ncmds_succd;
41     struct rtpp_command_stat ncmds_errs;
42     struct rtpp_command_stat ncmds_repld;
43 
44     struct rtpp_command_stat nsess_complete;
45     struct rtpp_command_stat nsess_created;
46 
47     struct rtpp_command_stat nplrs_created;
48     struct rtpp_command_stat nplrs_destroyed;
49 };
50 
51 #define RTPC_MAX_ARGC   20
52 
53 enum rtpp_cmd_op {DELETE, RECORD, PLAY, NOPLAY, COPY, UPDATE, LOOKUP, INFO,
54   QUERY, VER_FEATURE, GET_VER, DELETE_ALL, GET_STATS};
55 
56 struct common_cmd_args {
57     enum rtpp_cmd_op op;
58     const char *rname;
59     const char *hint;
60     char *call_id;
61     char *from_tag;
62     char *to_tag;
63 };
64 
65 struct rtpp_command
66 {
67     char buf[1024 * 8];
68     char buf_t[256];
69     char *argv[RTPC_MAX_ARGC];
70     int argc;
71     struct sockaddr_storage raddr;
72     struct sockaddr *laddr;
73     socklen_t rlen;
74     double dtime;
75     struct rtpp_command_stats *csp;
76     struct common_cmd_args cca;
77     int no_glock;
78     struct rtpp_session *sp;
79 };
80 
81 #define ECODE_CMDUNKN      0
82 
83 #define ECODE_PARSE_NARGS  1
84 #define ECODE_PARSE_MODS   2
85 
86 #define ECODE_PARSE_1      5
87 #define ECODE_PARSE_2      6
88 #define ECODE_PARSE_3      7
89 #define ECODE_PARSE_4      8
90 #define ECODE_PARSE_5      9
91 #define ECODE_PARSE_10    10
92 #define ECODE_PARSE_11    11
93 #define ECODE_PARSE_12    12
94 #define ECODE_PARSE_13    13
95 #define ECODE_PARSE_14    14
96 #define ECODE_PARSE_15    15
97 #define ECODE_PARSE_16    16
98 #define ECODE_PARSE_6     17
99 #define ECODE_PARSE_7     18
100 #define ECODE_PARSE_8     19
101 
102 #define ECODE_RTOOBIG_1   25
103 #define ECODE_RTOOBIG_2   26
104 
105 #define ECODE_INVLARG_1   31
106 #define ECODE_INVLARG_2   32
107 #define ECODE_INVLARG_3   33
108 #define ECODE_INVLARG_4   34
109 #define ECODE_INVLARG_5   35
110 #define ECODE_INVLARG_6   36
111 
112 #define ECODE_SESUNKN     50
113 
114 #define ECODE_PLRFAIL     60
115 #define ECODE_QRYFAIL     62
116 #define ECODE_CPYFAIL     65
117 #define ECODE_STSFAIL     68
118 
119 #define ECODE_LSTFAIL_1   71
120 #define ECODE_LSTFAIL_2   72
121 
122 #define ECODE_NOMEM_1     81
123 #define ECODE_NOMEM_2     82
124 #define ECODE_NOMEM_3     83
125 #define ECODE_NOMEM_4     84
126 #define ECODE_NOMEM_5     85
127 #define ECODE_NOMEM_6     86
128 #define ECODE_NOMEM_7     87
129 #define ECODE_NOMEM_8     88
130 
131 #define ECODE_SLOWSHTDN   99
132 
133 #endif
134