SIP Witch 1.9.15: voip.h Source File

SIP Witch 1.9.15
voip.h
Go to the documentation of this file.
1 // Copyright (C) 2008-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef _SIPWITCH_VOIP_H_
18 #define _SIPWITCH_VOIP_H_
19 
20 #pragma GCC diagnostic ignored "-Wvariadic-macros"
21 #undef HAVE_CONFIG_H
22 
23 #ifdef WIN32
24 #undef alloca
25 #endif
26 
27 #include <eXosip2/eXosip.h>
28 #undef WARNING
29 #undef CONTACT
30 
31 #ifndef _UCOMMON_PLATFORM_H_
32 #include <ucommon/platform.h>
33 #endif
34 
35 #ifndef _SIPWITCH_NAMESPACE_H_
36 #include <sipwitch/namespace.h>
37 #endif
38 
39 namespace sipwitch {
40 
41 #if defined(EXOSIP_OPT_BASE_OPTION) && !defined(EXOSIP_OPT_DONT_SEND_101)
42 #define EXOSIP_API4
43 #endif
44 
45  class __EXPORT voip
46 {
47 public:
48  #ifdef EXOSIP_API4
49  typedef eXosip_t *context_t;
50  inline static void lock(context_t ctx) {eXosip_lock(ctx);}
51  inline static void unlock(context_t ctx) {eXosip_unlock(ctx);}
52  #else
53   typedef void *context_t;
54   inline static void lock(context_t ctx) {eXosip_lock();}
55   inline static void unlock(context_t ctx) {eXosip_unlock();}
56  #endif
57 
58   typedef eXosip_event_t *event_t;
59   typedef int reg_t; // registration id
60   typedef int tid_t; // transaction id
61   typedef int did_t; // dialog id
62   typedef int call_t; // call id
63   typedef osip_header_t *hdr_t;
64   typedef osip_message_t *msg_t;
65   typedef osip_contact_t *contact_t;
66   typedef osip_uri_param_t *uri_param_t;
67   typedef osip_body_t *body_t;
68   typedef osip_content_type_t *ctype_t;
69   typedef osip_from_t *from_t;
70   typedef osip_via_t *via_t;
71   typedef osip_to_t *to_t;
72   typedef osip_uri_t *uri_t;
73   typedef unsigned long timeout_t;
74   typedef osip_authorization_t *auth_t;
75   typedef osip_generic_param_t *param_t;
76   typedef osip_proxy_authenticate_t *proxyauth_t;
77 
78  static bool make_request_message(context_t ctx, const char *method, const char *to, const char *from, msg_t *msg, const char *route = NULL);
79  static bool make_response_message(context_t ctx, tid_t tid, int status, msg_t *msg);
80  static void send_request_message(context_t ctx, msg_t msg);
81  static void send_response_message(context_t ctx, tid_t tid, int status, msg_t msg = NULL);
82 
83  static bool make_options_response(context_t ctx, tid_t tid, int status, msg_t *msg);
84  static void send_options_response(context_t ctx, tid_t tid, int status, msg_t msg = NULL);
85 
86  static bool make_invite_request(context_t ctx, const char *to, const char *from, const char *subject, msg_t *msg, const char *route = NULL);
87  static call_t send_invite_request(context_t ctx, msg_t msg);
88 
89  static bool make_answer_response(context_t ctx, tid_t tid, int status, msg_t *msg);
90  static void send_answer_response(context_t ctx, tid_t tid, int status, msg_t msg = NULL);
91 
92  static void release_call(context_t ctx, call_t cid, did_t did);
93 
94  static bool make_dialog_request(context_t ctx, did_t did, const char *method, msg_t *msg);
95  static bool make_dialog_notify(context_t ctx, did_t did, int status, msg_t *msg);
96  static bool make_dialog_update(context_t ctx, did_t did, msg_t *msg);
97  static bool make_dialog_refer(context_t ctx, did_t did, const char *to, msg_t *msg);
98  static bool make_dialog_info(context_t ctx, did_t did, msg_t *msg);
99  static bool make_dialog_options(context_t ctx, did_t did, msg_t *msg);
100  static void send_dialog_message(context_t ctx, did_t did, msg_t msg);
101 
102  static bool make_ack_message(context_t ctx, did_t did, msg_t *msg);
103  static void send_ack_message(context_t ctx, did_t did, msg_t msg = NULL);
104 
105  static bool make_prack_message(context_t ctx, tid_t tid, msg_t *msg);
106  static void send_prack_message(context_t ctx, tid_t tid, msg_t msg);
107 
108  static reg_t make_registry_request(context_t ctx, const char *uri, const char *s, const char *c, unsigned exp, msg_t *msg);
109  static void send_registry_request(context_t ctx, reg_t rid, msg_t msg);
110  static bool release_registry(context_t ctx, reg_t rid);
111 
112  static void add_authentication(context_t ctx, const char *user, const char *secret, const char *realm, bool automatic = false);
113 
114  static void default_action(context_t ctx, event_t ev);
115  static void automatic_action(context_t ctx);
116 
117  static bool publish(context_t ctx, const char *uri, const char *contact, const char *event, const char *duration, const char *type, const char *body);
118 
119  static event_t get_event(context_t ctx, timeout_t timeout);
120  static void call_reference(context_t ctx, call_t cid, void *route);
121  static void free_message_request(context_t ctx, voip::msg_t msg);
122  static void release_event(event_t ev);
123  static void option(context_t ctx, int opt, const void *value);
124 
125  static bool listen(context_t ctx, int proto = IPPROTO_UDP, const char *iface = NULL, unsigned port = 5060, bool tls = false);
126  static void create(context_t *ctx, const char *agent, int family = AF_INET);
127  static void release(context_t ctx);
128  static void show(msg_t msg);
129  static void header(msg_t msg, const char *key, const char *value);
130  static void attach(msg_t msg, const char *type, const char *body);
131  static void attach(msg_t msg, const char *type, const char *body, size_t size);
132 
133  static void server_allows(voip::msg_t msg);
134  static void server_accepts(voip::msg_t msg);
135  static void server_supports(voip::msg_t msg, const char *txt);
136  static void server_requires(voip::msg_t msg, const char *txt);
137 };
138 
139 #ifndef SESSION_EXPIRES
140  #define SESSION_EXPIRES "session-expires"
141 #endif
142 
143 #ifndef ALLOW_EVENTS
144  #define ALLOW_EVENTS "allow-events"
145 #endif
146 
147 #ifndef SESSION_EVENT
148  #define SESSION_EVENT "event"
149 #endif
150 
151  #define SDP_BODY "application/sdp"
152 
153 // private sipwitch headers...
154 
155  #define P_SIPWITCH_NODE "P-sipwitch-node" // internodal calling
156  #define P_SIPWITCH_FEATURE "P-sipwitch-feat" // feature code reply
157 
158 } // namespace sipwitch
159 
160 #endif
sipwitch::voip::lock
static void lock(context_t ctx)
Definition: voip.h:54
osip_message
Structure for SIP Message (REQUEST and RESPONSE).
Definition: osip_message.h:55
sipwitch::uri
Some convenience methods for manipulating SIP uri's.
Definition: uri.h:55
sipwitch::voip::uri_param_t
osip_uri_param_t * uri_param_t
Definition: voip.h:66
sipwitch::voip::ctype_t
osip_content_type_t * ctype_t
Definition: voip.h:68
sipwitch::voip::body_t
osip_body_t * body_t
Definition: voip.h:67
sipwitch::voip::param_t
osip_generic_param_t * param_t
Definition: voip.h:75
sipwitch::voip::unlock
static void unlock(context_t ctx)
Definition: voip.h:55
eXosip_lock
int eXosip_lock(struct eXosip_t *excontext)
Lock the eXtented oSIP library.
eXosip_event
Structure for event description.
Definition: eXosip.h:359
sipwitch::voip::timeout_t
unsigned long timeout_t
Definition: voip.h:73
sipwitch::voip::contact_t
osip_contact_t * contact_t
Definition: voip.h:65
osip_body
Structure for holding Body.
Definition: osip_body.h:48
osip_content_type
Definition of the Content-Type header.
Definition: osip_content_type.h:47
sipwitch::voip::call_t
int call_t
Definition: voip.h:62
sipwitch::voip::via_t
osip_via_t * via_t
Definition: voip.h:70
sipwitch::voip::tid_t
int tid_t
Definition: voip.h:60
sipwitch::voip::proxyauth_t
osip_proxy_authenticate_t * proxyauth_t
Definition: voip.h:76
sipwitch::voip::to_t
osip_to_t * to_t
Definition: voip.h:71
namespace.h
GNU SIP Witch library namespace.
sipwitch::voip::from_t
osip_from_t * from_t
Definition: voip.h:69
sipwitch::voip::event_t
eXosip_event_t * event_t
Definition: voip.h:58
eXosip_unlock
int eXosip_unlock(struct eXosip_t *excontext)
UnLock the eXtented oSIP library.
sipwitch::voip::uri_t
osip_uri_t * uri_t
Definition: voip.h:72
osip_from
Definition of the From header.
Definition: osip_from.h:48
value
char * value[96]
Definition: cgiserver.cpp:90
sipwitch::voip::auth_t
osip_authorization_t * auth_t
Definition: voip.h:74
osip_header
Definition of a generic sip header.
Definition: osip_header.h:52
osip_via
Definition of the Via header.
Definition: osip_via.h:47
sipwitch::voip::context_t
void * context_t
Definition: voip.h:53
sipwitch::voip::did_t
int did_t
Definition: voip.h:61
eXosip.h
eXosip API
sipwitch::voip::reg_t
int reg_t
Definition: voip.h:59
sipwitch::voip::msg_t
osip_message_t * msg_t
Definition: voip.h:64
osip_authorization
Definition of the Authorization header.
Definition: osip_authorization.h:46
osip_uri_param
Structure for referencing url parameters.
Definition: osip_uri.h:55
osip_uri
Structure for referencing SIP urls.
Definition: osip_uri.h:167
osip_www_authenticate
Definition of the WWW-Authenticate header.
Definition: osip_www_authenticate.h:46
sipwitch::voip::hdr_t
osip_header_t * hdr_t
Definition: voip.h:63

Generated on Dec 21, 2017 for sipwitch-1.9.15 (*.h and *.cpp), libosip2-5.0.0 (*.h) and libeXosip2-4.0.0 (*.h), by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /