summaryrefslogtreecommitdiff
path: root/src/ua.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-10-31 19:53:31 +0100
committerAlfred E. Heggestad <aeh@db.org>2015-10-31 19:53:31 +0100
commit7c2feeeafb9ffb672697872adda0bdb155df53bc (patch)
tree4aca3982dd8ce04741bdd63d38885eb15c5be69f /src/ua.c
parent136f8543e65e29fea1538fa7cd9a4dbdd533a6eb (diff)
presence: use struct sipevent_sock instance from core
- remove own instance of "struct sipevent_sock" in notifier - add a new handler uag_set_sub_handler for incoming SUBSCRIBE messages after this patch there should be only 1 global instance of sipevent_sock, in ua.c -- this patch will also fix a bug where sipevent could not find the subscription/notification and replies with 481
Diffstat (limited to 'src/ua.c')
-rw-r--r--src/ua.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/ua.c b/src/ua.c
index 424a2a1..3ffdcd2 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -57,6 +57,7 @@ static struct {
bool use_tcp; /**< Use TCP transport */
bool use_tls; /**< Use TLS transport */
bool prefer_ipv6; /**< Force IPv6 transport */
+ sip_msg_h *subh;
#ifdef USE_TLS
struct tls *tls; /**< TLS Context */
#endif
@@ -1286,6 +1287,26 @@ static const struct cmd cmdv[] = {
};
+static bool sub_handler(const struct sip_msg *msg, void *arg)
+{
+ struct ua *ua;
+
+ (void)arg;
+
+ ua = uag_find(&msg->uri.user);
+ if (!ua) {
+ warning("subscribe: no UA found for %r\n", &msg->uri.user);
+ (void)sip_treply(NULL, uag_sip(), msg, 404, "Not Found");
+ return true;
+ }
+
+ if (uag.subh)
+ uag.subh(msg, ua);
+
+ return true;
+}
+
+
/**
* Initialise the User-Agents
*
@@ -1347,7 +1368,8 @@ int ua_init(const char *software, bool udp, bool tcp, bool tls,
if (err)
goto out;
- err = sipevent_listen(&uag.evsock, uag.sip, bsize, bsize, NULL, NULL);
+ err = sipevent_listen(&uag.evsock, uag.sip, bsize, bsize,
+ sub_handler, NULL);
if (err)
goto out;
@@ -1841,6 +1863,12 @@ void uag_event_unregister(ua_event_h *h)
}
+void uag_set_sub_handler(sip_msg_h *subh)
+{
+ uag.subh = subh;
+}
+
+
void uag_current_set(struct ua *ua)
{
uag.ua_cur = ua;