Beispiel #1
0
static int mwi_subscribe(struct ua *ua)
{
    const char *routev[1];
    struct mwi *mwi;
    int err;

    mwi = mem_zalloc(sizeof(*mwi), destructor);
    if (!mwi)
        return ENOMEM;

    list_append(&mwil, &mwi->le, mwi);
    mwi->ua = ua;

    routev[0] = ua_outbound(ua);

    info("mwi: subscribing to messages for %s\n", ua_aor(ua));

    err = sipevent_subscribe(&mwi->sub, uag_sipevent_sock(), ua_aor(ua),
                             NULL, ua_aor(ua), "message-summary", NULL,
                             600, ua_cuser(ua),
                             routev, routev[0] ? 1 : 0,
                             auth_handler, ua_prm(ua), true, NULL,
                             notify_handler, close_handler, mwi,
                             "Accept:"
                             " application/simple-message-summary\r\n");
    if (err) {
        warning("mwi: subscribe ERROR: %m\n", err);
    }

    if (err)
        mem_deref(mwi);

    return err;
}
Beispiel #2
0
static int subscribe(struct presence *pres)
{
	const char *routev[1];
	struct ua *ua;
	char uri[256];
	int err;

	/* We use the first UA */
	ua = uag_find_aor(NULL);
	if (!ua) {
		warning("presence: no UA found\n");
		return ENOENT;
	}

	pl_strcpy(&contact_addr(pres->contact)->auri, uri, sizeof(uri));

	routev[0] = ua_outbound(ua);

	err = sipevent_subscribe(&pres->sub, uag_sipevent_sock(), uri, NULL,
				 ua_aor(ua), "presence", NULL, 600,
				 ua_cuser(ua), routev, routev[0] ? 1 : 0,
				 auth_handler, ua_prm(ua), true, NULL,
				 notify_handler, close_handler, pres,
				 "%H", ua_print_supported, ua);
	if (err) {
		warning("presence: sipevent_subscribe failed: %m\n", err);
	}

	return err;
}
Beispiel #3
0
int sip_req_send(struct ua *ua, const char *method, const char *uri,
                 sip_resp_h *resph, void *arg, const char *fmt, ...)
{
    const char *routev[1];
    struct sip_req *sr;
    int err;

    info("baresip.sipreq.sip_req_send()\n");

    if (!ua || !method || !uri || !fmt)
        return EINVAL;

    routev[0] = ua_outbound(ua);

    sr = mem_zalloc(sizeof(*sr), destructor);
    if (!sr)
        return ENOMEM;

    sr->resph = resph;
    sr->arg   = arg;

    err = str_dup(&sr->method, method);

    if (fmt) {
        va_list ap;

        va_start(ap, fmt);
        err |= re_vsdprintf(&sr->fmt, fmt, ap);
        va_end(ap);
    }

    if (err)
        goto out;

    err = sip_dialog_alloc(&sr->dlg, uri, uri, NULL, ua_aor(ua),
                           routev[0] ? routev : NULL,
                           routev[0] ? 1 : 0);
    if (err)
        goto out;

    err = sip_auth_alloc(&sr->auth, auth_handler, ua_prm(ua), true);
    if (err)
        goto out;

    err = request(sr);

out:
    if (err)
        mem_deref(sr);

    return err;
}
Beispiel #4
0
static int send_invite(struct call *call)
{
	const char *routev[1];
	struct mbuf *desc;
	int err;

	routev[0] = ua_outbound(call->ua);

	err = call_sdp_get(call, &desc, true);
	if (err)
		return err;

	err = sipsess_connect(&call->sess, uag_sipsess_sock(),
			      call->peer_uri,
			      call->local_name,
			      call->local_uri,
			      ua_cuser(call->ua),
			      routev[0] ? routev : NULL,
			      routev[0] ? 1 : 0,
			      "application/sdp", desc,
			      auth_handler, call->acc, true,
			      sipsess_offer_handler, sipsess_answer_handler,
			      sipsess_progr_handler, sipsess_estab_handler,
			      sipsess_info_handler, sipsess_refer_handler,
			      sipsess_close_handler, call,
			      "Allow: %s\r\n%H", uag_allowed_methods(),
			      ua_print_supported, call->ua);
	if (err) {
		warning("call: sipsess_connect: %m\n", err);
	}

	/* save call setup timer */
	call->time_conn = time(NULL);

	mem_deref(desc);

	return err;
}