<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17863">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bundled_pjproject: Create generic pjsip_hdr_find functions<br><br>pjsip_msg_find_hdr(), pjsip_msg_find_hdr_by_name(), and<br>pjsip_msg_find_hdr_by_names() require a pjsip_msg to be passed in<br>so if you need to search a header list that's not in a pjsip_msg,<br>you have to do it yourself. This commit adds generic versions of<br>those 3 functions that take in the actual header list head instead<br>of a pjsip_msg so if you need to search a list of headers in<br>something like a pjsip_multipart_part, you can do so easily.<br><br>Change-Id: I6f2c127170eafda48e5e0d5d4d187bcd52b4df07<br>---<br>A third-party/pjproject/patches/0150-Create-generic-pjsip_hdr_find-functions.patch<br>1 file changed, 176 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0150-Create-generic-pjsip_hdr_find-functions.patch b/third-party/pjproject/patches/0150-Create-generic-pjsip_hdr_find-functions.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..6ddb346</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0150-Create-generic-pjsip_hdr_find-functions.patch</span><br><span>@@ -0,0 +1,176 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 7e3dfd8a15fd0f98dbf0e04d2d7a5bded90ee401 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: George Joseph <gjoseph@sangoma.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Tue, 11 Jan 2022 09:27:23 -0700</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH] Create generic pjsip_hdr_find functions</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+pjsip_msg_find_hdr(), pjsip_msg_find_hdr_by_name(), and</span><br><span style="color: hsl(120, 100%, 40%);">+pjsip_msg_find_hdr_by_names() require a pjsip_msg to be passed in</span><br><span style="color: hsl(120, 100%, 40%);">+so if you need to search a header list that's not in a pjsip_msg,</span><br><span style="color: hsl(120, 100%, 40%);">+you have to do it yourself. This commit adds generic versions of</span><br><span style="color: hsl(120, 100%, 40%);">+those 3 functions that take in the actual header list head instead</span><br><span style="color: hsl(120, 100%, 40%);">+of a pjsip_msg so if you need to search a list of headers in</span><br><span style="color: hsl(120, 100%, 40%);">+something like a pjsip_multipart_part, you can do so easily.</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/include/pjsip/sip_msg.h | 53 +++++++++++++++++++++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_msg.c | 51 +++++++++++++++++++++++----------</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 89 insertions(+), 15 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h</span><br><span style="color: hsl(120, 100%, 40%);">+index 4c9100d39..e3502e94e 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/include/pjsip/sip_msg.h</span><br><span>++++ b/pjsip/include/pjsip/sip_msg.h</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -362,6 +362,59 @@ PJ_DECL(void*) pjsip_hdr_shallow_clone( pj_pool_t *pool, const void *hdr );</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_DECL(int) pjsip_hdr_print_on( void *hdr, char *buf, pj_size_t len);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++/**</span><br><span style="color: hsl(120, 100%, 40%);">++ * Find a header in a header list by the header type.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param hdr_list The "head" of the header list.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param type The header type to find.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param start The first header field where the search should begin.</span><br><span style="color: hsl(120, 100%, 40%);">++ * If NULL is specified, then the search will begin from the</span><br><span style="color: hsl(120, 100%, 40%);">++ * first header, otherwise the search will begin at the</span><br><span style="color: hsl(120, 100%, 40%);">++ * specified header.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @return The header field, or NULL if no header with the specified</span><br><span style="color: hsl(120, 100%, 40%);">++ * type is found.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DECL(void*) pjsip_hdr_find( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_hdr_e type,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++/**</span><br><span style="color: hsl(120, 100%, 40%);">++ * Find a header in a header list by its name.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param hdr_list The "head" of the header list.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param name The header name to find.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param start The first header field where the search should begin.</span><br><span style="color: hsl(120, 100%, 40%);">++ * If NULL is specified, then the search will begin from the</span><br><span style="color: hsl(120, 100%, 40%);">++ * first header, otherwise the search will begin at the</span><br><span style="color: hsl(120, 100%, 40%);">++ * specified header.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @return The header field, or NULL if no header with the specified</span><br><span style="color: hsl(120, 100%, 40%);">++ * type is found.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DECL(void*) pjsip_hdr_find_by_name( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++/**</span><br><span style="color: hsl(120, 100%, 40%);">++ * Find a header in a header list by its name and short name version.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param hdr_list The "head" of the header list.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param name The header name to find.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param sname The short name version of the header name.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param start The first header field where the search should begin.</span><br><span style="color: hsl(120, 100%, 40%);">++ * If NULL is specified, then the search will begin from the</span><br><span style="color: hsl(120, 100%, 40%);">++ * first header, otherwise the search will begin at the</span><br><span style="color: hsl(120, 100%, 40%);">++ * specified header.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @return The header field, or NULL if no header with the specified</span><br><span style="color: hsl(120, 100%, 40%);">++ * type is found.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DECL(void*) pjsip_hdr_find_by_names( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *sname,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /**</span><br><span style="color: hsl(120, 100%, 40%);">+ * @}</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 6ba3054da..2a6a96af0 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_msg.c</span><br><span>++++ b/pjsip/src/pjsip/sip_msg.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -356,13 +356,13 @@ PJ_DEF(pjsip_msg*) pjsip_msg_clone( pj_pool_t *pool, const pjsip_msg *src)</span><br><span style="color: hsl(120, 100%, 40%);">+ return dst;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+-PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg, </span><br><span style="color: hsl(120, 100%, 40%);">+- pjsip_hdr_e hdr_type, const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_hdr_find( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_hdr_e hdr_type, const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+- const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=&msg->hdr;</span><br><span style="color: hsl(120, 100%, 40%);">++ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (hdr == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+- hdr = msg->hdr.next;</span><br><span style="color: hsl(120, 100%, 40%);">++ hdr = end->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ for (; hdr!=end; hdr = hdr->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (hdr->type == hdr_type)</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -371,14 +371,14 @@ PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+-PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg, </span><br><span style="color: hsl(120, 100%, 40%);">+- const pj_str_t *name, </span><br><span style="color: hsl(120, 100%, 40%);">+- const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_hdr_find_by_name( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+- const pjsip_hdr *hdr=(const pjsip_hdr*)start, *end=&msg->hdr;</span><br><span style="color: hsl(120, 100%, 40%);">++ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (hdr == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+- hdr = msg->hdr.next;</span><br><span style="color: hsl(120, 100%, 40%);">++ hdr = end->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ for (; hdr!=end; hdr = hdr->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pj_stricmp(&hdr->name, name) == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -387,15 +387,15 @@ PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+-PJ_DEF(void*) pjsip_msg_find_hdr_by_names( const pjsip_msg *msg, </span><br><span style="color: hsl(120, 100%, 40%);">+- const pj_str_t *name, </span><br><span style="color: hsl(120, 100%, 40%);">+- const pj_str_t *sname,</span><br><span style="color: hsl(120, 100%, 40%);">+- const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_hdr_find_by_names( const void *hdr_list,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *sname,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+- const pjsip_hdr *hdr=(const pjsip_hdr*)start, *end=&msg->hdr;</span><br><span style="color: hsl(120, 100%, 40%);">++ const pjsip_hdr *hdr=(const pjsip_hdr*) start, *end=hdr_list;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (hdr == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+- hdr = msg->hdr.next;</span><br><span style="color: hsl(120, 100%, 40%);">++ hdr = end->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ for (; hdr!=end; hdr = hdr->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pj_stricmp(&hdr->name, name) == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -406,6 +406,27 @@ PJ_DEF(void*) pjsip_msg_find_hdr_by_names( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_msg_find_hdr( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_hdr_e hdr_type, const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ return pjsip_hdr_find(&msg->hdr, hdr_type, start);</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_msg_find_hdr_by_name( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ return pjsip_hdr_find_by_name(&msg->hdr, name, start);</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(void*) pjsip_msg_find_hdr_by_names( const pjsip_msg *msg,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *name,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_str_t *sname,</span><br><span style="color: hsl(120, 100%, 40%);">++ const void *start)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ return pjsip_hdr_find_by_names(&msg->hdr, name, sname, start);</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_DEF(void*) pjsip_msg_find_remove_hdr( pjsip_msg *msg, </span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_hdr_e hdr_type, void *start)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.34.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17863">change 17863</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/17863"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I6f2c127170eafda48e5e0d5d4d187bcd52b4df07 </div>
<div style="display:none"> Gerrit-Change-Number: 17863 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>