/src/rtpproxy/src/commands/rpcpv1_ul_subc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2006-2020 Sippy Software, Inc., http://www.sippysoft.com |
3 | | * |
4 | | * Redistribution and use in source and binary forms, with or without |
5 | | * modification, are permitted provided that the following conditions |
6 | | * are met: |
7 | | * 1. Redistributions of source code must retain the above copyright |
8 | | * notice, this list of conditions and the following disclaimer. |
9 | | * 2. Redistributions in binary form must reproduce the above copyright |
10 | | * notice, this list of conditions and the following disclaimer in the |
11 | | * documentation and/or other materials provided with the distribution. |
12 | | * |
13 | | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
14 | | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
16 | | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
17 | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
18 | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
19 | | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
20 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
21 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
22 | | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
23 | | * SUCH DAMAGE. |
24 | | * |
25 | | */ |
26 | | |
27 | | #include <sys/socket.h> |
28 | | #include <stdint.h> |
29 | | #include <stdlib.h> |
30 | | |
31 | | #include "config_pp.h" |
32 | | |
33 | | #include "rtpp_types.h" |
34 | | #include "rtpp_cfg.h" |
35 | | #include "rtpp_util.h" |
36 | | #include "rtpp_modman.h" |
37 | | #include "rtpp_command.h" |
38 | | #include "rtpp_command_args.h" |
39 | | #include "rtpp_command_sub.h" |
40 | | #include "rtpp_command_private.h" |
41 | | #include "commands/rpcpv1_ul.h" |
42 | | #include "commands/rpcpv1_ul_subc.h" |
43 | | #include "commands/rpcpv1_delete.h" |
44 | | |
45 | | int |
46 | | rtpp_subcommand_ul_opts_parse(const struct rtpp_cfg *cfsp, |
47 | | const struct rtpp_command_args *subc_args, struct after_success_h *asp) |
48 | 209 | { |
49 | 209 | int mod_id, inst_id; |
50 | 209 | const char *cp; |
51 | | |
52 | 209 | switch(subc_args->v[0].s[0]) { |
53 | 131 | case 'M': |
54 | 180 | case 'm': |
55 | 180 | if (atoi_safe_sep(&subc_args->v[0].s[1], &mod_id, ':', &cp) != ATOI_OK) |
56 | 19 | return (-1); |
57 | 161 | if (atoi_safe(cp, &inst_id) != ATOI_OK) |
58 | 5 | return (-1); |
59 | 156 | if (mod_id < 1 || inst_id < 1) |
60 | 78 | return (-1); |
61 | 78 | if (CALL_METHOD(cfsp->modules_cf, get_ul_subc_h, (unsigned)mod_id, |
62 | 78 | (unsigned)inst_id, asp) != 0) |
63 | 59 | return (-1); |
64 | 19 | break; |
65 | | |
66 | 19 | case 'D': |
67 | 27 | case 'd': |
68 | 27 | if (subc_args->c != 1) |
69 | 2 | return (-1); |
70 | 25 | asp->args.dyn = rtpp_command_del_opts_parse(NULL, subc_args); |
71 | 25 | if (asp->args.dyn == NULL) |
72 | 1 | return (-1); |
73 | 24 | asp->args.stat = (void *)cfsp; |
74 | 24 | asp->handler = handle_delete_as_subc; |
75 | 24 | break; |
76 | | |
77 | 2 | default: |
78 | 2 | return (-1); |
79 | 209 | } |
80 | 43 | return (0); |
81 | 209 | } |