Libexosip2 (1-3) -- how-to send or update registrations.

Source: Internet
Author: User

How-to send or update registrations.

The extented exosip Stack

Initiate a registration

To start a registration, you need to build a default register request by providing several mandatory headers.

You can start as your registration you want even in one exosip_t context.

Osip_message_t * Reg = NULL;

Int RID;

Int I;

Exosip_lock (CTX );

Rid = exosip_register_build_initial_register (CTX, "SIP: [email protected]", "sip.antisip.com", null, 1800, & reg );

If (RID <0)

{

Exosip_unlock (CTX );

Return-1;

}

Osip_message_set_supported (Reg, "100rel ");

Osip_message_set_supported (Reg, "path ");

I = exosip_register_send_register (CTX, RID, Reg );

Exosip_unlock (CTX );

Return I;

The returned element of exosip_register_build_initial_register is the registration identifier that you can use to update your registration. In future events about this registration, you'll see that registration identifier when applicable.

Contact headers in register

You shoshould let exosip2 manage contact headers alone. The setup you have provided will generate varous behavior, all being controlled by exosip2. see the "Nat and Contact Header" section in Setup documentation.

Set Password (s )!

Usually, you will need a login/password to access a service!

Exosip can be used to access several service at the same time and thus the Realm (identify the service) needs to be provided if you are using several services in the same instance.

The simple way when you use one service with username being the same as the login:

Exosip_lock (CTX );

Exosip_add_authentication_info (CTX, login, login, passwd, null, null );

Exosip_unlock (CTX );

Or the complete way:

Exosip_lock (CTX );

Exosip_add_authentication_info (CTX, login, login, passwd, null, "sip.antisip.com ");

Exosip_add_authentication_info (CTX, from_username, login, passwd, null, "otherservice.com ");

Exosip_unlock (CTX );

Delete all registration

This feature is not advised by SIP specification, but it exists for some purpose & reasons! You can send "*" in contact header of a register to ask for immediate removal of all active registrations for a participant sip agent:

Rid = exosip_register_build_initial_register (CTX, "SIP: [email protected]", "sip.antisip.com", "*", 1800, & reg );

Update a registration

You just need to reuse the Registry identifier:

Int I;

Exosip_lock (CTX );

I = exosip_register_build_register (CTX, RID, 1800, & reg );

If (I <0)

{

Exosip_unlock (CTX );

Return-1;

}

Exosip_register_send_register (CTX, RID, Reg );

Exosip_unlock (CTX );

Note: The above Code also shows that the stack is sometimes able to build and send a default SIP messages with only one API call

Closing the registration

A softphone shoshould delete its registration on the SIP server when terminating. To do so, you have to send a register request with the Expires header set to value "0 ".

The same Code as for updating a registration is used with 0 instead of 1800 for the expiration delay.

Int I;

Exosip_lock (CTX );

I = exosip_register_build_register (CTX, RID, 0, & reg );

If (I <0)

{

Exosip_unlock (CTX );

Return-1;

}

Exosip_register_send_register (CTX, RID, Reg );

Exosip_unlock (CTX );

Discard registration Context

If you need to delete a context without sending a register with expires 0, you can use exosip_register_remove to release memory.

Int I;

Exosip_lock (CTX );

I = exosip_register_remove (CTX, RID );

If (I = 0 ){

}

Exosip_unlock (CTX );

Libexosip2 (1-3) -- how-to send or update registrations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.