66 for (i = 0; i < n_params; i++) {
96 if (!security_mechanisms) {
135 if (security_mechanism ==
NULL) {
151 for (i = 0; i < size; ++i) {
175 if (!security_mechanisms) {
184 for (i = 0; i < vec_size; ++i) {
205 struct pjsip_generic_string_hdr *hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name,
NULL);
206 for (; hdr; hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name, hdr->next)) {
210 if (hdr->next == hdr) {
227 float ret = strtof(q_value, &
end);
229 if (
end == q_value) {
232 }
else if (
'\0' != *
end) {
235 }
else if (ret > 1.0 || ret < 0.0) {
269 if (!strncmp(param,
"q=", 2)) {
281 *security_mechanism = mech;
284 if (err && (mech !=
NULL)) {
291 const char *header_name,
int add_qval, pjsip_tx_data *tdata) {
297 static const pj_str_t proxy_require = {
"Proxy-Require", 13 };
298 static const pj_str_t require = {
"Require", 7 };
300 if (!security_mechanisms || !tdata) {
304 if (!strcmp(header_name,
"Security-Client")) {
306 }
else if (strcmp(header_name,
"Security-Server") &&
307 strcmp(header_name,
"Security-Verify")) {
312 add_qvalue = add_qvalue && add_qval;
315 for (i = 0; i < mech_cnt; ++i) {
324 if (pjsip_msg_find_hdr_by_name(tdata->msg, &require,
NULL) ==
NULL) {
327 if (pjsip_msg_find_hdr_by_name(tdata->msg, &proxy_require,
NULL) ==
NULL) {
341 if (!security_mechanisms || !hdr) {
345 if (pj_stricmp2(&hdr->name,
"Security-Client") && pj_stricmp2(&hdr->name,
"Security-Server") &&
346 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_MECH_DTLS_SRTP
@ AST_SIP_SECURITY_MECH_SDES_SRTP
@ AST_SIP_SECURITY_MECH_MSRP_TLS
@ AST_SIP_SECURITY_MECH_NONE
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 * security_mechanisms_copy(const struct ast_sip_security_mechanism *src)
static struct ast_sip_security_mechanism * 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)
static int str_to_security_mechanism_type(const char *security_mechanism)
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.
static void security_mechanism_destroy(struct ast_sip_security_mechanism *mech)
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 char * mechanism_str[]
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.
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
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
Support for dynamic strings.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
#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.