Browse code

core: parser - macro to get sip port based on proto

Daniel-Constantin Mierla authored on 06/07/2021 09:07:32
Showing 1 changed files
... ...
@@ -184,6 +184,15 @@ if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
184 184
 (((m)->new_uri.s && (m)->new_uri.len) ? (&(m)->new_uri) : (&(m)->first_line.u.request.uri))
185 185
 
186 186
 
187
+/*! \brief
188
+ * Return the SIP port.
189
+ * - _port if _port!=0
190
+ * - 5061 for _proto == TLS or WSS
191
+ * - 5060 for the other _proto
192
+ */
193
+#define GET_SIP_PORT(_port, _proto) ((_port==0)?((_proto==PROTO_TLS \
194
+					|| _proto==PROTO_WSS)?5061:5060):_port)
195
+
187 196
 enum _uri_type{ERROR_URI_T=0, SIP_URI_T, SIPS_URI_T, TEL_URI_T, TELS_URI_T, URN_URI_T};
188 197
 typedef enum _uri_type uri_type;
189 198
 enum _uri_flags{