コード例 #1
1
ファイル: sip_uri.c プロジェクト: RockHardJim/idphone
static pj_ssize_t pjsip_name_addr_print(pjsip_uri_context_e context,
                                        const pjsip_name_addr *name,
                                        char *buf, pj_size_t size)
{
    int printed;
    char *startbuf = buf;
    char *endbuf = buf + size;
    pjsip_uri *uri;

    uri = (pjsip_uri*) pjsip_uri_get_uri(name->uri);
    pj_assert(uri != NULL);

    if (context != PJSIP_URI_IN_REQ_URI) {
        if (name->display.slen) {
            if (endbuf-buf < 8) return -1;
            *buf++ = '"';
            copy_advance(buf, name->display);
            *buf++ = '"';
            *buf++ = ' ';
        }
        *buf++ = '<';
    }

    printed = pjsip_uri_print(context,uri, buf, size-(buf-startbuf));
    if (printed < 1)
        return -1;
    buf += printed;

    if (context != PJSIP_URI_IN_REQ_URI) {
        *buf++ = '>';
    }

    *buf = '\0';
    return buf-startbuf;
}
コード例 #2
0
ファイル: custom_headers.cpp プロジェクト: jmmL/sprout
int pjsip_accept_contact_hdr_print_on(void* void_hdr,
                                      char* buf,
                                      pj_size_t size)
{
  int printed;
  char *startbuf = buf;
  char *endbuf = buf + size;
  pjsip_accept_contact_hdr* hdr = (pjsip_accept_contact_hdr *)void_hdr;
  const pjsip_parser_const_t *pc = pjsip_parser_const();

  /* Route and Record-Route don't compact forms */
  copy_advance(buf, hdr->name);
  copy_advance(buf, pj_str(": *"));

  printed = pjsip_param_print_on(&hdr->feature_set, buf, endbuf-buf,
                                 &pc->pjsip_TOKEN_SPEC,
                                 &pc->pjsip_TOKEN_SPEC, ';');
  if (printed < 0)
  {
    return -1;
  }
  buf += printed;

  if (hdr->explicit_match)
  {
    copy_advance(buf, pj_str(";explicit"));
  }

  if (hdr->required_match)
  {
    copy_advance(buf, pj_str(";require"));
  }

  return buf-startbuf;
}
コード例 #3
0
static int pjsip_www_authenticate_hdr_print( pjsip_www_authenticate_hdr *hdr,
					     char *buf, pj_size_t size)
{
    int printed;
    char *startbuf = buf;
    char *endbuf = buf + size;

    copy_advance(buf, hdr->name);
    *buf++ = ':';
    *buf++ = ' ';

    copy_advance(buf, hdr->scheme);
    *buf++ = ' ';

    if (pj_stricmp2(&hdr->scheme, "digest") == 0)
	printed = print_digest_challenge(&hdr->challenge.digest, buf, endbuf - buf);
    else if (pj_stricmp2(&hdr->scheme, "pgp") == 0)
	printed = print_pgp_challenge(&hdr->challenge.pgp, buf, endbuf - buf);
    else {
	pj_assert(0);
	return -1;
    }

    if (printed == -1)
	return -1;

    buf += printed;
    *buf = '\0';
    return (int)(buf-startbuf);
}
コード例 #4
0
static int pjsip_authorization_hdr_print( pjsip_authorization_hdr *hdr,
					  char *buf, pj_size_t size)
{
    int printed;
    char *startbuf = buf;
    char *endbuf = buf + size;

    copy_advance(buf, hdr->name);
    *buf++ = ':';
    *buf++ = ' ';

    copy_advance(buf, hdr->scheme);
    *buf++ = ' ';

    if (pj_stricmp(&hdr->scheme, &pjsip_DIGEST_STR) == 0)
    {
	printed = print_digest_credential(&hdr->credential.digest, buf, endbuf - buf);
    } 
    else if (pj_stricmp(&hdr->scheme, &pjsip_PGP_STR) == 0)
    {
	printed = print_pgp_credential(&hdr->credential.pgp, buf, endbuf - buf);
    } 
    else {
	pj_assert(0);
	return -1;
    }

    if (printed == -1)
	return -1;

    buf += printed;
    *buf = '\0';
    return (int)(buf-startbuf);
}
コード例 #5
0
ファイル: sip_replaces.c プロジェクト: max3903/SFLphone
static int replaces_hdr_print( pjsip_replaces_hdr *hdr, 
			       char *buf, pj_size_t size)
{
    char *p = buf;
    char *endbuf = buf+size;
    int printed;
    const pjsip_parser_const_t *pc = pjsip_parser_const();

    copy_advance(p, hdr->name);
    *p++ = ':';
    *p++ = ' ';

    copy_advance(p, hdr->call_id);
    copy_advance_pair(p, ";to-tag=", 8, hdr->to_tag);
    copy_advance_pair(p, ";from-tag=", 10, hdr->from_tag);

    if (hdr->early_only) {
	const pj_str_t str_early_only = { ";early-only", 11 };
	copy_advance(p, str_early_only);
    }
    
    printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p,
				   &pc->pjsip_TOKEN_SPEC, 
				   &pc->pjsip_TOKEN_SPEC, ';');
    if (printed < 0)
	return printed;

    p += printed;
    return p - buf;
}
コード例 #6
0
ファイル: custom_headers.cpp プロジェクト: jmmL/sprout
int identity_hdr_print(pjsip_routing_hdr* hdr,
                       char* buf,
                       pj_size_t size)
{
  int printed;
  char *startbuf = buf;
  char *endbuf = buf + size;
  const pjsip_parser_const_t *pc = pjsip_parser_const();

  /* Route and Record-Route don't compact forms */
  copy_advance(buf, hdr->name);
  *buf++ = ':';
  *buf++ = ' ';

  printed = pjsip_uri_print(PJSIP_URI_IN_ROUTING_HDR,
                            &hdr->name_addr,
                            buf,
                            endbuf-buf);
  if (printed < 1)
  {
    return -1; // LCOV_EXCL_LINE
  }
  buf += printed;

  printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf,
                                 &pc->pjsip_TOKEN_SPEC,
                                 &pc->pjsip_TOKEN_SPEC, ';');
  if (printed < 0)
  {
    return -1; // LCOV_EXCL_LINE
  }
  buf += printed;

  return buf-startbuf;
}
コード例 #7
0
ファイル: custom_headers.cpp プロジェクト: jmmL/sprout
int pjsip_reject_contact_hdr_print_on(void* void_hdr,
                                      char* buf,
                                      pj_size_t size)
{
  int printed;
  char *startbuf = buf;
  char *endbuf = buf + size;
  pjsip_reject_contact_hdr* hdr = (pjsip_reject_contact_hdr *)void_hdr;
  const pjsip_parser_const_t *pc = pjsip_parser_const();

  /* Route and Record-Route don't compact forms */
  copy_advance(buf, hdr->name);
  *buf++ = ':';
  *buf++ = ' ';
  *buf++ = '*';

  printed = pjsip_param_print_on(&hdr->feature_set, buf, endbuf-buf,
                                 &pc->pjsip_TOKEN_SPEC,
                                 &pc->pjsip_TOKEN_SPEC, ';');
  if (printed < 0)
  {
    return -1;
  }
  buf += printed;

  return buf-startbuf;
}
コード例 #8
0
ファイル: sip_timer.c プロジェクト: Archipov/android-client
/*
 * Min-SE header vptr.
 */
