mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Merge code associated with AST-2009-006
(closes issue #12912) Reported by: rathaus Tested by: tilghman, russell, dvossel, dbrooks git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@215955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
1357
channels/chan_iax2.c
1357
channels/chan_iax2.c
File diff suppressed because it is too large
Load Diff
@@ -277,6 +277,7 @@ static struct iax2_ie {
|
||||
{ IAX_IE_RR_OOO, "RR_OUTOFORDER", dump_int },
|
||||
{ IAX_IE_VARIABLE, "VARIABLE", dump_string },
|
||||
{ IAX_IE_OSPTOKEN, "OSPTOKEN" },
|
||||
{ IAX_IE_CALLTOKEN, "CALLTOKEN" },
|
||||
};
|
||||
|
||||
static const struct iax2_ie prov_ies[] = {
|
||||
@@ -533,6 +534,9 @@ void iax_frame_subclass2str(enum iax_frame_subclass subclass, char *str, size_t
|
||||
case IAX_COMMAND_RTKEY:
|
||||
cmd = "RTKEY ";
|
||||
break;
|
||||
case IAX_COMMAND_CALLTOKEN:
|
||||
cmd = "CTOKEN ";
|
||||
break;
|
||||
}
|
||||
ast_copy_string(str, cmd, len);
|
||||
}
|
||||
@@ -1052,6 +1056,12 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
|
||||
errorf(tmp);
|
||||
}
|
||||
break;
|
||||
case IAX_IE_CALLTOKEN:
|
||||
if (len) {
|
||||
ies->calltokendata = (unsigned char *) data + 2;
|
||||
}
|
||||
ies->calltoken = 1;
|
||||
break;
|
||||
default:
|
||||
snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
|
||||
outputf(tmp);
|
||||
|
@@ -77,6 +77,8 @@ struct iax_ies {
|
||||
struct ast_variable *vars;
|
||||
char *osptokenblock[IAX_MAX_OSPBLOCK_NUM];
|
||||
unsigned int ospblocklength[IAX_MAX_OSPBLOCK_NUM];
|
||||
unsigned char calltoken;
|
||||
unsigned char *calltokendata;
|
||||
};
|
||||
|
||||
#define DIRECTION_INGRESS 1
|
||||
|
@@ -111,6 +111,8 @@ enum iax_frame_subclass {
|
||||
IAX_COMMAND_TXMEDIA = 38,
|
||||
/*! Command to rotate key */
|
||||
IAX_COMMAND_RTKEY = 39,
|
||||
/*! Call number token */
|
||||
IAX_COMMAND_CALLTOKEN = 40,
|
||||
};
|
||||
|
||||
/*! By default require re-registration once per minute */
|
||||
@@ -176,6 +178,7 @@ enum iax_frame_subclass {
|
||||
#define IAX_IE_RR_OOO 51 /*!< Frames received Out of Order u32 */
|
||||
#define IAX_IE_VARIABLE 52 /*!< Remote variables */
|
||||
#define IAX_IE_OSPTOKEN 53 /*!< OSP token */
|
||||
#define IAX_IE_CALLTOKEN 54 /*!< Call number security token */
|
||||
|
||||
#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
|
||||
#define IAX_MAX_OSPBLOCK_NUM 4
|
||||
|
@@ -311,6 +311,63 @@ autokill=yes
|
||||
; This can also be configured per device
|
||||
; Parkinglots are defined in features.conf
|
||||
|
||||
|
||||
;
|
||||
; The following two options are used to disable call token validation for the
|
||||
; purposes of interoperability with IAX2 endpoints that do not yet support it.
|
||||
;
|
||||
; Call token validation can be set as optional for a single IP address or IP
|
||||
; address range by using the 'calltokenoptional' option. 'calltokenoptional' is
|
||||
; only a global option.
|
||||
;
|
||||
;calltokenoptional=209.16.236.73/255.255.255.0
|
||||
;
|
||||
; In a peer/user/friend definition, the 'requirecalltoken' option may be used.
|
||||
; By setting 'requirecalltoken=no', call token validation becomes optional for
|
||||
; that peer/user. By setting 'requirecalltoken=auto', call token validation
|
||||
; is optional until a call token supporting peer registers successfully using
|
||||
; call token validation. This is used as an indication that from now on, we
|
||||
; can require it from this peer. So, requirecalltoken is internally set to yes.
|
||||
; By default, 'requirecalltoken=yes'.
|
||||
;
|
||||
;requirecalltoken=no
|
||||
;
|
||||
|
||||
;
|
||||
; These options are used to limit the amount of call numbers allocated to a
|
||||
; single IP address. Before changing any of these values, it is highly encouraged
|
||||
; to read the user guide associated with these options first. In most cases, the
|
||||
; default values for these options are sufficient.
|
||||
;
|
||||
; The 'maxcallnumbers' option limits the amount of call numbers allowed for each
|
||||
; individual remote IP address. Once an IP address reaches it's call number
|
||||
; limit, no more new connections are allowed until the previous ones close. This
|
||||
; option can be used in a peer definition as well, but only takes effect for
|
||||
; the IP of a dynamic peer after it completes registration.
|
||||
;
|
||||
;maxcallnumbers=512
|
||||
;
|
||||
; The 'maxcallnumbers_nonvalidated' is used to set the combined number of call
|
||||
; numbers that can be allocated for connections where call token validation
|
||||
; has been disabled. Unlike the 'maxcallnumbers' option, this limit is not
|
||||
; separate for each individual IP address. Any connection resulting in a
|
||||
; non-call token validated call number being allocated contributes to this
|
||||
; limit. For use cases, see the call token user guide. This option's
|
||||
; default value of 8192 should be sufficient in most cases.
|
||||
;
|
||||
;maxcallnumbers_nonvalidated=1024
|
||||
;
|
||||
; The [callnumberlimits] section allows custom call number limits to be set
|
||||
; for specific IP addresses and IP address ranges. These limits take precedence
|
||||
; over the global 'maxcallnumbers' option, but may still be overridden by a
|
||||
; peer defined 'maxcallnumbers' entry. Note that these limits take effect
|
||||
; for every individual address within the range, not the range as a whole.
|
||||
;
|
||||
;[callnumberlimits]
|
||||
;10.1.1.0/255.255.255.0 = 24
|
||||
;10.1.2.0/255.255.255.0 = 32
|
||||
;
|
||||
|
||||
; Guest sections for unauthenticated connection attempts. Just specify an
|
||||
; empty secret, or provide no secret section.
|
||||
;
|
||||
|
@@ -55,6 +55,9 @@ struct ast_ha {
|
||||
/*! \brief Free host access list */
|
||||
void ast_free_ha(struct ast_ha *ha);
|
||||
|
||||
/*! \brief Copy ha structure */
|
||||
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to);
|
||||
|
||||
/*! \brief Append ACL entry to host access list. */
|
||||
struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error);
|
||||
|
||||
|
@@ -673,6 +673,15 @@ enum search_flags {
|
||||
* The search function is unaffected (i.e. use the one passed as
|
||||
* argument, or match_by_addr if none specified). */
|
||||
OBJ_POINTER = (1 << 3),
|
||||
/*!
|
||||
* \brief Continue if a match is not found in the hashed out bucket
|
||||
*
|
||||
* This flag is to be used in combination with OBJ_POINTER. This tells
|
||||
* the ao2_callback() core to keep searching through the rest of the
|
||||
* buckets if a match is not found in the starting bucket defined by
|
||||
* the hash value on the argument.
|
||||
*/
|
||||
OBJ_CONTINUE = (1 << 4),
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@@ -225,7 +225,7 @@ void ast_free_ha(struct ast_ha *ha)
|
||||
}
|
||||
|
||||
/* Copy HA structure */
|
||||
static void ast_copy_ha(struct ast_ha *from, struct ast_ha *to)
|
||||
void ast_copy_ha(const struct ast_ha *from, struct ast_ha *to)
|
||||
{
|
||||
memcpy(&to->netaddr, &from->netaddr, sizeof(from->netaddr));
|
||||
memcpy(&to->netmask, &from->netmask, sizeof(from->netmask));
|
||||
|
@@ -605,7 +605,7 @@ static void *internal_ao2_callback(struct ao2_container *c,
|
||||
const enum search_flags flags, void *cb_fn, void *arg, void *data, enum ao2_callback_type type,
|
||||
char *tag, char *file, int line, const char *funcname)
|
||||
{
|
||||
int i, last; /* search boundaries */
|
||||
int i, start, last; /* search boundaries */
|
||||
void *ret = NULL;
|
||||
ao2_callback_fn *cb_default = NULL;
|
||||
ao2_callback_data_fn *cb_withdata = NULL;
|
||||
@@ -642,13 +642,15 @@ static void *internal_ao2_callback(struct ao2_container *c,
|
||||
* (this only for the time being. We need to optimize this.)
|
||||
*/
|
||||
if ((flags & OBJ_POINTER)) /* we know hash can handle this case */
|
||||
i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets;
|
||||
start = i = c->hash_fn(arg, flags & OBJ_POINTER) % c->n_buckets;
|
||||
else /* don't know, let's scan all buckets */
|
||||
i = -1; /* XXX this must be fixed later. */
|
||||
|
||||
/* determine the search boundaries: i..last-1 */
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
start = i = 0;
|
||||
last = c->n_buckets;
|
||||
} else if ((flags & OBJ_CONTINUE)) {
|
||||
last = c->n_buckets;
|
||||
} else {
|
||||
last = i + 1;
|
||||
@@ -716,6 +718,17 @@ static void *internal_ao2_callback(struct ao2_container *c,
|
||||
}
|
||||
}
|
||||
AST_LIST_TRAVERSE_SAFE_END;
|
||||
|
||||
if (ret) {
|
||||
/* This assumes OBJ_MULTIPLE with !OBJ_NODATA is still not implemented */
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == c->n_buckets - 1 && (flags & OBJ_POINTER) && (flags & OBJ_CONTINUE)) {
|
||||
/* Move to the beginning to ensure we check every bucket */
|
||||
i = -1;
|
||||
last = start;
|
||||
}
|
||||
}
|
||||
ao2_unlock(c);
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user