Commit b62dae17 authored by DanmeiChen's avatar DanmeiChen

integrate retry-after in belle-sip-header type

parent ec215739
......@@ -350,6 +350,20 @@ BELLESIP_EXPORT void belle_sip_header_call_id_set_call_id(belle_sip_header_call_
unsigned int belle_sip_header_call_id_equals(const belle_sip_header_call_id_t* a,const belle_sip_header_call_id_t* b);
#define BELLE_SIP_HEADER_CALL_ID(t) BELLE_SIP_CAST(t,belle_sip_header_call_id_t)
#define BELLE_SIP_CALL_ID "Call-ID"
/******************************
* Retry-After object inherent from object
*
******************************/
typedef struct _belle_sip_header_retry_after belle_sip_header_retry_after_t;
BELLESIP_EXPORT belle_sip_header_retry_after_t* belle_sip_header_retry_after_new(void);
BELLESIP_EXPORT belle_sip_header_retry_after_t* belle_sip_header_retry_after_create (int retry_after);
BELLESIP_EXPORT belle_sip_header_retry_after_t* belle_sip_header_retry_after_parse (const char *retry_after) ;
BELLESIP_EXPORT int belle_sip_header_retry_after_get_retry_after(const belle_sip_header_retry_after_t* retry_after);
BELLESIP_EXPORT void belle_sip_header_retry_after_set_retry_after(belle_sip_header_retry_after_t* retry_after,int second);
#define BELLE_SIP_HEADER_RETRY_AFTER(t) BELLE_SIP_CAST(t,belle_sip_header_retry_after_t)
#define BELLE_SIP_RETRY_AFTER "Retry-After"
/******************************
* cseq object inherent from object
*
......
......@@ -151,7 +151,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(belle_sip,1)
BELLE_SIP_TYPE_ID(belle_sip_header_authentication_info_t),
BELLE_SIP_TYPE_ID(belle_sip_mdns_register_t),
BELLE_SIP_TYPE_ID(belle_sip_resolver_results_t),
BELLE_SIP_TYPE_ID(belle_sip_cpp_object_t)
BELLE_SIP_TYPE_ID(belle_sip_cpp_object_t),
BELLE_SIP_TYPE_ID(belle_sip_header_retry_after_t)
BELLE_SIP_DECLARE_TYPES_END
......
......@@ -51,6 +51,8 @@ static struct header_name_func_pair header_table[] = {
,{PROTO_SIP, BELLE_SIP_DIVERSION, (header_parse_func)belle_sip_header_diversion_parse}
,{PROTO_SIP, "i", (header_parse_func)belle_sip_header_call_id_parse}
,{PROTO_SIP, BELLE_SIP_CALL_ID, (header_parse_func)belle_sip_header_call_id_parse}
,{PROTO_SIP, "r", (header_parse_func)belle_sip_header_retry_after_parse}
,{PROTO_SIP, BELLE_SIP_RETRY_AFTER, (header_parse_func)belle_sip_header_retry_after_parse}
,{PROTO_SIP, "l", (header_parse_func)belle_sip_header_content_length_parse}
,{PROTO_SIP|PROTO_HTTP, BELLE_SIP_CONTENT_LENGTH, (header_parse_func)belle_sip_header_content_length_parse}
,{PROTO_SIP, "c", (header_parse_func)belle_sip_header_content_type_parse}
......@@ -902,6 +904,41 @@ BELLE_SIP_NEW_HEADER(header_call_id,header,BELLE_SIP_CALL_ID)
BELLE_SIP_PARSE(header_call_id)
GET_SET_STRING(belle_sip_header_call_id,call_id);
/**************************
* retry-after header object inherits from object
****************************
*/
struct _belle_sip_header_retry_after {
belle_sip_header_t header;
int retry_after;
};
static void belle_sip_header_retry_after_destroy(belle_sip_header_retry_after_t* retry_after) {
}
static void belle_sip_header_retry_after_clone(belle_sip_header_retry_after_t* retry_after,const belle_sip_header_retry_after_t *orig){
retry_after->retry_after = orig->retry_after;
}
belle_sip_error_code belle_sip_header_retry_after_marshal(belle_sip_header_retry_after_t* retry_after, char* buff, size_t buff_size, size_t *offset) {
belle_sip_error_code error=belle_sip_header_marshal(BELLE_SIP_HEADER(retry_after), buff, buff_size, offset);
if (error!=BELLE_SIP_OK) return error;
if (retry_after->retry_after > 0) {
error=belle_sip_snprintf(buff,buff_size,offset,"%i",retry_after->retry_after);
if (error!=BELLE_SIP_OK) return error;
}
return error;
}
BELLE_SIP_NEW_HEADER(header_retry_after,header,BELLE_SIP_RETRY_AFTER)
BELLE_SIP_PARSE(header_retry_after)
GET_SET_INT(belle_sip_header_retry_after,retry_after,int);
belle_sip_header_retry_after_t* belle_sip_header_retry_after_create (int retry_after) {
belle_sip_header_retry_after_t* obj;
obj = belle_sip_header_retry_after_new();
belle_sip_header_retry_after_set_retry_after(obj,retry_after);
return obj;
}
/**************************
* cseq header object inherent from object
****************************
*/
......
......@@ -171,6 +171,7 @@ BELLE_SIP_DECLARE_VPTR(belle_sip_request_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_response_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_parameters_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_call_id_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_retry_after_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_cseq_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_content_type_t);
BELLE_SIP_DECLARE_VPTR(belle_sip_header_route_t);
......
......@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-09-19 17:07:21
* - On : 2019-02-19 14:56:19
* - for the lexer : belle_sdpLexerLexer
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-09-19 17:07:21
* - On : 2019-02-19 14:56:19
* - for the lexer : belle_sdpLexerLexer
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C source file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-09-19 17:07:21
* - On : 2019-02-19 14:56:18
* - for the parser : belle_sdpParserParser
*
* Editing it, at least manually, is not wise.
......
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sdp.g
* - On : 2018-09-19 17:07:21
* - On : 2019-02-19 14:56:18
* - for the parser : belle_sdpParserParser
*
* Editing it, at least manually, is not wise.
......
......@@ -153,6 +153,7 @@ message_header [belle_sip_message_t* message]
// | authorization
// | header_call_id {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_call_id.ret));}/*
// | call_info
// | header_retry_after {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_retry_after.ret));}/*
// | header_contact {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_contact.ret));}
// | content_disposition
// | content_encoding
......@@ -630,6 +631,21 @@ info_param
: ( 'purpose' EQUAL ( 'icon' | 'info'
| 'card' | token ) ) | generic_param;
*/
/*retry-after header*/
retry_after_token: {IS_HEADER_NAMED(Retry-After,r)}? token;
header_retry_after returns [belle_sip_header_retry_after_t* ret]
scope { belle_sip_header_retry_after_t* current; }
@init {$header_retry_after::current = belle_sip_header_retry_after_new(); $ret=$header_retry_after::current; }
: retry_after_token /*( 'Retry-After' | 'r' )*/ hcolon retry_after{belle_sip_header_retry_after_set_retry_after($header_retry_after::current,atoi((const char*) $retry_after.text->chars)); };
catch [ANTLR3_RECOGNITION_EXCEPTION]
{
belle_sip_message("[\%s] reason [\%s]",(const char*)EXCEPTION->name,(const char*)EXCEPTION->message);
belle_sip_object_unref($header_retry_after::current);
$ret=NULL;
}
retry_after
: DIGIT+;
/* contact header */
contact_token: {IS_HEADER_NAMED(Contact,m)}? token;
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-09-19 17:07:29
* - On : 2019-02-19 14:56:30
* - for the lexer : belle_sip_messageLexerLexer
*
* Editing it, at least manually, is not wise.
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* This C header file was generated by $ANTLR version 3.4
*
* - From the grammar source file : ../grammars/belle_sip_message.g
* - On : 2018-09-19 17:07:28
* - On : 2019-02-19 14:56:28
* - for the parser : belle_sip_messageParserParser
*
* Editing it, at least manually, is not wise.
......@@ -254,6 +254,15 @@ has the callable functions (rules) shown below,
belle_sip_messageParser_call_id_return
pbelle_sip_messageParser->call_id(pbelle_sip_messageParser)
* -
void
pbelle_sip_messageParser->retry_after_token(pbelle_sip_messageParser)
* -
belle_sip_header_retry_after_t*
pbelle_sip_messageParser->header_retry_after(pbelle_sip_messageParser)
* -
belle_sip_messageParser_retry_after_return
pbelle_sip_messageParser->retry_after(pbelle_sip_messageParser)
* -
void
pbelle_sip_messageParser->contact_token(pbelle_sip_messageParser)
* -
......@@ -1225,6 +1234,17 @@ typedef struct belle_sip_messageParser_call_id_return_struct
typedef struct belle_sip_messageParser_retry_after_return_struct
{
/** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
*/
pANTLR3_COMMON_TOKEN start;
pANTLR3_COMMON_TOKEN stop;
}
belle_sip_messageParser_retry_after_return;
typedef struct belle_sip_messageParser_display_name_tokens_return_struct
{
/** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees
......@@ -2021,6 +2041,35 @@ typedef struct belle_sip_messageParser_header_call_id_SCOPE_struct
belle_sip_messageParser_header_call_id_SCOPE, * pbelle_sip_messageParser_header_call_id_SCOPE;
/* ruleAttributeScopeDecl(scope)
*/
/* makeScopeSet()
*/
/** Definition of the header_retry_after scope variable tracking
* structure. An instance of this structure is created by calling
* belle_sip_messageParser_header_retry_afterPush().
*/
typedef struct belle_sip_messageParser_header_retry_after_SCOPE_struct
{
/** Function that the user may provide to be called when the
* scope is destroyed (so you can free pANTLR3_HASH_TABLES and so on)
*
* \param POinter to an instance of this typedef/struct
*/
void (ANTLR3_CDECL *free) (struct belle_sip_messageParser_header_retry_after_SCOPE_struct * frame);
/* =============================================================================
* Programmer defined variables...
*/
belle_sip_header_retry_after_t* current;
/* End of programmer defined variables
* =============================================================================
*/
}
belle_sip_messageParser_header_retry_after_SCOPE, * pbelle_sip_messageParser_header_retry_after_SCOPE;
/* ruleAttributeScopeDecl(scope)
*/
/* makeScopeSet()
......@@ -3585,6 +3634,17 @@ struct belle_sip_messageParser_Ctx_struct
pbelle_sip_messageParser_header_call_id_SCOPE pbelle_sip_messageParser_header_call_idTop;
/* ruleAttributeScopeDef(scope)
*/
/** Pointer to the header_retry_after stack for use by pbelle_sip_messageParser_header_retry_afterPush()
* and pbelle_sip_messageParser_header_retry_afterPop()
*/
pANTLR3_STACK pbelle_sip_messageParser_header_retry_afterStack;
ANTLR3_UINT32 pbelle_sip_messageParser_header_retry_afterStack_limit;
pbelle_sip_messageParser_header_retry_after_SCOPE (*pbelle_sip_messageParser_header_retry_afterPush)(struct belle_sip_messageParser_Ctx_struct * ctx);
pbelle_sip_messageParser_header_retry_after_SCOPE pbelle_sip_messageParser_header_retry_afterTop;
/* ruleAttributeScopeDef(scope)
*/
/** Pointer to the header_contact stack for use by pbelle_sip_messageParser_header_contactPush()
......@@ -4340,6 +4400,15 @@ struct belle_sip_messageParser_Ctx_struct
belle_sip_messageParser_call_id_return
(*call_id) (struct belle_sip_messageParser_Ctx_struct * ctx);
void
(*retry_after_token) (struct belle_sip_messageParser_Ctx_struct * ctx);
belle_sip_header_retry_after_t*
(*header_retry_after) (struct belle_sip_messageParser_Ctx_struct * ctx);
belle_sip_messageParser_retry_after_return
(*retry_after) (struct belle_sip_messageParser_Ctx_struct * ctx);
void
(*contact_token) (struct belle_sip_messageParser_Ctx_struct * ctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment