[Asterisk-code-review] res_stir_shaken: Add inbound INVITE support. (asterisk[master])

George Joseph asteriskteam at digium.com
Tue Jun 2 11:00:02 CDT 2020


George Joseph has posted comments on this change. ( https://gerrit.asterisk.org/c/asterisk/+/14447 )

Change subject: res_stir_shaken: Add inbound INVITE support.
......................................................................


Patch Set 2: Code-Review+1

(2 comments)

https://gerrit.asterisk.org/c/asterisk/+/14447/2/res/res_pjsip_stir_shaken.c 
File res/res_pjsip_stir_shaken.c:

https://gerrit.asterisk.org/c/asterisk/+/14447/2/res/res_pjsip_stir_shaken.c@36 
PS2, Line 36: /*!
            :  * \brief Decode a base 64 encoded string
            :  *
            :  * \note This function just makes it easier to base64decode since it
            :  * calculates the length for you
            :  *
            :  * \param s The encoded string
            :  *
            :  * \retval NULL on failure
            :  * \retval decoded string on success
            :  */
            : static char *decode_base64_string(const char *s)
            : {
            : 	size_t encoded_len;
            : 	size_t decoded_len;
            : 	int padding = 0;
            : 	unsigned char *decoded_string;
            : 
            : 	if (ast_strlen_zero(s)) {
            : 		return NULL;
            : 	}
            : 
            : 	encoded_len = strlen(s);
            : 	if (encoded_len > 2 && s[encoded_len - 1] == '=') {
            : 		padding++;
            : 		if (s[encoded_len - 2] == '=') {
            : 			padding++;
            : 		}
            : 	}
            : 
            : 	decoded_len = (encoded_len / 4 * 3) - padding;
            : 	decoded_string = ast_calloc(1, decoded_len);
            : 	if (!decoded_string) {
            : 		return NULL;
            : 	}
            : 
            : 	ast_base64decode(decoded_string, s, decoded_len);
            : 
            : 	return (char *)decoded_string;
            : }
            : 
This could go in utils.c since it's generic. ast_base64decode_string or something like that.
No need to change unless you're making other changes to this review.


https://gerrit.asterisk.org/c/asterisk/+/14447/2/res/res_pjsip_stir_shaken.c@158 
PS2, Line 158: static char *get_value_from_header_inbound(pjsip_rx_data *rdata, const pj_str_t str)
             : {
             : 	pjsip_generic_string_hdr *hdr;
             : 	pj_str_t hdr_val;
             : 
             : 	hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,
             : 		&str, NULL);
             : 	if (!hdr) {
             : 		return NULL;
             : 	}
             : 
             : 	pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
             : 
             : 	return hdr_val.ptr;
             : }
             : 
This would probably be a good utility function to put in res_pjsip.c...  "ast_sip_rdata_get_header_value"
No need to change unless you have to change something else.



-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14447
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I855f857be3d1c63b64812ac35d9ce0534085b913
Gerrit-Change-Number: 14447
Gerrit-PatchSet: 2
Gerrit-Owner: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Comment-Date: Tue, 02 Jun 2020 16:00:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200602/324328b9/attachment-0001.html>


More information about the asterisk-code-review mailing list