66 for (i = 0; i < n_params; i++) {
103 if (!security_mechanisms) {
117 if (!strcasecmp(security_mechanism,
"msrp-tls")) {
119 }
else if (!strcasecmp(security_mechanism,
"sdes-srtp")) {
121 }
else if (!strcasecmp(security_mechanism,
"dtls-srtp")) {
143 size_t buf_size = 128;
145 char *ret =
ast_calloc(buf_size,
sizeof(
char));
150 if (security_mechanism ==
NULL) {
157 snprintf(ret + strlen(ret), buf_size - 1,
";q=%f.4", security_mechanism->
qvalue);
161 for (i = 0; i < size; ++i) {
177 if (!security_mechanisms) {
184 for (i = 0; i < vec_size; ++i) {
189 snprintf(ret + strlen(ret),
sizeof(ret) - 1,
"%s%s",
190 tmp_buf, i == vec_size - 1 ?
"" :
", ");
201 struct pjsip_generic_string_hdr *hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name,
NULL);
202 for (; hdr; hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name, hdr->next)) {
206 if (hdr->next == hdr) {
223 float ret = strtof(q_value, &
end);
225 if (
end == q_value) {
228 }
else if (
'\0' != *
end) {
231 }
else if (ret > 1.0 || ret < 0.0) {
265 if (!strncmp(param,
"q=", 2)) {
277 *security_mechanism = mech;
280 if (err && (mech !=
NULL)) {
287 const char *header_name,
int add_qval, pjsip_tx_data *tdata) {
294 if (!security_mechanisms || !tdata) {
298 if (!strcmp(header_name,
"Security-Client")) {
300 }
else if (strcmp(header_name,
"Security-Server") &&
301 strcmp(header_name,
"Security-Verify")) {
306 add_qvalue = add_qvalue && add_qval;
309 for (i = 0; i < mech_cnt; ++i) {
328 if (!security_mechanisms || !hdr) {
332 if (pj_stricmp2(&hdr->name,
"Security-Client") && pj_stricmp2(&hdr->name,
"Security-Server") &&
333 pj_stricmp2(&hdr->name,
"Security-Verify")) {
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
static struct ast_threadstorage tmp_buf
ast_sip_security_mechanism_type
The security mechanism type.
@ AST_SIP_SECURITY_MECH_DTLS_SRTP
@ AST_SIP_SECURITY_MECH_SDES_SRTP
@ AST_SIP_SECURITY_MECH_MSRP_TLS
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
void ast_sip_header_to_security_mechanism(const pjsip_generic_string_hdr *hdr, struct ast_sip_security_mechanism_vector *security_mechanisms)
Append to security mechanism vector from SIP header.
void ast_sip_security_mechanisms_vector_copy(struct ast_sip_security_mechanism_vector *dst, const struct ast_sip_security_mechanism_vector *src)
Duplicate a security mechanism.
static struct ast_sip_security_mechanism * ast_sip_security_mechanisms_copy(const struct ast_sip_security_mechanism *src)
static char * ast_sip_security_mechanism_type_to_str(enum ast_sip_security_mechanism_type mech_type)
static struct ast_sip_security_mechanism * ast_sip_security_mechanisms_alloc(size_t n_params)
void ast_sip_security_mechanisms_vector_destroy(struct ast_sip_security_mechanism_vector *security_mechanisms)
Free contents of a security mechanism vector.
static int security_mechanism_to_str(const struct ast_sip_security_mechanism *security_mechanism, int add_qvalue, char **buf)
int ast_sip_security_mechanism_vector_init(struct ast_sip_security_mechanism_vector *security_mechanisms, const char *value)
Initialize security mechanism vector from string of security mechanisms.
int ast_sip_security_mechanisms_to_str(const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf)
Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.
int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value)
Allocate a security mechanism from a string.
static float parse_qvalue(const char *q_value)
void ast_sip_remove_headers_by_name_and_value(pjsip_msg *msg, const pj_str_t *hdr_name, const char *value)
Removes all headers of a specific name and value from a pjsip_msg.
static int ast_sip_str_to_security_mechanism_type(const char *security_mechanism)
static void ast_sip_security_mechanisms_destroy(struct ast_sip_security_mechanism *mech)
int ast_sip_add_security_headers(struct ast_sip_security_mechanism_vector *security_mechanisms, const char *header_name, int add_qval, pjsip_tx_data *tdata)
Add security headers to transmission data.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Structure representing a security mechanism as defined in RFC 3329.
struct ast_vector_string mechanism_parameters
enum ast_sip_security_mechanism_type type
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.