view libsip/get_header.c @ 152:7176dc850d7a

sip-in hold/retr error handling: simply send BYE Because we know that the SIP state is CONNECTED at the time of any such error event, we can call initiate_bye() instead of disconnect_sip(), and thereby get rid of struct gsm_mncc_cause which will never be used in this scenario anyway.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 11 Oct 2022 16:11:21 -0800
parents 5427b26525cd
children
line wrap: on
line source

/*
 * In this module we implement functions for retrieving individual
 * header fields from struct sip_pkt_rx.
 */

#include <string.h>
#include <strings.h>
#include "parse.h"

char *
get_single_header(msg, name, altname, dupp)
	struct sip_pkt_rx *msg;
	char *name, *altname;
	int *dupp;
{
	unsigned n;
	char *ret;

	for (n = 0; n < msg->num_hdr_fields; n++) {
		if (!strcasecmp(msg->hdr_fields[n].field_name, name))
			break;
		if (altname &&
		    !strcasecmp(msg->hdr_fields[n].field_name, altname))
			break;
	}
	if (n >= msg->num_hdr_fields)
		return 0;
	ret = msg->hdr_fields[n].field_value;
	if (!dupp)
		return ret;
	for (n++; n < msg->num_hdr_fields; n++) {
		if (!strcasecmp(msg->hdr_fields[n].field_name, name))
			*dupp = 1;
		if (altname &&
		    !strcasecmp(msg->hdr_fields[n].field_name, altname))
			*dupp = 1;
	}
	return ret;
}