diff --git a/src/modules/sst/parse_sst.c b/src/modules/sst/parse_sst.c index d9861722cb8..462976464db 100644 --- a/src/modules/sst/parse_sst.c +++ b/src/modules/sst/parse_sst.c @@ -34,34 +34,50 @@ #include "../../core/mem/mem.h" -static inline int/*bool*/ is_space( char c ) { return (c == ' ' || c == '\t'); } -static inline int/*bool*/ is_num( char c ) { return (c >= '0' && c <= '9'); } - -static inline unsigned lower_byte( char b ) { return b | 0x20; } -static inline unsigned lower_4bytes( unsigned d ) { return d | 0x20202020; } -static inline unsigned lower_3bytes( unsigned d ) { return d | 0x202020; } -static inline unsigned read_4bytes( char *val ) { - return (*(val + 0) + (*(val + 1) << 8) - + (*(val + 2) << 16) + (*(val + 3) << 24)); +static inline int /*bool*/ is_space(char c) +{ + return (c == ' ' || c == '\t'); +} +static inline int /*bool*/ is_num(char c) +{ + return (c >= '0' && c <= '9'); +} + +static inline unsigned lower_byte(char b) +{ + return b | 0x20; +} +static inline unsigned lower_4bytes(unsigned d) +{ + return d | 0x20202020; +} +static inline unsigned lower_3bytes(unsigned d) +{ + return d | 0x202020; } -static inline unsigned read_3bytes( char *val ) { +static inline unsigned read_4bytes(char *val) +{ + return (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16) + + (*(val + 3) << 24)); +} +static inline unsigned read_3bytes(char *val) +{ return (*(val + 0) + (*(val + 1) << 8) + (*(val + 2) << 16)); } /* compile-time constants if called with constants */ -#define MAKE_4BYTES( a, b, c, d ) \ - ( ((a)&0xFF) | (((b)&0xFF)<<8) | (((c)&0xFF)<<16) | (((d)&0xFF)<<24) ) -#define MAKE_3BYTES( a, b, c ) \ - ( ((a)&0xFF) | (((b)&0xFF)<<8) | (((c)&0xFF)<<16) ) +#define MAKE_4BYTES(a, b, c, d) \ + (((a)&0xFF) | (((b)&0xFF) << 8) | (((c)&0xFF) << 16) | (((d)&0xFF) << 24)) +#define MAKE_3BYTES(a, b, c) \ + (((a)&0xFF) | (((b)&0xFF) << 8) | (((c)&0xFF) << 16)) -struct session_expires * -malloc_session_expires( void ) +struct session_expires *malloc_session_expires(void) { - struct session_expires *se = (struct session_expires *) - pkg_malloc( sizeof(struct session_expires) ); - if ( se ) - memset( se, 0, sizeof(struct session_expires) ); + struct session_expires *se = (struct session_expires *)pkg_malloc( + sizeof(struct session_expires)); + if(se) + memset(se, 0, sizeof(struct session_expires)); return se; } @@ -71,105 +87,104 @@ malloc_session_expires( void ) void hf_free_session_expires(void *parsed) { struct session_expires *se; - se = (struct session_expires*)parsed; + se = (struct session_expires *)parsed; free_session_expires(se); } -void -free_session_expires( struct session_expires *se ) +void free_session_expires(struct session_expires *se) { - if ( se ) - pkg_free( se ); + if(se) + pkg_free(se); } -enum parse_sst_result -parse_session_expires_body( struct hdr_field *hf ) +enum parse_sst_result parse_session_expires_body(struct hdr_field *hf) { register char *p = hf->body.s; int pos = 0; int len = hf->body.len; char *q; - struct session_expires se = { 0, 0, sst_refresher_unspecified }; + struct session_expires se = {0, 0, sst_refresher_unspecified}; unsigned tok; - if ( !p || len <= 0 ) { - LM_ERR(" no body for header field\n" ); + if(!p || len <= 0) { + LM_ERR(" no body for header field\n"); return parse_sst_header_not_found; } /* skip whitespace */ - for ( ; pos < len && is_space(*p); ++pos, ++p ) + for(; pos < len && is_space(*p); ++pos, ++p) /*nothing*/; /* collect a number */ - for ( q = p; pos < len && is_num(*q); ++pos, ++q ) - se.interval = se.interval*10/*radix*/ + (*q - '0'); + for(q = p; pos < len && is_num(*q); ++pos, ++q) + se.interval = se.interval * 10 /*radix*/ + (*q - '0'); - if ( q == p ) /*nothing parsed */ { - LM_ERR(" no expiry interval\n" ); + if(q == p) /*nothing parsed */ { + LM_ERR(" no expiry interval\n"); return parse_sst_no_value; } p = q; /* continue on with params */ - while ( pos < len ) { - - if ( *p == ';' ) { - ++p; ++pos; - - if ( pos + 4 < len ) { - switch ( lower_4bytes(read_4bytes(p)) ) { - case /*refr*/MAKE_4BYTES('r','e','f','r'): - if ( pos + 9 <= len - && lower_4bytes(read_4bytes(p+4)) - == /*eshe*/MAKE_4BYTES('e','s','h','e') - && lower_byte(*(p+8)) == 'r' - && *(p+9) == '=' ) { - tok = lower_3bytes( read_3bytes(p+10) ); - if ( tok == MAKE_3BYTES('u','a','c') ) { + while(pos < len) { + + if(*p == ';') { + ++p; + ++pos; + + if(pos + 4 < len) { + switch(lower_4bytes(read_4bytes(p))) { + case /*refr*/ MAKE_4BYTES('r', 'e', 'f', 'r'): + if(pos + 9 <= len + && lower_4bytes(read_4bytes(p + 4)) + == /*eshe*/ MAKE_4BYTES( + 'e', 's', 'h', 'e') + && lower_byte(*(p + 8)) == 'r' + && *(p + 9) == '=') { + tok = lower_3bytes(read_3bytes(p + 10)); + if(tok == MAKE_3BYTES('u', 'a', 'c')) { se.refresher = sst_refresher_uac; - p += 13; pos += 13; - } - else if ( tok == MAKE_3BYTES('u','a','s') ) { + p += 13; + pos += 13; + } else if(tok == MAKE_3BYTES('u', 'a', 's')) { se.refresher = sst_refresher_uas; - p += 13; pos += 13; - } - else /* unrecognized refresher-param */ { - LM_ERR(" unrecognized refresher\n" ); + p += 13; + pos += 13; + } else /* unrecognized refresher-param */ { + LM_ERR(" unrecognized refresher\n"); return parse_sst_parse_error; } - } - else /* not "esher=" */ { + } else /* not "esher=" */ { /* there are no other se-params that start with "refr" */ - for ( ; pos < len && *p != ';'; ++pos, ++p ) + for(; pos < len && *p != ';'; ++pos, ++p) /*skip to ';'*/; } break; default: /* unrecognized se-param */ - for ( ; pos < len && *p != ';'; ++pos, ++p ) + for(; pos < len && *p != ';'; ++pos, ++p) /*skip to ';'*/; break; } /*switch*/ - } /* exist 4 bytes to check */ + } /* exist 4 bytes to check */ else /* less than 4 bytes left */ { /* not enough text left for any of the recognized se-params */ /* no other recognized se-param */ - for ( ; pos < len && *p != ';'; ++pos, ++p ) /*skip to ';'*/; + for(; pos < len && *p != ';'; ++pos, ++p) /*skip to ';'*/ + ; } - } - else /* not ';' */ { + } else /* not ';' */ { LM_ERR("no semicolon separating se-params\n"); return parse_sst_parse_error; } /* if ';' */ - } /* while */ + } /* while */ hf->parsed = malloc_session_expires(); - if ( !hf->parsed ) { - LM_ERR(" out of pkg memory\n" ); + if(!hf->parsed) { + LM_ERR(" out of pkg memory\n"); return parse_sst_out_of_mem; } se.hfree = hf_free_session_expires; @@ -179,30 +194,28 @@ parse_session_expires_body( struct hdr_field *hf ) } -enum parse_sst_result -parse_session_expires( struct sip_msg *msg, struct session_expires *se ) +enum parse_sst_result parse_session_expires( + struct sip_msg *msg, struct session_expires *se) { enum parse_sst_result result; - if ( msg->session_expires ) { - if ( msg->session_expires->parsed == 0 - && (result = parse_session_expires_body(msg->session_expires)) - != parse_sst_success ) { + if(msg->session_expires) { + if(msg->session_expires->parsed == 0 + && (result = parse_session_expires_body(msg->session_expires)) + != parse_sst_success) { return result; } - if ( se ) { + if(se) { *se = *((struct session_expires *)msg->session_expires->parsed); } return parse_sst_success; - } - else { + } else { return parse_sst_header_not_found; } } -enum parse_sst_result -parse_min_se_body( struct hdr_field *hf ) +enum parse_sst_result parse_min_se_body(struct hdr_field *hf) { int len = hf->body.len; char *p = hf->body.s; @@ -210,40 +223,38 @@ parse_min_se_body( struct hdr_field *hf ) unsigned int interval = 0; /* skip whitespace */ - for ( ; pos < len && is_space(*p); ++pos, ++p ) + for(; pos < len && is_space(*p); ++pos, ++p) /*nothing*/; - if ( pos == len ) + if(pos == len) return parse_sst_no_value; /* collect a number */ - for ( ; pos < len && is_num(*p); ++pos, ++p ) - interval = interval*10/*radix*/ + (*p - '0'); + for(; pos < len && is_num(*p); ++pos, ++p) + interval = interval * 10 /*radix*/ + (*p - '0'); /* skip whitespace */ - for ( ; pos < len && is_space(*p); ++pos, ++p ) + for(; pos < len && is_space(*p); ++pos, ++p) /*nothing*/; - if ( pos != len ) /* shouldn't be any more junk */ + if(pos != len) /* shouldn't be any more junk */ return parse_sst_parse_error; - hf->parsed=(void*)(long)interval; + hf->parsed = (void *)(long)interval; return parse_sst_success; } -enum parse_sst_result -parse_min_se( struct sip_msg *msg, unsigned int *min_se ) +enum parse_sst_result parse_min_se(struct sip_msg *msg, unsigned int *min_se) { enum parse_sst_result result; - if ( msg->min_se ) { - if ( msg->min_se->parsed == 0 - && (result = parse_min_se_body(msg->min_se)) - != parse_sst_success ) { + if(msg->min_se) { + if(msg->min_se->parsed == 0 + && (result = parse_min_se_body(msg->min_se)) + != parse_sst_success) { return result; } - if ( min_se ) { + if(min_se) { *min_se = (unsigned int)(long)msg->min_se->parsed; } return parse_sst_success; - } - else { + } else { return parse_sst_header_not_found; } } diff --git a/src/modules/sst/parse_sst.h b/src/modules/sst/parse_sst.h index cbb86f5b476..05f6b5703ae 100644 --- a/src/modules/sst/parse_sst.h +++ b/src/modules/sst/parse_sst.h @@ -37,7 +37,8 @@ /*! * Indicate the "refresher=" value of the Session-Expires header. */ -enum sst_refresher { +enum sst_refresher +{ sst_refresher_unspecified, sst_refresher_uac, sst_refresher_uas, @@ -48,37 +49,37 @@ enum sst_refresher { * We will treat the 'void* parsed' field of struct hdr_field as * a pointer to a struct session_expires. */ -struct session_expires { - hf_parsed_free_f hfree; /* function to free the content */ - unsigned interval; /* in seconds */ - enum sst_refresher refresher; +struct session_expires +{ + hf_parsed_free_f hfree; /* function to free the content */ + unsigned interval; /* in seconds */ + enum sst_refresher refresher; }; -enum parse_sst_result { +enum parse_sst_result +{ parse_sst_success, - parse_sst_header_not_found, /* no header */ + parse_sst_header_not_found, /* no header */ parse_sst_no_value, /* no interval specified */ #if NOT_IMPLEMENTED_YET - parse_sst_duplicate, /* multiple s-e / x / min-se headers found */ + parse_sst_duplicate, /* multiple s-e / x / min-se headers found */ #endif parse_sst_out_of_mem, - parse_sst_parse_error, /* something puked */ + parse_sst_parse_error, /* something puked */ }; /*! * Allocate a zeroed-out struct session_expires. */ -struct session_expires * -malloc_session_expires( void ); +struct session_expires *malloc_session_expires(void); /*! * Deallocates memory previously allocated via malloc_session_expires(). */ -void -free_session_expires( struct session_expires * ); +void free_session_expires(struct session_expires *); /*! @@ -103,8 +104,8 @@ free_session_expires( struct session_expires * ); * *((struct session_expires *)msg->session_expires->parsed) * \return parse_sst_result */ -enum parse_sst_result -parse_session_expires( struct sip_msg *msg, struct session_expires *se ); +enum parse_sst_result parse_session_expires( + struct sip_msg *msg, struct session_expires *se); /*! @@ -118,8 +119,7 @@ parse_session_expires( struct sip_msg *msg, struct session_expires *se ); * result is also available in (unsigned)msg->min_se->parsed * \return parse_sst_result */ -enum parse_sst_result -parse_min_se( struct sip_msg *msg, unsigned *min_se ); +enum parse_sst_result parse_min_se(struct sip_msg *msg, unsigned *min_se); #endif /* ! PARSE_SST_H */ diff --git a/src/modules/sst/sst.c b/src/modules/sst/sst.c index 4b640cf6e07..e462d8c2240 100644 --- a/src/modules/sst/sst.c +++ b/src/modules/sst/sst.c @@ -70,8 +70,8 @@ stat_var *expired_sst = 0; * code will set the dialog lifetime when it returns from the INVITE * and IN_ROUTE callbacks. */ -pv_spec_t timeout_avp; -static char* timeout_spec = 0; /*!< Place holder for the passed in name */ +pv_spec_t timeout_avp; +static char *timeout_spec = 0; /*!< Place holder for the passed in name */ /*! * The default or script parameter for the requested MIN-SE: value for @@ -79,7 +79,7 @@ static char* timeout_spec = 0; /*!< Place holder for the passed in name */ * proxy will except any value from the UAC as its min-SE value. If * the value is NOT set then the default will be asserted. */ -unsigned int sst_minSE = 90; +unsigned int sst_minSE = 90; /*! * Should the PROXY (us) reject (with a 422 reply) and SE < sst_minSE @@ -100,44 +100,39 @@ struct dlg_binds *dlg_binds = &dialog_st; /* * Script commands we export. */ -static cmd_export_t cmds[]={ - {"sstCheckMin", (cmd_function)sst_check_min, 1, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE }, - {0,0,0,0,0,0} -}; +static cmd_export_t cmds[] = {{"sstCheckMin", (cmd_function)sst_check_min, 1, 0, + 0, REQUEST_ROUTE | ONREPLY_ROUTE}, + {0, 0, 0, 0, 0, 0}}; /* * Script parameters */ -static param_export_t mod_params[]={ - { "enable_stats", INT_PARAM, &sst_enable_stats }, - { "min_se", INT_PARAM, &sst_minSE }, - { "timeout_avp", PARAM_STRING, &timeout_spec }, - { "reject_to_small", INT_PARAM, &sst_reject }, - { "sst_flag", INT_PARAM, &sst_flag }, - { 0,0,0 } -}; +static param_export_t mod_params[] = { + {"enable_stats", INT_PARAM, &sst_enable_stats}, + {"min_se", INT_PARAM, &sst_minSE}, + {"timeout_avp", PARAM_STRING, &timeout_spec}, + {"reject_to_small", INT_PARAM, &sst_reject}, + {"sst_flag", INT_PARAM, &sst_flag}, {0, 0, 0}}; #ifdef STATISTICS /* * Export the statistics we have */ static stat_export_t mod_stats[] = { - {"expired_sst", 0, &expired_sst}, - {0,0,0} -}; + {"expired_sst", 0, &expired_sst}, {0, 0, 0}}; #endif /* STATISTICS */ -struct module_exports exports= { - "sst", /* module's name */ - DEFAULT_DLFLAGS, /* dlopen flags */ - cmds, /* exported functions */ - mod_params, /* param exports */ - 0, /* RPC method exports */ - 0, /* exported pseudo-variables */ - 0, /* reply processing function */ - mod_init, /* module initialization function */ - 0, /* per-child init function */ - 0 /* Destroy function */ +struct module_exports exports = { + "sst", /* module's name */ + DEFAULT_DLFLAGS, /* dlopen flags */ + cmds, /* exported functions */ + mod_params, /* param exports */ + 0, /* RPC method exports */ + 0, /* exported pseudo-variables */ + 0, /* reply processing function */ + mod_init, /* module initialization function */ + 0, /* per-child init function */ + 0 /* Destroy function */ }; /** @@ -150,15 +145,14 @@ struct module_exports exports= { * @return 0 to continue to load the Kamailio, -1 to stop the loading * and abort Kamailio. */ -static int mod_init(void) +static int mod_init(void) { str s; #ifdef STATISTICS /* register statistics */ - if (sst_enable_stats!=0) - { - if (register_module_stats( exports.name, mod_stats)!=0 ) { + if(sst_enable_stats != 0) { + if(register_module_stats(exports.name, mod_stats) != 0) { LM_ERR("failed to register core statistics\n"); return -1; } @@ -166,20 +160,20 @@ static int mod_init(void) #endif - if (sst_flag == -1) { + if(sst_flag == -1) { LM_ERR("no sst flag set!!\n"); return -1; - } - else if (sst_flag > MAX_FLAG) { + } else if(sst_flag > MAX_FLAG) { LM_ERR("invalid sst flag %d!!\n", sst_flag); return -1; } - if (timeout_spec != NULL) { + if(timeout_spec != NULL) { LM_DBG("Dialog AVP is %s", timeout_spec); - s.s = timeout_spec; s.len = strlen(s.s); - if (pv_parse_spec(&s, &timeout_avp)==0 - && (timeout_avp.type != PVT_AVP)){ + s.s = timeout_spec; + s.len = strlen(s.s); + if(pv_parse_spec(&s, &timeout_avp) == 0 + && (timeout_avp.type != PVT_AVP)) { LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n", timeout_spec); return -1; @@ -187,23 +181,24 @@ static int mod_init(void) } /* bind the SL API */ - if (sl_load_api(&slb)!=0) { + if(sl_load_api(&slb) != 0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* Init the handlers */ - sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE, - sst_flag, sst_reject); + sst_handler_init( + (timeout_spec ? &timeout_avp : 0), sst_minSE, sst_flag, sst_reject); /* Register the main (static) dialog call back. */ - if (load_dlg_api(&dialog_st) != 0) { + if(load_dlg_api(&dialog_st) != 0) { LM_ERR("failed to load dialog hooks"); - return(-1); + return (-1); } /* Load dialog hooks */ - dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL); + dialog_st.register_dlgcb( + NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL); return 0; } diff --git a/src/modules/sst/sst_handlers.c b/src/modules/sst/sst_handlers.c index be4db6db34f..9a159577af7 100644 --- a/src/modules/sst/sst_handlers.c +++ b/src/modules/sst/sst_handlers.c @@ -47,7 +47,7 @@ * */ -#include /* for snprintf() */ +#include /* for snprintf() */ #include /* for memset() */ #include /* For atoi() */ @@ -73,19 +73,17 @@ */ #ifdef USE_CONFIRM_CALLBACK -#define DLOGMSG(msg) { \ - if (msg->first_line.type == SIP_REQUEST) { \ - LM_INFO("REQUEST: %.*s\n", \ - msg->first_line.u.request.method.len, \ - msg->first_line.u.request.method.s); \ - } \ - else { \ - LM_INFO("RESPONSE: %d %.*s\n", \ - msg->first_line.u.reply.statuscode, \ - msg->first_line.u.reply.reason.len, \ - msg->first_line.u.reply.reason.s); \ - } \ -} +#define DLOGMSG(msg) \ + { \ + if(msg->first_line.type == SIP_REQUEST) { \ + LM_INFO("REQUEST: %.*s\n", msg->first_line.u.request.method.len, \ + msg->first_line.u.request.method.s); \ + } else { \ + LM_INFO("RESPONSE: %d %.*s\n", msg->first_line.u.reply.statuscode, \ + msg->first_line.u.reply.reason.len, \ + msg->first_line.u.reply.reason.s); \ + } \ + } #endif @@ -99,11 +97,12 @@ extern struct dlg_binds *dlg_binds; * A collection of information about SST in the current SIP message * being processed. */ -typedef struct sst_msg_info_st { - int supported; /* supported = timer in message */ - unsigned int min_se; /* The Min-SE: value or zero */ - unsigned int se; /* The Session-Expires: header */ - enum sst_refresher refresher;/* The refresher (parse_sst.h) */ +typedef struct sst_msg_info_st +{ + int supported; /* supported = timer in message */ + unsigned int min_se; /* The Min-SE: value or zero */ + unsigned int se; /* The Session-Expires: header */ + enum sst_refresher refresher; /* The refresher (parse_sst.h) */ } sst_msg_info_t; /** @@ -111,15 +110,15 @@ typedef struct sst_msg_info_st { * documentation. */ #ifdef USE_CONFIRM_CALLBACK -static void sst_dialog_confirmed_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params); +static void sst_dialog_confirmed_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); #endif /* USE_CONFIRM_CALLBACK */ -static void sst_dialog_terminate_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params); -static void sst_dialog_request_within_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params); -static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params); +static void sst_dialog_terminate_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); +static void sst_dialog_request_within_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); +static void sst_dialog_response_fwded_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); static int send_response(struct sip_msg *request, int code, str *reason, char *header, int header_len); static int append_header(struct sip_msg *msg, const char *header); @@ -161,28 +160,26 @@ static str sst_422_rpl = str_init("Session Timer Too Small"); /* fixme: copied from functions, but size is too much */ -#define SST_SE_BUF_SIZE 80 +#define SST_SE_BUF_SIZE 80 static char sst_se_buf[SST_SE_BUF_SIZE]; static inline int sst_build_minse_hdr(int seval, str *sehdr) { - if(sehdr==NULL) + if(sehdr == NULL) return -1; - sehdr->len = snprintf(sst_se_buf, SST_SE_BUF_SIZE, - "Min-SE: %d\r\n", seval); + sehdr->len = snprintf(sst_se_buf, SST_SE_BUF_SIZE, "Min-SE: %d\r\n", seval); sehdr->s = sst_se_buf; return 0; } static inline int sst_build_se_hdr(int seval, str *sehdr, char *refresher) { - if(sehdr==NULL) + if(sehdr == NULL) return -1; - if(refresher==NULL) { - sehdr->len = snprintf(sst_se_buf, SST_SE_BUF_SIZE, - "Session-Expires: %d\r\n", seval); - } - else { + if(refresher == NULL) { + sehdr->len = snprintf( + sst_se_buf, SST_SE_BUF_SIZE, "Session-Expires: %d\r\n", seval); + } else { sehdr->len = snprintf(sst_se_buf, SST_SE_BUF_SIZE, "Session-Expires: %d;refresher=%s\r\n", seval, refresher); } @@ -200,8 +197,8 @@ static inline int sst_build_se_hdr(int seval, str *sehdr, char *refresher) * @param flag - sst flag * @param reject - reject state */ -void sst_handler_init(pv_spec_t *timeout_avp_p, unsigned int min_se, - int flag, unsigned int reject) +void sst_handler_init(pv_spec_t *timeout_avp_p, unsigned int min_se, int flag, + unsigned int reject) { timeout_avp = timeout_avp_p; sst_min_se = min_se; @@ -250,18 +247,18 @@ void sst_handler_init(pv_spec_t *timeout_avp_p, unsigned int min_se, * @param params - The pointer to nothing. As we did not attach * anything to this callback in the dialog module. */ -void sst_dialog_created_CB(struct dlg_cell *did, int type, - struct dlg_cb_params * params) +void sst_dialog_created_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { sst_info_t *info = NULL; sst_msg_info_t minfo; - struct sip_msg* msg = params->req; + struct sip_msg *msg = params->req; memset(&minfo, 0, sizeof(sst_msg_info_t)); /* * Only deal with messages flaged as SST interested. */ - if ((msg->flags & sst_flag) != sst_flag) { + if((msg->flags & sst_flag) != sst_flag) { LM_DBG("SST flag was not set for this request\n"); return; } @@ -269,8 +266,8 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type, /* * look only at INVITE */ - if (msg->first_line.type != SIP_REQUEST || - msg->first_line.u.request.method_value != METHOD_INVITE) { + if(msg->first_line.type != SIP_REQUEST + || msg->first_line.u.request.method_value != METHOD_INVITE) { LM_WARN("dialog create callback called with a non-INVITE request.\n"); return; } @@ -278,62 +275,60 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type, /* * Gather all the information about SST for this message */ - if (parse_msg_for_sst_info(msg, &minfo)) { + if(parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information\n"); return; } info = (sst_info_t *)shm_malloc(sizeof(sst_info_t)); memset(info, 0, sizeof(sst_info_t)); - info->requester = (minfo.se?SST_UAC:SST_UNDF); - info->supported = (minfo.supported?SST_UAC:SST_UNDF); + info->requester = (minfo.se ? SST_UAC : SST_UNDF); + info->supported = (minfo.supported ? SST_UAC : SST_UNDF); info->interval = MAX(sst_min_se, 90); /* For now, will set for real * later */ - if (minfo.se != 0) { + if(minfo.se != 0) { /* * There is a SE already there, this is good, we just need to * check the values out a little before passing it along. */ - if (minfo.se < sst_min_se) { + if(minfo.se < sst_min_se) { /* * Problem, the requested Session-Expires is too small for * our local policy. We need to fix it, or reject it or * ignore it. */ - if (!minfo.supported) { + if(!minfo.supported) { /* * Increase the Min-SE: value in the request and * forward it. */ str msehdr; - if (minfo.min_se) { + if(minfo.min_se) { /* We need to update, which means, remove + * insert */ remove_header(msg, "Min-SE"); } info->interval = MAX(sst_min_se, minfo.min_se); sst_build_minse_hdr(info->interval, &msehdr); - if (append_header(msg, msehdr.s)) { + if(append_header(msg, msehdr.s)) { LM_ERR("Could not append modified Min-SE: header\n"); } - } - else if (sst_reject) { + } else if(sst_reject) { /* Make sure that that all are at least 90 */ LM_DBG("rejecting 442 - local Min-SE: %d - received Min-SE: %d" - " - received SE: %d\n", + " - received SE: %d\n", sst_min_se, minfo.min_se, minfo.se); send_reject(msg, MAX(MAX(sst_min_se, minfo.min_se), 90)); shm_free(info); return; } - } /* end of se < sst_min_se */ + } /* end of se < sst_min_se */ else { /* Use the INVITE SE: value */ info->interval = minfo.se; } - } - else { + } else { /* * No Session-Expires: stated in request. */ @@ -341,10 +336,10 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type, info->interval = MAX(minfo.min_se, sst_min_se); - if (minfo.min_se && minfo.min_se < sst_min_se) { + if(minfo.min_se && minfo.min_se < sst_min_se) { remove_header(msg, "Min-SE"); sst_build_minse_hdr(info->interval, &msehdr); - if (append_header(msg, msehdr.s)) { + if(append_header(msg, msehdr.s)) { LM_ERR("failed to append modified Min-SE: header\n"); /* What to do? Let is slide, we can still work */ } @@ -352,9 +347,9 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type, info->requester = SST_PXY; sst_build_se_hdr(info->interval, &msehdr, NULL); - if (append_header(msg, msehdr.s)) { + if(append_header(msg, msehdr.s)) { LM_ERR("failed to append Session-Expires header to proxy " - "requested SST.\n"); + "requested SST.\n"); shm_free(info); return; /* Nothing we can do! */ } @@ -368,10 +363,10 @@ void sst_dialog_created_CB(struct dlg_cell *did, int type, /** * Play time. Please ignore this call. */ -static void sst_dialog_confirmed_CB(struct dlg_cell *did, int type, - struct dlg_cb_params * params) +static void sst_dialog_confirmed_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { - struct sip_msg* msg = params->rpl; + struct sip_msg *msg = params->rpl; LM_DBG("confirmed dialog CB %p\n", did); DLOGMSG(msg); @@ -387,13 +382,14 @@ static void sst_dialog_confirmed_CB(struct dlg_cell *did, int type, * @param type - The termination cause/reason. * @param params - The sst information */ -static void sst_dialog_terminate_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params) +static void sst_dialog_terminate_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { - switch (type) { + switch(type) { case DLGCB_FAILED: LM_DBG("DID %p failed (canceled). " - "Terminating session.\n", did); + "Terminating session.\n", + did); break; case DLGCB_EXPIRED: /* In the case of expired, the msg is pointing at a @@ -408,7 +404,7 @@ static void sst_dialog_terminate_CB(struct dlg_cell* did, int type, /* * Free the param sst_info_t memory */ - if (*(params->param)) { + if(*(params->param)) { LM_DBG("freeing the sst_info_t from dialog %p\n", did); shm_free(*(params->param)); *(params->param) = NULL; @@ -432,29 +428,29 @@ static void sst_dialog_terminate_CB(struct dlg_cell* did, int type, * @param type - The reason for the callback. DLGCB_REQ_WITHIN * @param params - The sst information */ -static void sst_dialog_request_within_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params) +static void sst_dialog_request_within_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { sst_info_t *info = (sst_info_t *)*(params->param); - sst_msg_info_t minfo = {0,0,0,0}; - struct sip_msg* msg = params->req; + sst_msg_info_t minfo = {0, 0, 0, 0}; + struct sip_msg *msg = params->req; - if (msg->first_line.type == SIP_REQUEST) { - if ((msg->first_line.u.request.method_value == METHOD_INVITE || - msg->first_line.u.request.method_value == METHOD_UPDATE)) { + if(msg->first_line.type == SIP_REQUEST) { + if((msg->first_line.u.request.method_value == METHOD_INVITE + || msg->first_line.u.request.method_value + == METHOD_UPDATE)) { LM_DBG("Update by a REQUEST. %.*s\n", msg->first_line.u.request.method.len, msg->first_line.u.request.method.s); - if (parse_msg_for_sst_info(msg, &minfo)) { + if(parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information\n"); return; } /* Early resetting of the value here */ set_timeout_avp(msg, minfo.se); info->interval = minfo.se; - } - else if (msg->first_line.u.request.method_value == METHOD_PRACK) { + } else if(msg->first_line.u.request.method_value == METHOD_PRACK) { /* Special case here. The PRACK will cause the dialog * module to reset the timeout value to the dlg->lifetime * value and look for the new AVP value bound to the @@ -469,10 +465,9 @@ static void sst_dialog_request_within_CB(struct dlg_cell* did, int type, LM_DBG("PRACK workaround applied!\n"); set_timeout_avp(msg, info->interval); } - } - else if (msg->first_line.type == SIP_REPLY) { - if ((msg->first_line.u.reply.statuscode > 199 && - msg->first_line.u.reply.statuscode < 300)) { + } else if(msg->first_line.type == SIP_REPLY) { + if((msg->first_line.u.reply.statuscode > 199 + && msg->first_line.u.reply.statuscode < 300)) { /* * To spec (RFC) the internal time out value so not be reset * until here. @@ -481,7 +476,7 @@ static void sst_dialog_request_within_CB(struct dlg_cell* did, int type, msg->first_line.u.reply.statuscode, msg->first_line.u.reply.reason.len, msg->first_line.u.reply.reason.s); - if (parse_msg_for_sst_info(msg, &minfo)) { + if(parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information\n"); return; } @@ -500,18 +495,18 @@ static void sst_dialog_request_within_CB(struct dlg_cell* did, int type, * @param type - The reason for the callback. DLGCB_CONFIRMED * @param params - The sst information */ -static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params) +static void sst_dialog_response_fwded_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { - struct sip_msg* msg = params->rpl; + struct sip_msg *msg = params->rpl; /* * This test to see if the message is a response should ALWAYS be * true. This callback should not get called for requests. But * lets be safe. */ - if (msg->first_line.type == SIP_REPLY) { - sst_msg_info_t minfo = {0,0,0,0}; + if(msg->first_line.type == SIP_REPLY) { + sst_msg_info_t minfo = {0, 0, 0, 0}; sst_info_t *info = (sst_info_t *)*(params->param); LM_DBG("Dialog seen REPLY %d %.*s\n", @@ -524,8 +519,8 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, * large as in the Min-SE: in the reply 422 message. If not, * we will create an INVITE, 422 loop. */ - if (msg->first_line.u.reply.statuscode == 422) { - if (parse_msg_for_sst_info(msg, &minfo)) { + if(msg->first_line.u.reply.statuscode == 422) { + if(parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information for the 422 reply\n"); return; } @@ -538,58 +533,58 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, * body. The RFC states we can only play with 2XX from the * INVITE or reINVITE/UPDATE. */ - if (!msg->cseq && ((parse_headers(msg, HDR_CSEQ_F, 0) == -1) || !msg->cseq)) { + if(!msg->cseq + && ((parse_headers(msg, HDR_CSEQ_F, 0) == -1) || !msg->cseq)) { LM_ERR("failed to parse CSeq\n"); return; } /* 2XX replies to INVITES only !*/ - if (msg->first_line.u.reply.statuscode > 199 && - msg->first_line.u.reply.statuscode < 300 && - (get_cseq(msg)->method_id == METHOD_INVITE || - get_cseq(msg)->method_id == METHOD_UPDATE)) { - if (parse_msg_for_sst_info(msg, &minfo)) { + if(msg->first_line.u.reply.statuscode > 199 + && msg->first_line.u.reply.statuscode < 300 + && (get_cseq(msg)->method_id == METHOD_INVITE + || get_cseq(msg)->method_id == METHOD_UPDATE)) { + if(parse_msg_for_sst_info(msg, &minfo)) { LM_ERR("failed to parse sst information for the 2XX reply\n"); return; } - if (minfo.se != 0) { - if (set_timeout_avp(msg, info->interval)) { + if(minfo.se != 0) { + if(set_timeout_avp(msg, info->interval)) { LM_ERR("failed to set the timeout AVP\n"); return; } - } - else { + } else { /* no se header found, we want to resquest it. */ - if (info->requester == SST_PXY || info->supported == SST_UAC) { + if(info->requester == SST_PXY || info->supported == SST_UAC) { str sehdr; - LM_DBG("appending the Session-Expires: header to the 2XX reply." - " UAC will deal with it.\n"); + LM_DBG("appending the Session-Expires: header to the 2XX " + "reply." + " UAC will deal with it.\n"); /* * GOOD! we can just insert the Session-Expires: * header and forward back to the UAC and it will * deal with refreshing the session. */ sst_build_se_hdr(info->interval, &sehdr, "uac"); - if (append_header(msg, sehdr.s)) { + if(append_header(msg, sehdr.s)) { LM_ERR("failed to append Session-Expires header\n"); return; } /* Set the dialog timeout HERE */ - if (set_timeout_avp(msg, info->interval)) { + if(set_timeout_avp(msg, info->interval)) { return; } - } - else { + } else { /* We are sunk, uac did not request it, and it * does not support it */ LM_DBG("UAC and UAS do not support timers!" - " No session timers for this session.\n"); + " No session timers for this session.\n"); } } } /* End of 2XX for an INVITE */ - } /* If the msg is a repsonse and not a request */ + } /* If the msg is a repsonse and not a request */ } /** @@ -617,23 +612,23 @@ static void sst_dialog_response_fwded_CB(struct dlg_cell* did, int type, int ki_sst_check_min(struct sip_msg *msg, int flag) { enum parse_sst_result result; - struct session_expires se = {0,0}; + struct session_expires se = {0, 0}; unsigned minse = 0; /* * Only look in INVITES. We can't reply with a 422 to a 2xx reply * now can we. This check can ONLY be done on the INVITE/UPDATE. */ - if (msg->first_line.type == SIP_REQUEST && - msg->first_line.u.request.method_value == METHOD_INVITE) { + if(msg->first_line.type == SIP_REQUEST + && msg->first_line.u.request.method_value == METHOD_INVITE) { /* * First see if there is an Session-Expires: header. If there * is, also look for a MIN-SE: header. If there is, use the * minimum value of the two to compare with srt1. All MUST not * be less than 90 and 1800 is recommended. See RCF section 4. */ - if ((result = parse_session_expires(msg, &se)) != parse_sst_success) { - if (result != parse_sst_header_not_found) { + if((result = parse_session_expires(msg, &se)) != parse_sst_success) { + if(result != parse_sst_header_not_found) { LM_ERR("failed to parse Session-Expires headers.\n"); return 0; /* Error drop the message */ } @@ -648,8 +643,8 @@ int ki_sst_check_min(struct sip_msg *msg, int flag) /* * We have a Session_expire header. Now look for the MIN-SE. */ - if ((result = parse_min_se(msg, &minse)) != parse_sst_success) { - if (result != parse_sst_header_not_found) { + if((result = parse_min_se(msg, &minse)) != parse_sst_success) { + if(result != parse_sst_header_not_found) { /* * This is an error. The header was found but could * not parse it. @@ -665,23 +660,24 @@ int ki_sst_check_min(struct sip_msg *msg, int flag) minse = 90; /* default by RFC4028, $5 */ } - LM_DBG("Session-Expires: %d; MIN-SE: %d\n", se.interval, minse); + LM_DBG("Session-Expires: %d; MIN-SE: %d\n", se.interval, minse); /* * Now compare our MIN-SE with the messages and see if it is * too small. We will take the smaller of the messages * Session-expires and min-se if stated. */ - if (sst_min_se < MIN(minse, se.interval)) { + if(sst_min_se < MIN(minse, se.interval)) { /* * Too small. See if we need to send the 422 and are able * to send it. */ - if (flag) { + if(flag) { str msehdr; sst_build_minse_hdr(sst_min_se, &msehdr); LM_DBG("Sending 422: %.*s\n", msehdr.len, msehdr.s); - if (send_response(msg, 422, &sst_422_rpl, msehdr.s, msehdr.len)){ + if(send_response( + msg, 422, &sst_422_rpl, msehdr.s, msehdr.len)) { LM_ERR("Error sending 422 reply.\n"); } } @@ -721,7 +717,7 @@ int ki_sst_check_min(struct sip_msg *msg, int flag) */ int sst_check_min(struct sip_msg *msg, char *flag, char *str2) { - if (flag && *flag) { + if(flag && *flag) { return ki_sst_check_min(msg, 1); } return ki_sst_check_min(msg, 0); @@ -744,25 +740,24 @@ static int send_response(struct sip_msg *request, int code, str *reason, char *header, int header_len) { - if (slb.freply != 0) { + if(slb.freply != 0) { /* Add new headers if not null or zero length */ - if ((header) && (header_len)) { - if (add_lump_rpl(request, header, header_len, LUMP_RPL_HDR) == 0) { + if((header) && (header_len)) { + if(add_lump_rpl(request, header, header_len, LUMP_RPL_HDR) == 0) { /* An error with adding the lump */ LM_ERR("unable to append header.\n"); return -1; } } /* Now using the sl function, send the reply/response */ - if (slb.freply(request, code, reason) < 0) { + if(slb.freply(request, code, reason) < 0) { LM_ERR("Unable to send reply.\n"); return -1; } - } - else { + } else { return -1; } - return(0); + return (0); } /** @@ -775,35 +770,35 @@ static int send_response(struct sip_msg *request, int code, str *reason, */ static int append_header(struct sip_msg *msg, const char *header) { - struct lump* anchor = NULL; + struct lump *anchor = NULL; char *s = NULL; int len = 0; LM_DBG("Appending header: %s", header); - if (parse_headers(msg, HDR_EOH_F, 0) == -1) { + if(parse_headers(msg, HDR_EOH_F, 0) == -1) { LM_ERR("failed to parse headers in message.\n"); - return(1); + return (1); } - if ((anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0)) == 0) { + if((anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0)) == 0) { LM_ERR("failed to get anchor to append header\n"); - return(1); + return (1); } len = strlen(header); - if ((s = (char *)pkg_malloc(len+1)) == 0) { + if((s = (char *)pkg_malloc(len + 1)) == 0) { LM_ERR("No more pkg memory. (size requested = %d)\n", len); - return(1); + return (1); } memcpy(s, header, len); s[len] = '\0'; - if (insert_new_lump_before(anchor, s, len, 0) == 0) { + if(insert_new_lump_before(anchor, s, len, 0) == 0) { LM_ERR("failed to insert lump\n"); pkg_free(s); - return(1); + return (1); } LM_DBG("Done appending header successfully.\n"); - return(0); + return (0); } /** @@ -817,26 +812,26 @@ static int append_header(struct sip_msg *msg, const char *header) */ static int remove_header(struct sip_msg *msg, const char *header) { - struct lump* anchor = NULL; + struct lump *anchor = NULL; struct hdr_field *hf = NULL; int cnt = 0; int len = strlen(header); - if (parse_headers(msg, HDR_EOH_F, 0) == -1) { + if(parse_headers(msg, HDR_EOH_F, 0) == -1) { LM_ERR("failed to parse headers in message.\n"); - return(-1); + return (-1); } - for (hf = msg->headers; hf; hf = hf->next) { - if (hf->name.len != len) { + for(hf = msg->headers; hf; hf = hf->next) { + if(hf->name.len != len) { continue; } - if (strncasecmp(hf->name.s, header, hf->name.len) != 0) { + if(strncasecmp(hf->name.s, header, hf->name.len) != 0) { continue; } - anchor = del_lump(msg, hf->name.s-msg->buf, hf->len, 0); - if (anchor == 0) { + anchor = del_lump(msg, hf->name.s - msg->buf, hf->len, 0); + if(anchor == 0) { LM_ERR("no more pkg memory\n"); return -1; } @@ -861,19 +856,19 @@ static int set_timeout_avp(struct sip_msg *msg, unsigned int value) int result = 0; /* Set the dialog timeout HERE */ - if (timeout_avp) { - if ((result = pv_get_spec_value(msg, timeout_avp, &pv_val)) == 0) { + if(timeout_avp) { + if((result = pv_get_spec_value(msg, timeout_avp, &pv_val)) == 0) { /* We now hold a reference to the AVP */ - if (pv_val.flags & PV_VAL_INT && pv_val.ri == value) { + if(pv_val.flags & PV_VAL_INT && pv_val.ri == value) { /* INT AVP with the same value */ - LM_DBG("Current timeout value already set to %d\n", - value); + LM_DBG("Current timeout value already set to %d\n", value); rtn = 0; } else { /* AVP not found or non-INT value -> add a new one*/ - pv_val.flags = PV_VAL_INT|PV_TYPE_INT; + pv_val.flags = PV_VAL_INT | PV_TYPE_INT; pv_val.ri = value; - if (timeout_avp->setf(msg,&timeout_avp->pvp,EQ_T,&pv_val)!=0) { + if(timeout_avp->setf(msg, &timeout_avp->pvp, EQ_T, &pv_val) + != 0) { LM_ERR("failed to set new dialog timeout value\n"); } else { LM_DBG("Timeout avp value set to %d\n", value); @@ -886,7 +881,7 @@ static int set_timeout_avp(struct sip_msg *msg, unsigned int value) } else { LM_ERR("SST needs to know the name of the dialog timeout AVP!\n"); } - return(rtn); + return (rtn); } /** @@ -901,9 +896,9 @@ static int set_timeout_avp(struct sip_msg *msg, unsigned int value) static int parse_msg_for_sst_info(struct sip_msg *msg, sst_msg_info_t *minfo) { int rtn = 0; - struct session_expires se = {0,0}; + struct session_expires se = {0, 0}; - if (!msg || !minfo) { + if(!msg || !minfo) { return (-1); } @@ -920,9 +915,9 @@ static int parse_msg_for_sst_info(struct sip_msg *msg, sst_msg_info_t *minfo) * if not found or an error parsing the one it did find! So assume * it is not found if unsuccessfull. */ - if ((rtn = parse_supported(msg)) == 0) { - if ((((struct option_tag_body*)msg->supported->parsed)->option_tags_all - & F_OPTION_TAG_TIMER)) { + if((rtn = parse_supported(msg)) == 0) { + if((((struct option_tag_body *)msg->supported->parsed)->option_tags_all + & F_OPTION_TAG_TIMER)) { minfo->supported = 1; } } @@ -930,15 +925,15 @@ static int parse_msg_for_sst_info(struct sip_msg *msg, sst_msg_info_t *minfo) * Parse the Min-SE: header next. */ minfo->min_se = 0; - if ((rtn = parse_min_se(msg, &minfo->min_se)) != parse_sst_success) { + if((rtn = parse_min_se(msg, &minfo->min_se)) != parse_sst_success) { minfo->min_se = 0; /* Make sure it statys clean */ } minfo->se = 0; - if ((rtn = parse_session_expires(msg, &se)) == parse_sst_success) { + if((rtn = parse_session_expires(msg, &se)) == parse_sst_success) { minfo->se = se.interval; minfo->refresher = se.refresher; } - return(0); + return (0); } /** @@ -955,12 +950,12 @@ static int send_reject(struct sip_msg *msg, unsigned int min_se) sst_build_minse_hdr(min_se, &msehdr); - if (send_response(msg, 422, &sst_422_rpl, msehdr.s, msehdr.len)) { + if(send_response(msg, 422, &sst_422_rpl, msehdr.s, msehdr.len)) { LM_ERR("Error sending 422 reply.\n"); - return(-1); + return (-1); } LM_DBG("Send reject reply 422 with Min-SE: %d\n", min_se); - return(0); + return (0); } /** @@ -979,19 +974,19 @@ static void setup_dialog_callbacks(struct dlg_cell *did, sst_info_t *info) #ifdef USE_CONFIRM_CALLBACK LM_DBG("Adding callback DLGCB_CONFIRMED\n"); - dlg_binds->register_dlgcb(did, - DLGCB_CONFIRMED_NA, sst_dialog_confirmed_CB, info, NULL); + dlg_binds->register_dlgcb( + did, DLGCB_CONFIRMED_NA, sst_dialog_confirmed_CB, info, NULL); #endif /* USE_CONFIRM_CALLBACK */ LM_DBG("Adding callback " - "DLGCB_FAILED|DLGCB_TERMINATED|DLGCB_EXPIRED\n"); + "DLGCB_FAILED|DLGCB_TERMINATED|DLGCB_EXPIRED\n"); dlg_binds->register_dlgcb(did, - DLGCB_FAILED|DLGCB_TERMINATED|DLGCB_EXPIRED, + DLGCB_FAILED | DLGCB_TERMINATED | DLGCB_EXPIRED, sst_dialog_terminate_CB, (void *)info, NULL); LM_DBG("Adding callback DLGCB_REQ_WITHIN\n"); /* This is for the reINVITE/UPDATE requests */ - dlg_binds->register_dlgcb(did, DLGCB_REQ_WITHIN, - sst_dialog_request_within_CB, info, NULL); + dlg_binds->register_dlgcb( + did, DLGCB_REQ_WITHIN, sst_dialog_request_within_CB, info, NULL); /* * This is for the final configuration of who will do SST for * us. In the DLGCB_CONFIRMED callback the message is @@ -1003,7 +998,6 @@ static void setup_dialog_callbacks(struct dlg_cell *did, sst_info_t *info) sst_dialog_response_fwded_CB, info, NULL); LM_DBG("Adding rpc handler\n"); - dlg_binds->register_dlgcb(did, DLGCB_RPC_CONTEXT, - sst_dialog_rpc_context_CB, (void *)info, NULL); - + dlg_binds->register_dlgcb(did, DLGCB_RPC_CONTEXT, sst_dialog_rpc_context_CB, + (void *)info, NULL); } diff --git a/src/modules/sst/sst_handlers.h b/src/modules/sst/sst_handlers.h index c82ad5f55e8..08a6ceda8bf 100644 --- a/src/modules/sst/sst_handlers.h +++ b/src/modules/sst/sst_handlers.h @@ -26,7 +26,7 @@ * \ingroup sst * Module: \ref sst */ - + #ifndef _SST_HANDLERS_H_ #define _SST_HANDLERS_H_ @@ -39,19 +39,21 @@ /*! \brief * Fag values used in the sst_info_t See below. */ -enum sst_flags { - SST_UNDF=0, /* 0 - --- */ - SST_UAC=1, /* 1 - 2^0 */ - SST_UAS=2, /* 2 - 2^1 */ - SST_PXY=4, /* 4 - 2^2 */ - SST_NSUP=8 /* 8 - 2^3 */ +enum sst_flags +{ + SST_UNDF = 0, /* 0 - --- */ + SST_UAC = 1, /* 1 - 2^0 */ + SST_UAS = 2, /* 2 - 2^1 */ + SST_PXY = 4, /* 4 - 2^2 */ + SST_NSUP = 8 /* 8 - 2^3 */ }; /** \brief * The local state required to figure out if and who supports SST and * if and who will be the refresher. */ -typedef struct sst_info_st { +typedef struct sst_info_st +{ enum sst_flags requester; enum sst_flags supported; unsigned int interval; @@ -61,8 +63,8 @@ typedef struct sst_info_st { /** \brief * The static (opening) callback function for all dialog creations */ -void sst_dialog_created_CB(struct dlg_cell *did, int type, - struct dlg_cb_params * params); +void sst_dialog_created_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); /** \brief * The script function @@ -74,7 +76,7 @@ int ki_sst_check_min(struct sip_msg *msg, int flag); /** \brief * The handlers initializer function */ -void sst_handler_init(pv_spec_t *timeout_avp, unsigned int minSE, - int flag, unsigned int reject); +void sst_handler_init(pv_spec_t *timeout_avp, unsigned int minSE, int flag, + unsigned int reject); #endif /* _SST_HANDLERS_H_ */ diff --git a/src/modules/sst/sst_rpc.c b/src/modules/sst/sst_rpc.c index a8cd3984661..f2377119f8c 100644 --- a/src/modules/sst/sst_rpc.c +++ b/src/modules/sst/sst_rpc.c @@ -38,13 +38,13 @@ /*! \brief * The dialog rpc helper function. */ -void sst_dialog_rpc_context_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params) +void sst_dialog_rpc_context_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params) { - rpc_cb_ctx_t *rpc_cb = (rpc_cb_ctx_t*)(params->dlg_data); + rpc_cb_ctx_t *rpc_cb = (rpc_cb_ctx_t *)(params->dlg_data); rpc_t *rpc = rpc_cb->rpc; void *c = rpc_cb->c; - sst_info_t* sst_info = (sst_info_t*)*(params->param); + sst_info_t *sst_info = (sst_info_t *)*(params->param); rpc->rpl_printf(c, "sst_requester_flags: %d", sst_info->requester); rpc->rpl_printf(c, "sst_supported_flags: %d", sst_info->supported); diff --git a/src/modules/sst/sst_rpc.h b/src/modules/sst/sst_rpc.h index fbb0efd6e88..5d4ca8eafd6 100644 --- a/src/modules/sst/sst_rpc.h +++ b/src/modules/sst/sst_rpc.h @@ -38,7 +38,7 @@ /** * The dialog mi helper function. */ -void sst_dialog_rpc_context_CB(struct dlg_cell* did, int type, - struct dlg_cb_params * params); +void sst_dialog_rpc_context_CB( + struct dlg_cell *did, int type, struct dlg_cb_params *params); #endif /* _SST_RPC_H_ */