SIP API Developer's Guide

Header Lookup Functions

const struct sip_header *sip_get_header(sip_msg_t sip_msg, char *header_name, sip_header_t old_header, int *error);

The sip_get_header() function obtains the SIP message header that is specified by the value of the header_name parameter. If the value of the header_name parameter is NULL, the function returns the first header of the SIP message. If the value of the old_header parameter is not NULL, the function searches for a header that matches the value of the header_name parameter. This search begins from the header specified by the value of the old_header parameter. For example, to search for the first VIA header, use VIA as the value for the header_name parameter and NULL as the value for the old_header parameter. To get the next VIA header from the message, use the value of the sip_header parameter that the previous call to the sip_get_header() function returned as the value of the old_header parameter. This function ignores headers that are marked as deleted. A lookup for a deleted header returns a result of NULL unless the message has another header of the same name that is not marked as deleted. The value of the header_name parameter can be either the long or the compact name.

The value of the error parameter is set to zero when this function completes successfully. When this function completes unsuccessfully, it sets the value of the error parameter to the appropriate error value. If the value of the sip_msg parameter is null, the function sets the value of the error parameter to EINVAL. If the function cannot find the header, it sets the value of the error parameter to ENOENT.