Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
belle-sip
Commits
356cc400
Commit
356cc400
authored
Dec 15, 2010
by
jehan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add from and to header implementation
parent
fc163f88
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
483 additions
and
218 deletions
+483
-218
include/belle-sip/belle-sip.h
include/belle-sip/belle-sip.h
+11
-1
include/belle-sip/headers.h
include/belle-sip/headers.h
+73
-14
include/belle-sip/list.h
include/belle-sip/list.h
+16
-5
include/belle-sip/parameters.h
include/belle-sip/parameters.h
+46
-0
include/belle-sip/uri.h
include/belle-sip/uri.h
+2
-1
src/belle_sip_headers_impl.c
src/belle_sip_headers_impl.c
+56
-30
src/belle_sip_internal.h
src/belle_sip_internal.h
+65
-15
src/belle_sip_message.g
src/belle_sip_message.g
+55
-66
src/belle_sip_object.c
src/belle_sip_object.c
+5
-1
src/belle_sip_parameters.c
src/belle_sip_parameters.c
+82
-0
src/belle_sip_uri_impl.c
src/belle_sip_uri_impl.c
+25
-65
src/belle_sip_utils.c
src/belle_sip_utils.c
+5
-5
tester/belle_sip_headers_tester.c
tester/belle_sip_headers_tester.c
+31
-4
tester/belle_sip_uri_tester.c
tester/belle_sip_uri_tester.c
+11
-11
No files found.
include/belle-sip/belle-sip.h
View file @
356cc400
...
...
@@ -28,6 +28,14 @@ typedef enum belle_sip_type_id{
BELLE_SIP_TYPE_ID
(
belle_sip_server_transaction_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_client_transaction_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_transport_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_address_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_contact_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_from_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_to_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_header_via_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_uri_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_object_t
),
BELLE_SIP_TYPE_ID
(
belle_sip_parameters_t
),
belle_sip_type_id_end
}
belle_sip_type_id_t
;
...
...
@@ -48,7 +56,7 @@ int belle_sip_object_is_unowed(const belle_sip_object_t *obj);
* If the object is initially unowed, this acquires the first reference.
**/
#define belle_sip_object_ref(obj) _belle_sip_object_ref((belle_sip_object_t*)obj)
void
_belle_sip_object_ref
(
belle_sip_object_t
*
obj
);
belle_sip_object_t
*
_belle_sip_object_ref
(
belle_sip_object_t
*
obj
);
/**
* Decrements the reference counter. When it drops to zero, the object is destroyed.
...
...
@@ -66,11 +74,13 @@ void _belle_sip_object_destroy(belle_sip_object_t *obj);
void
*
belle_sip_object_cast
(
belle_sip_object_t
*
obj
,
belle_sip_type_id_t
id
,
const
char
*
castname
,
const
char
*
file
,
int
fileno
);
#define BELLE_SIP_CAST(obj,_type) (_type*)belle_sip_object_cast((belle_sip_object_t *)(obj), _type##_id, #_type, __FILE__, __LINE__)
#define BELLE_SIP_OBJECT(obj) BELLE_SIP_CAST(obj,belle_sip_object_t)
#include "belle-sip/list.h"
#include "belle-sip/mainloop.h"
#include "belle-sip/uri.h"
#include "belle-sip/headers.h"
#include "belle-sip/parameters.h"
#include "belle-sip/message.h"
#include "belle-sip/transaction.h"
#undef TRUE
...
...
include/belle-sip/headers.h
View file @
356cc400
...
...
@@ -20,6 +20,7 @@
#define HEADERS_H_
#include "belle-sip/uri.h"
/***************************************************************************************
* header address
*
...
...
@@ -29,13 +30,8 @@ typedef struct _belle_sip_header_address belle_sip_header_address_t;
belle_sip_header_address_t
*
belle_sip_header_address_new
();
void
belle_sip_header_address_delete
(
belle_sip_header_address_t
*
contact
);
belle_sip_header_address_t
*
belle_sip_header_address_parse
(
const
char
*
address
)
;
belle_sip_header_address_t
*
belle_sip_header_address_ref
(
belle_sip_header_address_t
*
address
)
;
void
belle_sip_header_address_unref
(
belle_sip_header_address_t
*
address
)
;
/**
*
*/
...
...
@@ -54,6 +50,9 @@ const char* belle_sip_header_address_get_displayname(belle_sip_header_address_t*
*/
void
belle_sip_header_address_set_displayname
(
belle_sip_header_address_t
*
address
,
const
char
*
uri
);
#define BELLE_SIP_HEADER_ADDRESS(t) BELLE_SIP_CAST(t,belle_sip_header_address_t)
/***************************************************************************************
* header common
...
...
@@ -62,14 +61,13 @@ void belle_sip_header_address_set_displayname(belle_sip_header_address_t* addres
typedef
struct
_belle_sip_header
belle_sip_header_t
;
/**
/**
*********************
* Contact header object
*/
***********************
*/
typedef
struct
_belle_sip_header_contact
belle_sip_header_contact_t
;
belle_sip_header_contact_t
*
belle_sip_header_contact_new
();
void
belle_sip_header_contact_delete
(
belle_sip_header_contact_t
*
contact
);
belle_sip_header_contact_t
*
belle_sip_header_contact_parse
(
const
char
*
contact
)
;
...
...
@@ -104,27 +102,88 @@ belle_sip_header_contact_t* belle_sip_header_contact_parse (const char* contact)
*/
void
belle_sip_header_contact_set_wildcard
(
belle_sip_header_contact_t
*
contact
,
unsigned
int
is_wildcard
);
/**
#define BELLE_SIP_HEADER_CONTACT(t) BELLE_SIP_CAST(t,belle_sip_header_contact_t)
/******************************
* From header object inherent from header_address
*
*/
*****************************
*/
typedef
struct
_belle_sip_header_from
belle_sip_header_from_t
;
belle_sip_header_from_t
*
belle_sip_header_from_new
();
void
belle_sip_header_from_delete
(
belle_sip_header_from_t
*
from
);
belle_sip_header_from_t
*
belle_sip_header_from_parse
(
const
char
*
from
)
;
belle_sip_header_from_t
*
belle_sip_header_from_ref
(
belle_sip_header_from_t
*
from
)
;
void
belle_sip_header_from_unref
(
belle_sip_header_from_t
*
from
)
;
void
belle_sip_header_from_set_tag
(
belle_sip_header_from_t
*
from
,
const
char
*
tag
);
const
char
*
belle_sip_header_from_get_tag
(
belle_sip_header_from_t
*
from
);
#define BELLE_SIP_HEADER_FROM(t) BELLE_SIP_CAST(t,belle_sip_header_from_t)
/******************************
* To header object inherent from header_address
*
******************************/
typedef
struct
_belle_sip_header_to
belle_sip_header_to_t
;
belle_sip_header_to_t
*
belle_sip_header_to_new
();
belle_sip_header_to_t
*
belle_sip_header_to_parse
(
const
char
*
to
)
;
void
belle_sip_header_to_set_tag
(
belle_sip_header_to_t
*
from
,
const
char
*
tag
);
const
char
*
belle_sip_header_to_get_tag
(
belle_sip_header_to_t
*
from
);
#define BELLE_SIP_HEADER_TO(t) BELLE_SIP_CAST(t,belle_sip_header_to_t)
/******************************
* Via header object inherent from header_address
*
******************************/
typedef
struct
_belle_sip_header_via
belle_sip_header_via_t
;
belle_sip_header_via_t
*
belle_sip_header_via_new
();
belle_sip_header_via_t
*
belle_sip_header_via_parse
(
const
char
*
via
)
;
const
char
*
belle_sip_header_via_get_branch
(
belle_sip_header_via_t
*
via
);
const
char
*
belle_sip_header_via_get_host
(
belle_sip_header_via_t
*
via
);
/*
String getMAddr()
Returns the value of the maddr parameter, or null if this is not set.
int getPort()
Returns the port part of this ViaHeader.
String getProtocol()
Returns the value of the protocol used.
String getReceived()
Gets the received paramater of the ViaHeader.
int getRPort()
Returns the rport part of this ViaHeader.
String getTransport()
Returns the value of the transport parameter.
int getTTL()
Returns the value of the ttl parameter, or -1 if this is not set.
void setBranch(String branch)
Sets the branch parameter of the ViaHeader to the newly supplied branch value.
void setHost(String host)
Set the host part of this ViaHeader to the newly supplied host parameter.
void setMAddr(String mAddr)
Sets the value of the maddr parameter of this ViaHeader.
void setPort(int port)
Set the port part of this ViaHeader to the newly supplied port parameter.
void setProtocol(String protocol)
Sets the value of the protocol parameter.
void setReceived(String received)
Sets the received parameter of ViaHeader.
void setRPort()
Set the rport part of this ViaHeader.
void setTransport(String transport)
Sets the value of the transport.
void setTTL(int ttl)
*/
#define BELLE_SIP_HEADER_VIA(t) BELLE_SIP_CAST(t,belle_sip_header_via_t)
#endif
/* HEADERS_H_ */
include/belle-sip/list.h
View file @
356cc400
/*
* belle_sip_list.h
*
* Created on: 1 oct. 2010
* Author: jehanmonnier
*/
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BELLE_SIP_LIST_H_
#define BELLE_SIP_LIST_H_
...
...
include/belle-sip/parameters.h
0 → 100644
View file @
356cc400
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 Belledonne Communications SARL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARAMETERS_H_
#define PARAMETERS_H_
#include "belle-sip/list.h"
/***
* parameters
*
*/
typedef
struct
_belle_sip_parameters
belle_sip_parameters_t
;
belle_sip_parameters_t
*
belle_sip_parameters_new
();
const
char
*
belle_sip_parameters_get_parameter
(
belle_sip_parameters_t
*
obj
,
const
char
*
name
);
/**
* returns 0 if not found
*/
unsigned
int
belle_sip_parameters_is_parameter
(
belle_sip_parameters_t
*
obj
,
const
char
*
name
);
void
belle_sip_parameters_set_parameter
(
belle_sip_parameters_t
*
obj
,
const
char
*
name
,
const
char
*
value
);
const
belle_sip_list_t
*
belle_sip_parameters_get_parameter_names
(
belle_sip_parameters_t
*
obj
);
void
belle_sip_parameters_remove_parameter
(
belle_sip_parameters_t
*
obj
,
const
char
*
name
);
#define BELLE_SIP_PARAMETERS(obj) BELLE_SIP_CAST(obj,belle_sip_parameters_t)
#endif
/*PARAMETERS_H_*/
include/belle-sip/uri.h
View file @
356cc400
...
...
@@ -42,7 +42,7 @@ typedef struct _belle_sip_uri belle_sip_uri_t;
* Returns an Iterator over the const char*names of all headers present in this SipURI.
*
*/
belle_sip_list_t
*
belle_sip_uri_get_header_names
(
belle_sip_uri_t
*
uri
)
;
const
belle_sip_list_t
*
belle_sip_uri_get_header_names
(
belle_sip_uri_t
*
uri
)
;
/**
* Returns the host part of this SipURI.
*
...
...
@@ -170,6 +170,7 @@ typedef struct _belle_sip_uri belle_sip_uri_t;
*/
char
*
belle_sip_uri_to_string
(
belle_sip_uri_t
*
uri
)
;
#define BELLE_SIP_URI(obj) BELLE_SIP_CAST(obj,belle_sip_uri_t)
#endif
/*BELLE_SIP_URI_H_*/
src/belle_sip_headers_impl.c
View file @
356cc400
...
...
@@ -19,6 +19,7 @@
#include "belle-sip/headers.h"
#include "belle-sip/parameters.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
...
...
@@ -31,19 +32,21 @@
* header_address
***********************/
struct
_belle_sip_header_address
{
int
ref
;
belle_sip_parameters_t
params
;
const
char
*
displayname
;
belle_sip_uri_t
*
uri
;
};
belle_sip_header_address_t
*
belle_sip_header_address_new
()
{
return
(
belle_sip_header_address_t
*
)
belle_sip_new0
(
belle_sip_header_address_t
);
static
void
belle_sip_header_address_init
(
belle_sip_header_address_t
*
object
){
belle_sip_object_init_type
(
object
,
belle_sip_header_address_t
);
belle_sip_parameters_init
((
belle_sip_parameters_t
*
)
object
);
/*super*/
}
void
belle_sip_header_address_de
lete
(
belle_sip_header_address_t
*
contact
)
{
if
(
contact
->
displayname
)
free
((
void
*
)(
contact
->
displayname
));
if
(
contact
->
uri
)
belle_sip_
uri_delete
(
contact
->
uri
);
static
void
belle_sip_header_address_de
stroy
(
belle_sip_header_address_t
*
contact
)
{
if
(
contact
->
displayname
)
belle_sip_
free
((
void
*
)(
contact
->
displayname
));
if
(
contact
->
uri
)
belle_sip_
object_unref
(
BELLE_SIP_OBJECT
(
contact
->
uri
)
)
;
}
BELLE_SIP_NEW
(
header_address
,
object
)
GET_SET_STRING
(
belle_sip_header_address
,
displayname
);
void
belle_sip_header_address_set_quoted_displayname
(
belle_sip_header_address_t
*
address
,
const
char
*
value
)
{
...
...
@@ -60,7 +63,6 @@ void belle_sip_header_address_set_uri(belle_sip_header_address_t* address, belle
address
->
uri
=
uri
;
}
BELLE_SIP_REF
(
header_address
)
/************************
...
...
@@ -68,26 +70,21 @@ BELLE_SIP_REF(header_address)
***********************/
struct
_belle_sip_header_contact
{
belle_sip_header_address_t
address
;
int
ref
;
int
expires
;
float
qvalue
;
unsigned
int
wildcard
;
};
belle_sip_header_contact_
t
*
belle_sip_header_contact_
new
(
)
{
return
(
belle_sip_header_
contact_t
*
)
belle_sip_new0
(
belle_sip_header_
contact
_t
);
void
belle_sip_header_contact_
destroy
(
belle_sip_header_contact_
t
*
contact
)
{
belle_sip_header_
address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
contact
)
);
}
void
belle_sip_header_contact_delete
(
belle_sip_header_contact_t
*
contact
)
{
belle_sip_header_address_delete
((
belle_sip_header_address_t
*
)
contact
);
}
BELLE_SIP_PARSE
(
header_contact
);
BELLE_SIP_NEW
(
header_contact
,
header_address
)
BELLE_SIP_PARSE
(
header_contact
)
GET_SET_INT_PRIVATE
(
belle_sip_header_contact
,
expires
,
int
,
_
)
;
GET_SET_INT_PRIVATE
(
belle_sip_header_contact
,
q
value
,
float
,
_
);
GET_SET_INT_
PARAM_
PRIVATE
(
belle_sip_header_contact
,
expires
,
int
,
_
)
GET_SET_INT_
PARAM_
PRIVATE
(
belle_sip_header_contact
,
q
,
float
,
_
);
GET_SET_BOOL
(
belle_sip_header_contact
,
wildcard
,
is
);
int
belle_sip_header_contact_set_expires
(
belle_sip_header_contact_t
*
contact
,
int
expires
)
{
if
(
expires
<
0
)
{
return
-
1
;
...
...
@@ -99,29 +96,58 @@ int belle_sip_header_contact_set_qvalue(belle_sip_header_contact_t* contact, flo
if
(
qValue
!=
-
1
&&
qValue
<
0
&&
qValue
>
1
)
{
return
-
1
;
}
_belle_sip_header_contact_set_q
value
(
contact
,
qValue
);
_belle_sip_header_contact_set_q
(
contact
,
qValue
);
return
0
;
}
/**
float
belle_sip_header_contact_get_qvalue
(
belle_sip_header_contact_t
*
contact
)
{
return
belle_sip_header_contact_get_q
(
contact
);
}
/**************************
* From header object inherent from header_address
*
*
***************************
*/
struct
_belle_sip_header_from
{
belle_sip_header_address_t
address
;
int
ref
;
const
char
*
tag
;
};
BELLE_SIP_NEW
(
header_from
)
BELLE_SIP_REF
(
header_from
)
static
void
belle_sip_header_from_destroy
(
belle_sip_header_from_t
*
from
)
{
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
from
));
}
BELLE_SIP_NEW
(
header_from
,
header_address
)
BELLE_SIP_PARSE
(
header_from
)
GET_SET_STRING
(
belle_sip_header_from
,
tag
);
GET_SET_STRING_PARAM
(
belle_sip_header_from
,
tag
);
/**************************
* To header object inherent from header_address
****************************
*/
struct
_belle_sip_header_to
{
belle_sip_header_address_t
address
;
};
void
belle_sip_header_
from_delete
(
belle_sip_header_
from_t
*
from
)
{
belle_sip_header_address_de
lete
((
belle_sip_header_address_t
*
)
from
);
static
void
belle_sip_header_
to_destroy
(
belle_sip_header_
to_t
*
to
)
{
belle_sip_header_address_de
stroy
(
BELLE_SIP_HEADER_ADDRESS
(
to
)
);
}
BELLE_SIP_NEW
(
header_to
,
header_address
)
BELLE_SIP_PARSE
(
header_to
)
GET_SET_STRING_PARAM
(
belle_sip_header_to
,
tag
);
/**************************
* Viq header object inherent from header_address
****************************
*/
struct
_belle_sip_header_via
{
belle_sip_header_address_t
address
;
};
static
void
belle_sip_header_via_destroy
(
belle_sip_header_via_t
*
to
)
{
belle_sip_header_address_destroy
(
BELLE_SIP_HEADER_ADDRESS
(
to
));
}
BELLE_SIP_NEW
(
header_via
,
header_address
)
BELLE_SIP_PARSE
(
header_via
)
src/belle_sip_internal.h
View file @
356cc400
...
...
@@ -39,6 +39,8 @@ struct _belle_sip_object{
belle_sip_object_t
*
_belle_sip_object_new
(
size_t
objsize
,
belle_sip_type_id_t
id
,
belle_sip_object_destroy_t
destroy_func
,
int
initially_unowed
);
void
_belle_sip_object_init_type
(
belle_sip_object_t
*
obj
,
belle_sip_type_id_t
id
);
void
belle_sip_object_init
(
belle_sip_object_t
*
obj
);
#define belle_sip_object_new(_type,destroy) (_type*)_belle_sip_object_new(sizeof(_type),BELLE_SIP_TYPE_ID(_type),destroy,0)
#define belle_sip_object_new_unowed(_type,destroy) (_type*)_belle_sip_object_new(sizeof(_type),BELLE_SIP_TYPE_ID(_type),destroy,1)
...
...
@@ -212,6 +214,21 @@ uint64_t belle_sip_time_ms(void);
obj->attribute=malloc(strlen(value)+1);\
strcpy((char*)(obj->attribute),value);\
}
#define GET_SET_STRING_PARAM(object_type,attribute) GET_SET_STRING_PARAM2(object_type,attribute,attribute)
#define GET_SET_STRING_PARAM2(object_type,attribute,func_name) \
const char* object_type##_get_##func_name (object_type##_t* obj) {\
const char* l_value = belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(obj),#attribute);\
if (l_value == NULL) { \
belle_sip_warning("cannot find parameters [%s]",#attribute);\
return NULL;\
}\
return l_value;\
}\
void object_type##_set_##func_name (object_type##_t* obj,const char* value) {\
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(obj),#attribute,value);\
}
#define GET_SET_INT(object_type,attribute,type) GET_SET_INT_PRIVATE(object_type,attribute,type,)
#define GET_SET_INT_PRIVATE(object_type,attribute,type,set_prefix) \
...
...
@@ -221,6 +238,31 @@ uint64_t belle_sip_time_ms(void);
void set_prefix##object_type##_set_##attribute (object_type##_t* obj,type value) {\
obj->attribute=value;\
}
#define GET_SET_INT_PARAM(object_type,attribute,type) GET_SET_INT_PARAM_PRIVATE(object_type,attribute,type,)
#define GET_SET_INT_PARAM2(object_type,attribute,type,func_name) GET_SET_INT_PARAM_PRIVATE2(object_type,attribute,type,,func_name)
#define ATO_(type,value) ATO_##type(value)
#define ATO_int(value) atoi(value)
#define ATO_float(value) strtof(value,NULL)
#define FORMAT_(type) FORMAT_##type
#define FORMAT_int "%i"
#define FORMAT_float "%f"
#define GET_SET_INT_PARAM_PRIVATE(object_type,attribute,type,set_prefix) GET_SET_INT_PARAM_PRIVATE2(object_type,attribute,type,set_prefix,attribute)
#define GET_SET_INT_PARAM_PRIVATE2(object_type,attribute,type,set_prefix,func_name) \
type object_type##_get_##func_name (object_type##_t* obj) {\
const char* l_value = belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(obj),#attribute);\
if (l_value == NULL) { \
belle_sip_error("cannot find parameters [%s]",#attribute);\
return -1;\
}\
return ATO_(type,l_value);\
}\
void set_prefix##object_type##_set_##func_name (object_type##_t* obj,type value) {\
char l_str_value[16];\
snprintf(l_str_value,16,FORMAT_(type),value);\
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(obj),#attribute,(const char*)l_str_value);\
}
#define GET_SET_BOOL(object_type,attribute,getter) \
unsigned int object_type##_##getter##_##attribute (object_type##_t* obj) {\
...
...
@@ -229,6 +271,13 @@ uint64_t belle_sip_time_ms(void);
void object_type##_set_##attribute (object_type##_t* obj,unsigned int value) {\
obj->attribute=value;\
}
#define GET_SET_BOOL_PARAM2(object_type,attribute,getter,func_name) \
unsigned int object_type##_##getter##_##func_name (object_type##_t* obj) {\
return belle_sip_parameters_is_parameter(BELLE_SIP_PARAMETERS(obj),#attribute);\
}\
void object_type##_set_##func_name (object_type##_t* obj,unsigned int value) {\
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(obj),#attribute,NULL);\
}
#define BELLE_SIP_PARSE(object_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value) { \
...
...
@@ -251,22 +300,13 @@ belle_sip_##object_type##_t* belle_sip_##object_type##_parse (const char* value)
return l_parsed_object;\
}
#define BELLE_SIP_NEW(object_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_new (belle_sip_##object_type##_t* obj) { \
return (belle_sip_##object_type##_t*)belle_sip_new0(belle_sip_##object_type##_t);\
#define BELLE_SIP_NEW(object_type,super_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_new () { \
belle_sip_##object_type##_t* l_object = belle_sip_object_new(belle_sip_##object_type##_t, (belle_sip_object_destroy_t)belle_sip_##object_type##_destroy);\
belle_sip_##super_type##_init((belle_sip_##super_type##_t*)l_object); \
return l_object;\
}
#define BELLE_SIP_REF(object_type) \
belle_sip_##object_type##_t* belle_sip_##object_type##_ref (belle_sip_##object_type##_t* obj) { \
obj->ref++;\
return obj;\
}\
void belle_sip_##object_type##_unref (belle_sip_##object_type##_t* obj) { \
obj->ref--; \
if (obj->ref < 0) {\
belle_sip_##object_type##_delete(obj);\
}\
}
typedef
struct
belle_sip_param_pair_t
{
...
...
@@ -278,7 +318,7 @@ typedef struct belle_sip_param_pair_t {
belle_sip_param_pair_t
*
belle_sip_param_pair_new
(
const
char
*
name
,
const
char
*
value
);
void
belle_sip_param_pair_de
lete
(
belle_sip_param_pair_t
*
pair
)
;
void
belle_sip_param_pair_de
stroy
(
belle_sip_param_pair_t
*
pair
)
;
int
belle_sip_param_pair_comp_func
(
const
belle_sip_param_pair_t
*
a
,
const
char
*
b
)
;
...
...
@@ -289,6 +329,16 @@ void belle_sip_param_pair_unref(belle_sip_param_pair_t* obj);
void
belle_sip_header_address_set_quoted_displayname
(
belle_sip_header_address_t
*
address
,
const
char
*
value
);
/*class parameters*/
struct
_belle_sip_parameters
{
belle_sip_object_t
base
;
belle_sip_list_t
*
param_list
;
belle_sip_list_t
*
paramnames_list
;
};
void
belle_sip_parameters_init
(
belle_sip_parameters_t
*
obj
);
#ifdef __cplusplus
}
#endif
...
...
src/belle_sip_message.g
View file @
356cc400
...
...
@@ -147,10 +147,17 @@ qvalue
: ( '0' ( '.' DIGIT+)? )
| ( '1'( '.'DIGIT+)? );
*/
generic_param returns [belle_sip_param_pair_t* ret]
generic_param
[belle_sip_parameters_t* object]
returns [belle_sip_param_pair_t* ret]
: SP* token ( SP* EQUAL SP* is_gen=gen_value )? {
$ret=belle_sip_param_pair_new((const char*)($token.text->chars)
if (object == NULL) {
$ret=belle_sip_param_pair_new((const char*)($token.text->chars)
,$is_gen.text?(const char*)($gen_value.text->chars):NULL);
} else {
belle_sip_parameters_set_parameter(object
,(const char*)($token.text->chars)
,$is_gen.text?(const char*)($gen_value.text->chars):NULL);
$ret=NULL;
}
};
gen_value
: token | quoted_string;
...
...
@@ -281,13 +288,13 @@ scope { belle_sip_header_contact_t* current; }
( STAR { belle_sip_header_contact_set_wildcard($header_contact::current,1);}
| (contact_param (COMMA contact_param)*)) {$ret = $header_contact::current;};
contact_param
: (name_addr[
(belle_sip_header_address_t*)
$header_contact::current]
| addr_spec[
(belle_sip_header_address_t*)
$header_contact::current]) (SEMI contact_params)*;
: (name_addr[
BELLE_SIP_HEADER_ADDRESS(
$header_contact::current
)
]
| addr_spec[
BELLE_SIP_HEADER_ADDRESS(
$header_contact::current
)
]) (SEMI contact_params)*;
name_addr[belle_sip_header_address_t* object]
: ( display_name[object] )? sp_laquot_sp addr_spec[object] sp_raquot_sp;
addr_spec[belle_sip_header_address_t* object]
: uri {belle_sip_header_address_set_uri(object,
belle_sip_uri_ref
($uri.ret));};//| absoluteURI;
: uri {belle_sip_header_address_set_uri(object,
BELLE_SIP_URI(belle_sip_object_ref(BELLE_SIP_OBJECT
($uri.ret))
))
;};//| absoluteURI;
display_name[belle_sip_header_address_t* object]
: token {belle_sip_header_address_set_displayname(object,(const char*)($token.text->chars));}
...
...
@@ -302,16 +309,7 @@ contact_params
c_p_expires
: 'expires' EQUAL delta_seconds;*/
contact_extension
: generic_param {belle_sip_param_pair_t* pair = $generic_param.ret ;
if (strcmp("expires",pair->name) == 0) {
belle_sip_header_contact_set_expires($header_contact::current,atoi(pair->value));
} else if (strcmp("q",pair->name) == 0) {
belle_sip_header_contact_set_qvalue($header_contact::current,atof(pair->value));
} else {
belle_sip_warning("unknown contact param \%s",(const char *)$contact_extension.text->chars);
}
belle_sip_param_pair_unref(pair);
};
: generic_param [BELLE_SIP_PARAMETERS($header_contact::current)];
/*
delta_seconds
: DIGIT+;*/
...
...
@@ -411,20 +409,12 @@ header_from returns [belle_sip_header_from_t* ret]
scope { belle_sip_header_from_t* current; }
@init { $header_from::current = belle_sip_header_from_new(); }
: from_token/* ( 'From' | 'f' )*/
HCOLON
from_spec {$ret = $header_from::current;};
: from_token/* ( 'From' | 'f' )*/
hcolom
from_spec {$ret = $header_from::current;};
from_spec
: ( name_addr[
(belle_sip_header_address_t*)
$header_from::current] | addr_spec[
(belle_sip_header_address_t*)
$header_from::current] )
: ( name_addr[
BELLE_SIP_HEADER_ADDRESS(
$header_from::current
)
] | addr_spec[
BELLE_SIP_HEADER_ADDRESS(
$header_from::current
)
] )
( SEMI from_param )*;
from_param
: /*tag_param |*/ generic_param {belle_sip_param_pair_t* pair = $generic_param.ret ;
if (strcmp("tag",pair->name) == 0) {
belle_sip_header_from_set_tag($header_from::current,pair->value);
} else {
belle_sip_warning("unknown from param \%s",(const char *)$from_param.text->chars);
}
belle_sip_param_pair_unref(pair);
}
;
: /*tag_param |*/ generic_param [BELLE_SIP_PARAMETERS($header_from::current)];
/*
tag_param
...
...
@@ -561,28 +551,38 @@ timestamp
( '.' (DIGIT)* )? ( LWS delay )?;
delay
: (DIGIT)* ( '.' (DIGIT)* )?;
to
: ( 'To' | 't' ) HCOLON ( name_addr
| addr_spec ) ( SEMI to_param )*;
*/
to_token: {strcmp("To",(const char*)(INPUT->toStringTT(INPUT,LT(1),LT(2)))->chars) == 0}? token;
header_to returns [belle_sip_header_to_t* ret]