Logo Search packages:      
Sourcecode: sofia-sip version File versions  Download package

sip_call_id_t* sip_call_id_create ( su_home_t home,
char const *  domain 
)

Create a header object.

Create a Call-ID header object with a new unique value. It uses su_guid_generate() function to generate the value. If the local host name domain is specified, it is prepended to the generated value instead of local MAC address.

Parameters:
home memory home
domain local domain name
Returns:
A pointer to newly created header object when successful or NULL upon an error.
See also:
su_guid_generate(), su_guid_sprintf()

Definition at line 1124 of file sip_basic.c.

References su_guid_generate(), su_guid_sprintf(), and su_guid_strlen.

Referenced by nta_leg_tcreate().

{
  sip_call_id_t *i;
  size_t xtra = su_guid_strlen + 1 + (domain ? strlen(domain) + 1 : 0);

  i = (sip_call_id_t *)sip_header_alloc(home, sip_call_id_class, xtra);

  if (i) {
    char *b;
    su_guid_t guid[1];

    i->i_id = b = (char *)(i + 1);

    su_guid_generate(guid);
    /*
     * Guid looks like "NNNNNNNN-NNNN-NNNN-NNNN-XXXXXXXXXXXX"
     * where NNNNNNNN-NNNN-NNNN-NNNN is timestamp and XX is MAC address
     * (but we use usually random ID for MAC because we do not have
     *  guid generator available for all processes within node)
     */
    su_guid_sprintf(b, su_guid_strlen + 1, guid);

    /* If we have a domain name don't include MAC address at the end of guid */
    if (domain) {
      b[8 + 5 + 5 + 5] = '@';
      strcpy(b + 8 + 5 + 5 + 5 + 1, domain);
    }

    i->i_hash = msg_hash_string(i->i_id);
  }

  return i;

}


Generated by  Doxygen 1.6.0   Back to index