compare client id is now a two step procedure:

first we go for contact header. If present in both cases (stored in
registration table AND in INVITE / OK frame, then use it, otherwise fall
back to IP addresses.
This commit is contained in:
Thomas Ries 2007-06-08 19:41:49 +00:00
parent f6b0b49bf9
commit 5ff32070f5
2 changed files with 18 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* -*- Mode: C; c-basic-offset: 3 -*-
Copyright (C) 2002-2005 Thomas Ries <tries@gmx.net>
/*
Copyright (C) 2002-2007 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
@ -111,7 +111,7 @@ int proxy_request (sip_ticket_t *ticket) {
/*
* logging of passing calls
*/
/*&&&& this should be moved to its own loggin plugin */
/*&&&& this should be moved to its own logging plugin */
if (configuration.log_calls) {
osip_uri_t *from_url = NULL;
osip_uri_t *to_url = NULL;
@ -1036,10 +1036,12 @@ if (configuration.debuglevel)
*
*/
memset(&client_id, 0, sizeof(client_id));
/* get the Contact Header if present */
osip_message_get_contact(mymsg, 0, &contact);
osip_contact_to_str(contact, &tmp);
strcpy(client_id.contact, tmp);
if (contact) osip_contact_to_str(contact, &tmp);
if (tmp) strncpy(client_id.contact, tmp, CLIENT_ID_SIZE-1);
/* store the IP address of the sender */
memcpy(&client_id.from_ip, &ticket->from.sin_addr,

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2002-2005 Thomas Ries <tries@gmx.net>
Copyright (C) 2002-2007 Thomas Ries <tries@gmx.net>
This file is part of Siproxd.
@ -528,14 +528,21 @@ int createpidfile(char *pidfilename) {
/*
* compare_client_id:
* Compares two client_id_t structures. If both have the Contact item
* defined (not NULL), then compare it and return.
* If one (or both) do NOT have the contact item defined, then
* fall back on comparing the from_ip (IP address).
*
*
* returns:
* STS_SUCCESS on match
* STS_FAILURE on no match
*/
int compare_client_id(client_id_t cid1, client_id_t cid2) {
/* Prio 1: Contact - if present */
/* Prio 1: Contact - if present in both structures */
if ((cid1.contact[0] != '\0') && (cid2.contact[0] != '\0')) {
if (strcmp(cid1.contact, cid2.contact) == 0) {
if (strncmp(cid1.contact, cid2.contact, CLIENT_ID_SIZE) == 0) {
DEBUGC(DBCLASS_BABBLE, "compare_client_id: contact match [%s]",
cid1.contact);
return STS_SUCCESS;