static int adsi = 0;
-static unsigned int oseq;
+static unsigned int oseq_global = 0;
+AST_MUTEX_DEFINE_STATIC(oseq_lock);
/*! Wait up to 16 seconds for first digit (FXO logic) */
static int firstdigittimeout = 16000;
return 0;
}
-static int init_req(struct mgcp_endpoint *p, struct mgcp_request *req, char *verb)
+static int init_req(struct mgcp_endpoint *p, struct mgcp_request *req, char *verb, unsigned int oseq)
{
/* Initialize a response */
if (req->headers || req->len) {
static int reqprep(struct mgcp_request *req, struct mgcp_endpoint *p, char *verb)
{
+ unsigned int oseq;
memset(req, 0, sizeof(struct mgcp_request));
- oseq++;
- if (oseq > 999999999) {
- oseq = 1;
- }
- init_req(p, req, verb);
- return 0;
+ ast_mutex_lock(&oseq_lock);
+ oseq_global++;
+ if (oseq_global > 999999999) {
+ oseq_global = 1;
+ }
+ oseq = oseq_global;
+ ast_mutex_unlock(&oseq_lock);
+ init_req(p, req, verb, oseq);
+ return oseq;
}
static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp_request *req, char *msgrest)
struct mgcp_endpoint *p = sub->parent;
struct ast_format tmpfmt;
struct ast_sockaddr sub_tmpdest_tmp;
+ unsigned int oseq;
if (ast_strlen_zero(sub->cxident) && rtp) {
/* We don't have a CXident yet, store the destination and
}
- reqprep(&resp, p, "MDCX");
+ oseq = reqprep(&resp, p, "MDCX");
add_header(&resp, "C", sub->callid);
add_header(&resp, "L", local);
add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
char tmp[80];
struct ast_format tmpfmt;
struct mgcp_endpoint *p = sub->parent;
+ unsigned int oseq;
ast_debug(3, "Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
}
}
sub->sdpsent = 1;
- reqprep(&resp, p, "CRCX");
+ oseq = reqprep(&resp, p, "CRCX");
add_header(&resp, "C", sub->callid);
add_header(&resp, "L", local);
add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
char tmp[80];
struct ast_format tmpfmt;
struct mgcp_endpoint *p = sub->parent;
+ unsigned int oseq;
ast_copy_string(local, "p:20, s:off, e:on", sizeof(local));
ast_debug(3, "Creating connection for %s@%s-%d in cxmode: %s callid: %s\n",
p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
sub->sdpsent = 0;
- reqprep(&resp, p, "CRCX");
+ oseq = reqprep(&resp, p, "CRCX");
add_header(&resp, "C", sub->callid);
add_header(&resp, "L", local);
add_header(&resp, "M", "inactive");
{
struct mgcp_request resp;
struct mgcp_endpoint *p = sub->parent;
+ unsigned int oseq;
ast_debug(3, "MGCP Asked to indicate tone: %s on %s@%s-%d in cxmode: %s\n",
tone, p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode]);
ast_copy_string(p->curtone, tone, sizeof(p->curtone));
- reqprep(&resp, p, "RQNT");
+ oseq = reqprep(&resp, p, "RQNT");
add_header(&resp, "X", p->rqnt_ident);
switch (p->hookstate) {
case MGCP_ONHOOK:
struct timeval t = ast_tvnow();
struct ast_tm tm;
struct mgcp_endpoint *p = sub->parent;
+ unsigned int oseq;
ast_localtime(&t, &tm, NULL);
n = callername;
snprintf(tone2, sizeof(tone2), "%s,L/ci(%02d/%02d/%02d/%02d,%s,%s)", tone,
tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, l, n);
ast_copy_string(p->curtone, tone, sizeof(p->curtone));
- reqprep(&resp, p, "RQNT");
+ oseq = reqprep(&resp, p, "RQNT");
add_header(&resp, "X", p->rqnt_ident);
switch (p->hookstate) {
case MGCP_ONHOOK:
int fc = 1;
char local[256];
char tmp[80];
+ unsigned int oseq;
if (ast_strlen_zero(sub->cxident)) {
/* We don't have a CXident yet, store the destination and
}
}
- reqprep(&resp, p, "MDCX");
+ oseq = reqprep(&resp, p, "MDCX");
add_header(&resp, "C", sub->callid);
if (!sub->sdpsent) {
add_header(&resp, "L", local);
static int transmit_audit_endpoint(struct mgcp_endpoint *p)
{
struct mgcp_request resp;
- reqprep(&resp, p, "AUEP");
+ unsigned int oseq;
+ oseq = reqprep(&resp, p, "AUEP");
/* removed unknown param VS */
/*add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,E,MD,M");*/
add_header(&resp, "F", "A");
{
struct mgcp_endpoint *p = sub->parent;
struct mgcp_request resp;
+ unsigned int oseq;
ast_debug(3, "Delete connection %s %s@%s-%d with new mode: %s on callid: %s\n",
sub->cxident, p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode], sub->callid);
- reqprep(&resp, p, "DLCX");
+ oseq = reqprep(&resp, p, "DLCX");
/* check if call id is avail */
if (sub->callid[0])
add_header(&resp, "C", sub->callid);
static int transmit_connection_del_w_params(struct mgcp_endpoint *p, char *callid, char *cxident)
{
struct mgcp_request resp;
+ unsigned int oseq;
ast_debug(3, "Delete connection %s %s@%s on callid: %s\n",
cxident ? cxident : "", p->name, p->parent->name, callid ? callid : "");
- reqprep(&resp, p, "DLCX");
+ oseq = reqprep(&resp, p, "DLCX");
/* check if call id is avail */
if (callid && *callid)
add_header(&resp, "C", callid);