1 /* 2 * Copyright (C) 2011 VoIP Embedded, Inc. 3 * 4 * This file is part of Kamailio, a free SIP server. 5 * 6 * Kamailio is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version 10 * 11 * Kamailio is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 */ 21 22 23 #ifndef _XHTTP_RPC_H 24 #define _XHTTP_RPC_H 25 26 #include "../../core/str.h" 27 #include "../../core/rpc_lookup.h" 28 #include "../../core/parser/msg_parser.h" 29 30 31 #define ERROR_REASON_BUF_LEN 1024 32 #define PRINT_VALUE_BUF_LEN 256 33 34 35 36 struct rpc_data_struct { 37 struct rpc_ctx* ctx; 38 struct rpc_data_struct* next; 39 }; 40 41 42 /** Representation of the xhttp_rpc reply being constructed. 43 * 44 * This data structure describes the xhttp_rpc reply that is being constructed 45 * and will be sent to the client. 46 */ 47 struct xhttp_rpc_reply { 48 int code; /**< Reply code which indicates the type of the reply */ 49 str reason; /**< Reason phrase text which provides human-readable 50 * description that augments the reply code */ 51 str body; /**< The xhttp_rpc http body built so far */ 52 str buf; /**< The memory buffer allocated for the reply, this is 53 * where the body attribute of the structure points to */ 54 }; 55 56 57 /** The context of the xhttp_rpc request being processed. 58 * 59 * This is the data structure that contains all data related to the xhttp_rpc 60 * request being processed, such as the reply code and reason, data to be sent 61 * to the client in the reply, and so on. 62 * 63 * There is always one context per xhttp_rpc request. 64 */ 65 typedef struct rpc_ctx { 66 sip_msg_t* msg; /**< The SIP/HTTP received message. */ 67 struct xhttp_rpc_reply reply; /**< xhttp_rpc reply to be sent to the client */ 68 int reply_sent; 69 int mod; /**< Module being processed */ 70 int cmd; /**< RPC command being processed */ 71 int arg_received; /**< RPC argument flag */ 72 str arg; /**< RPC command argument */ 73 str arg2scan; /**< RPC command args to be parsed */ 74 struct rpc_struct *structs; 75 struct rpc_data_struct *data_structs; 76 unsigned int struc_depth; 77 } rpc_ctx_t; 78 79 80 /* An RPC module representation. 81 * 82 * The module is the first substring of the RPC commands (delimited by '.'. 83 */ 84 typedef struct xhttp_rpc_mod_cmds_ { 85 int rpc_e_index; /**< Index to the first module RPC rec in rpc_sarray */ 86 str mod; /**< Module name */ 87 int size; /**< Number of commands provided by the above module */ 88 } xhttp_rpc_mod_cmds_t; 89 90 #endif 91 92