1 /* 2 eXosip - This is the eXtended osip library. 3 Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com 4 5 eXosip is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 eXosip is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 In addition, as a special exception, the copyright holders give 20 permission to link the code of portions of this program with the 21 OpenSSL library under certain conditions as described in each 22 individual source file, and distribute linked combinations 23 including the two. 24 You must obey the GNU General Public License in all respects 25 for all of the code used other than OpenSSL. If you modify 26 file(s) with this exception, you may extend this exception to your 27 version of the file(s), but you are not obligated to do so. If you 28 do not wish to do so, delete this exception statement from your 29 version. If you delete this exception statement from all source 30 files in the program, then also delete it here. 31 */ 32 33 #ifdef ENABLE_MPATROL 34 #include <mpatrol.h> 35 #endif 36 37 #ifndef __EX_SUBSCRIBE_H__ 38 #define __EX_SUBSCRIBE_H__ 39 40 #include <osipparser2/osip_parser.h> 41 #include <time.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @file eX_subscribe.h 49 * @brief eXosip subscribe request API 50 * 51 * This file provide the API needed to control SUBSCRIBE requests. You can use it to: 52 * 53 * <ul> 54 * <li>build SUBSCRIBE requests.</li> 55 * <li>send SUBSCRIBE requests.</li> 56 * <li>build SUBSCRIBE answers.</li> 57 * <li>send SUBSCRIBE answers.</li> 58 * </ul> 59 */ 60 61 /** 62 * @defgroup eXosip2_subscribe eXosip2 SUBSCRIBE and outgoing subscriptions 63 * @ingroup eXosip2_msg 64 * @{ 65 */ 66 67 /** 68 * Structure for subscription status 69 * @enum eXosip_ss 70 */ 71 enum eXosip_ss { 72 EXOSIP_SUBCRSTATE_UNKNOWN, /**< unknown subscription-state */ 73 EXOSIP_SUBCRSTATE_PENDING, /**< pending subscription-state */ 74 EXOSIP_SUBCRSTATE_ACTIVE, /**< active subscription-state */ 75 EXOSIP_SUBCRSTATE_TERMINATED /**< terminated subscription-state */ 76 }; 77 78 /** 79 * Structure for subscription reason 80 * @enum eXosip_ss_reason 81 */ 82 enum eXosip_ss_reason { 83 DEACTIVATED, /**< deactivated for subscription-state */ 84 PROBATION, /**< probation for subscription-state */ 85 REJECTED, /**< rejected for subscription-state */ 86 TIMEOUT, /**< timeout for subscription-state */ 87 GIVEUP, /**< giveup for subscription-state */ 88 NORESOURCE /**< noresource for subscription-state */ 89 }; 90 91 /** 92 * Structure for notification status 93 * @enum eXosip_ss_status 94 */ 95 enum eXosip_ss_status { 96 EXOSIP_NOTIFY_UNKNOWN, /**< unknown state for subscription */ 97 EXOSIP_NOTIFY_PENDING, /**< subscription not yet accepted */ 98 EXOSIP_NOTIFY_ONLINE, /**< online status */ 99 EXOSIP_NOTIFY_BUSY, /**< busy status */ 100 EXOSIP_NOTIFY_BERIGHTBACK, 101 /**< be right back status */ 102 EXOSIP_NOTIFY_AWAY, /**< away status */ 103 EXOSIP_NOTIFY_ONTHEPHONE, /**< on the phone status */ 104 EXOSIP_NOTIFY_OUTTOLUNCH, /**< out to lunch status */ 105 EXOSIP_NOTIFY_CLOSED /**< closed status */ 106 }; 107 108 #ifndef MINISIZE 109 110 /** 111 * Build a default initial SUBSCRIBE request. 112 * 113 * @param excontext eXosip_t instance. 114 * @param subscribe Pointer for the SIP request to build. 115 * @param to SIP url for callee. 116 * @param from SIP url for caller. 117 * @param route Route header for SUBSCRIBE. (optional) 118 * @param event Event header for SUBSCRIBE. 119 * @param expires Expires header for SUBSCRIBE. 120 */ 121 int eXosip_subscription_build_initial_subscribe(struct eXosip_t *excontext, osip_message_t **subscribe, const char *to, const char *from, const char *route, const char *event, int expires); 122 123 /** 124 * Build a default initial REFER request. 125 * 126 * @param excontext eXosip_t instance. 127 * @param refer Pointer for the SIP request to build. 128 * @param to SIP url for callee. 129 * @param from SIP url for caller. 130 * @param route Route header for REFER. (optional) 131 * @param refer_to SIP url for transfer. 132 */ 133 int eXosip_subscription_build_initial_refer(struct eXosip_t *excontext, osip_message_t **refer, const char *to, const char *from, const char *route, const char *refer_to); 134 135 /** 136 * Send an initial SUBSCRIBE/REFER request. 137 * 138 * @param excontext eXosip_t instance. 139 * @param subscribe SIP SUBSCRIBE message to send. 140 */ 141 int eXosip_subscription_send_initial_request(struct eXosip_t *excontext, osip_message_t *subscribe); 142 143 /** 144 * Build a default new SUBSCRIBE/REFER refresh message. 145 * 146 * @param excontext eXosip_t instance. 147 * @param did identifier of the subscription. 148 * @param sub Pointer for the SIP request to build. 149 */ 150 int eXosip_subscription_build_refresh_request(struct eXosip_t *excontext, int did, osip_message_t **sub); 151 152 /** 153 * Send a new SUBSCRIBE/REFER refresh request. 154 * 155 * @param excontext eXosip_t instance. 156 * @param did identifier of the subscription. 157 * @param sub SIP SUBSCRIBE message to send. 158 */ 159 int eXosip_subscription_send_refresh_request(struct eXosip_t *excontext, int did, osip_message_t *sub); 160 161 /** 162 * Remove outgoing subscription context. 163 * 164 * @param excontext eXosip_t instance. 165 * @param did identifier of the subscription. 166 */ 167 int eXosip_subscription_remove(struct eXosip_t *excontext, int did); 168 169 /** @} */ 170 171 /** 172 * @defgroup eXosip2_notify eXosip2 SUBSCRIBE and incoming subscriptions 173 * @ingroup eXosip2_msg 174 * @{ 175 */ 176 177 /** 178 * Build answer for an SUBSCRIBE request. 179 * 180 * @param excontext eXosip_t instance. 181 * @param tid id of SUBSCRIBE transaction. 182 * @param status status for SIP answer to build. 183 * @param answer The SIP answer to build. 184 */ 185 int eXosip_insubscription_build_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t **answer); 186 187 /** 188 * Send answer for an SUBSCRIBE request. 189 * 190 * @param excontext eXosip_t instance. 191 * @param tid id of SUBSCRIBE transaction. 192 * @param status status for SIP answer to send. 193 * @param answer The SIP answer to send. (default will be sent if NULL) 194 */ 195 int eXosip_insubscription_send_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t *answer); 196 197 /** 198 * Build a request within subscription. 199 * 200 * @param excontext eXosip_t instance. 201 * @param did id of incoming subscription. 202 * @param method request method to build. 203 * @param request The SIP request to build. 204 */ 205 int eXosip_insubscription_build_request(struct eXosip_t *excontext, int did, const char *method, osip_message_t **request); 206 207 /** 208 * Build a NOTIFY request within subscription. 209 * 210 * @param excontext eXosip_t instance. 211 * @param did id of incoming subscription. 212 * @param subscription_status subscription status (pending, active, terminated) 213 * @param subscription_reason subscription reason 214 * @param request The SIP request to build. 215 */ 216 int eXosip_insubscription_build_notify(struct eXosip_t *excontext, int did, int subscription_status, int subscription_reason, osip_message_t **request); 217 218 /** 219 * Send a request within subscription. 220 * 221 * @param excontext eXosip_t instance. 222 * @param did id of incoming subscription. 223 * @param request The SIP request to send. 224 */ 225 int eXosip_insubscription_send_request(struct eXosip_t *excontext, int did, osip_message_t *request); 226 227 /** 228 * Remove incoming subscription context. 229 * 230 * @param excontext eXosip_t instance. 231 * @param did identifier of the subscription. 232 */ 233 int eXosip_insubscription_remove(struct eXosip_t *excontext, int did); 234 235 #endif 236 237 /** @} */ 238 239 #ifdef __cplusplus 240 } 241 #endif 242 #endif 243