static int min_se_hdr_print(pjsip_min_se_hdr *hdr, 
			    char *buf, pj_size_t size)
{
    char *p = buf;
    char *endbuf = buf+size;
    pj_ssize_t printed;
    const pjsip_parser_const_t *pc = pjsip_parser_const();

    /* Print header name and value */
    if ((endbuf - p) < (hdr->name.slen + 16))
	return -1;

    copy_advance(p, hdr->name);
    *p++ = ':';
    *p++ = ' ';

    printed = pj_utoa(hdr->min_se, p);
    p += printed;

    /* Print generic params */
    printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p,
				   &pc->pjsip_TOKEN_SPEC, 
				   &pc->pjsip_TOKEN_SPEC, ';');
    if (printed < 0)
	return (int)printed;

    p += printed;
    return (int)(p - buf);
}
コード例 #9
0
ファイル: sip_timer.c プロジェクト: Archipov/android-client
/*
 * Session-Expires header vptr.
 */
static int se_hdr_print(pjsip_sess_expires_hdr *hdr, 
			char *buf, pj_size_t size)
{
    char *p = buf;
    char *endbuf = buf+size;
    pj_ssize_t printed;
    const pjsip_parser_const_t *pc = pjsip_parser_const();
    const pj_str_t *hname = pjsip_use_compact_form? &hdr->sname : &hdr->name;

    /* Print header name and value */
    if ((endbuf - p) < (hname->slen + 16))
	return -1;

    copy_advance(p, (*hname));
    *p++ = ':';
    *p++ = ' ';

    printed = pj_utoa(hdr->sess_expires, p);
    p += printed;

    /* Print 'refresher' param */
    if (hdr->refresher.slen)
    {
	if  ((endbuf - p) < (STR_REFRESHER.slen + 2 + hdr->refresher.slen))
	    return -1;

	*p++ = ';';
	copy_advance(p, STR_REFRESHER);
	*p++ = '=';
	copy_advance(p, hdr->refresher);
    }

    /* Print generic params */
    printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p,
				   &pc->pjsip_TOKEN_SPEC, 
				   &pc->pjsip_TOKEN_SPEC, ';');
    if (printed < 0)
	return (int)printed;

    p += printed;
    return (int)(p - buf);
}
コード例 #10
0
ファイル: sip_uri.c プロジェクト: RockHardJim/idphone
static pj_ssize_t other_uri_print(pjsip_uri_context_e context,
                                  const pjsip_other_uri *uri,
                                  char *buf, pj_size_t size)
{
    char *startbuf = buf;
    char *endbuf = buf + size;

    PJ_UNUSED_ARG(context);

    if (uri->scheme.slen + uri->content.slen + 1 > (int)size)
        return -1;

    /* Print scheme. */
    copy_advance(buf, uri->scheme);
    *buf++ = ':';

    /* Print content. */
    copy_advance(buf, uri->content);

    return (buf - startbuf);
}
コード例 #11
0
ファイル: evsub_msg.c プロジェクト: batk0/pjsip
static int pjsip_event_hdr_print( pjsip_event_hdr *hdr, 
				  char *buf, pj_size_t size)
{
    char *p = buf;
    char *endbuf = buf+size;
    pj_ssize_t printed;
    const pjsip_parser_const_t *pc = pjsip_parser_const();

    copy_advance(p, hdr->name);
    *p++ = ':';
    *p++ = ' ';

    copy_advance(p, hdr->event_type);
    copy_advance_pair(p, ";id=", 4, hdr->id_param);
    
    printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p,
				   &pc->pjsip_TOKEN_SPEC, 
				   &pc->pjsip_TOKEN_SPEC, ';');
    if (printed < 0)
	return (int)printed;

    p += printed;
    return (int)(p - buf);
}
コード例 #12
0
/* Print tel: URI */
static pj_ssize_t tel_uri_print( pjsip_uri_context_e context,
				 const pjsip_tel_uri *uri, 
				 char *buf, pj_size_t size)
{
    int printed;
    char *startbuf = buf;
    char *endbuf = buf+size-1;
    const pjsip_parser_const_t *pc = pjsip_parser_const();

    PJ_UNUSED_ARG(context);

    /* Print scheme. */
    copy_advance(buf, pc->pjsip_TEL_STR);
    *buf++ = ':';

    /* Print number. */
    copy_advance_escape(buf, uri->number, pjsip_TEL_NUMBER_SPEC);

    /* ISDN sub-address or extension must appear first. */

    /* Extension param. */
    copy_advance_pair_escape(buf, ";ext=", 5, uri->ext_param, 
			     pjsip_TEL_EXT_VALUE_SPEC);

    /* ISDN sub-address. */
    copy_advance_pair_escape(buf, ";isub=", 6, uri->isub_param, 
			     pjsip_TEL_URIC_SPEC);

    /* Followed by phone context, if present. */
    copy_advance_pair_escape(buf, ";phone-context=", 15, uri->context, 
			     pjsip_TEL_PHONE_CONTEXT_SPEC);


    /* Print other parameters. */
    printed = (int)pjsip_param_print_on(&uri->other_param, buf, (endbuf-buf), 
					&pjsip_TEL_PNAME_SPEC, 
					&pjsip_TEL_PVALUE_SPEC, ';');
    if (printed < 0)
	return -1;
    buf += printed;

    *buf = '\0';

    return (buf-startbuf);
}
コード例 #13
0
ファイル: evsub_msg.c プロジェクト: batk0/pjsip
static int pjsip_sub_state_hdr_print(pjsip_sub_state_hdr *hdr, 
				     char *buf, pj_size_t size)
{
    char *p = buf;
    char *endbuf = buf+size;
    pj_ssize_t printed;
    const pjsip_parser_const_t *pc = pjsip_parser_const();

    copy_advance(p, hdr->name);
    *p++ = ':';
    *p++ = ' ';

    copy_advance_escape(p, hdr->sub_state, pc->pjsip_TOKEN_SPEC);
    copy_advance_pair_escape(p, ";reason=", 8, hdr->reason_param,
			     pc->pjsip_TOKEN_SPEC);
    if (hdr->expires_param >= 0) {
	pj_memcpy(p, ";expires=", 9);
	p += 9;
	printed = pj_utoa(hdr->expires_param, p);
	p += printed;
    }
    if (hdr->retry_after >= 0) {
	pj_memcpy(p, ";retry-after=", 13);
	p += 13;
	printed = pj_utoa(hdr->retry_after, p);
	p += printed;
    }
    
    printed = pjsip_param_print_on( &hdr->other_param, p, endbuf-p, 
				    &pc->pjsip_TOKEN_SPEC,
				    &pc->pjsip_TOKEN_SPEC,
				    ';');
    if (printed < 0)
	return (int)printed;

    p += printed;

    return (int)(p - buf);
}
コード例 #14
0
ファイル: sip_uri.c プロジェクト: RockHardJim/idphone
PJ_DEF(pj_ssize_t) pjsip_param_print_on( const pjsip_param *param_list,
        char *buf, pj_size_t size,
        const pj_cis_t *pname_spec,
        const pj_cis_t *pvalue_spec,
        int sep)
{
    const pjsip_param *p;
    char *startbuf;
    char *endbuf;
    int printed;

    p = param_list->next;
    if (p == NULL || p == param_list)
        return 0;

    startbuf = buf;
    endbuf = buf + size;

    PJ_UNUSED_ARG(pname_spec);

    do {
        *buf++ = (char)sep;
        copy_advance_escape(buf, p->name, (*pname_spec));
        if (p->value.slen) {
            *buf++ = '=';
            if (*p->value.ptr == '"')
                copy_advance(buf, p->value);
            else
                copy_advance_escape(buf, p->value, (*pvalue_spec));
        }
        p = p->next;
        if (sep == '?') sep = '&';
    } while (p != param_list);

    return buf-startbuf;
}