Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http registration #1

Open
wants to merge 59 commits into
base: Development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
8e66fc8
merge simple voter code from XIPAR
ajpaul25 Nov 26, 2019
fbdeee6
merge simple voter code from XIPAR
ajpaul25 Nov 26, 2019
a7be905
merge telemetry ducking code from XIPAR
ajpaul25 Nov 26, 2019
ae6d6f4
add rssi and rxchankeyed struct elements
ajpaul25 Nov 27, 2019
43814eb
Replace code that is only relevant to simple voter
ajpaul25 Nov 27, 2019
8b12c5a
add asl-reg utility
ajpaul25 Dec 4, 2019
0a30c92
integrate changes from dvswitch
ajpaul25 Dec 4, 2019
ae91fab
random delay improvements
ajpaul25 Dec 4, 2019
5f66d40
parse json responses
ajpaul25 Dec 4, 2019
75be6cd
add sample config for asl-reg
ajpaul25 Dec 5, 2019
e40d384
remove register line from iax.conf
ajpaul25 Dec 5, 2019
ab90ef3
handle buffer overflows
ajpaul25 Dec 5, 2019
895c9a3
fix telemetry ducking for local rx
ajpaul25 Dec 7, 2019
8ce13d4
fix ducking attribution, bump version
ajpaul25 Dec 8, 2019
bf93578
keep register line, but include a message suggesting http registration
ajpaul25 Dec 15, 2019
ad885d0
version bump
ajpaul25 Dec 16, 2019
cd8c7f9
update inline_api from upstream asterisk for compatibility with moder…
ajpaul25 Jul 27, 2020
4d10882
add debian build directory from asterisk-debian git circa v1.4.21
ajpaul25 Aug 2, 2020
0c17692
remove package build patches
ajpaul25 Aug 2, 2020
dcd0d9f
adjust pacage build dependencies
ajpaul25 Aug 2, 2020
c5cf71e
adjust package build configure arguments
ajpaul25 Aug 2, 2020
3347e4c
remove docs and h323 from package build
ajpaul25 Aug 2, 2020
5ba60e9
remove agi from examples
ajpaul25 Aug 2, 2020
19dd2c8
increase debhelper compatibility level
ajpaul25 Aug 2, 2020
78b1958
remove h323 voodoo
ajpaul25 Aug 2, 2020
33138a7
skip upstream changelog step
ajpaul25 Aug 2, 2020
d815ccd
remove broken examples from package build
ajpaul25 Aug 2, 2020
60ed4f7
remove h323 from debian control file
ajpaul25 Aug 2, 2020
a07e567
substitute libtonezone2.0 dependency for asl-libtonezone2.0
ajpaul25 Aug 2, 2020
bb758e3
reset ASTERISK_FILE_VERSION revision numbers
ajpaul25 Aug 2, 2020
1e74a24
align with upstream 1.4 code from 10-6-2008, git commit 3c576b42625f2…
ajpaul25 Aug 2, 2020
cdf3f14
update debhelper compatibility level and change non-functioning overr…
ajpaul25 Aug 2, 2020
51c7937
change dependency back to non-asl libtonezone
ajpaul25 Aug 3, 2020
33d6054
change package naming convention to asl-asterisk
ajpaul25 Aug 3, 2020
8cdef79
Merge pull request #4 from ajpaul25/debian_packaging
ajpaul25 Aug 5, 2020
a652510
fix old (non-asl) asterisk deps
ajpaul25 Aug 7, 2020
54742ed
package version bump
ajpaul25 Aug 7, 2020
bba1f5b
rename packaging files to match new package names
ajpaul25 Aug 7, 2020
782d7ac
update path to new directories
ajpaul25 Aug 7, 2020
9804c5f
additional cleanup due to do package rename
ajpaul25 Aug 8, 2020
2274162
fix badly formatted trailer line
ajpaul25 Aug 8, 2020
93b9d1d
version bump
ajpaul25 Aug 8, 2020
3d29bf4
fix badly formatted trailer line
ajpaul25 Aug 8, 2020
ddcf1d2
fix badly formatted trailer line
ajpaul25 Aug 8, 2020
a0efa92
create makefile for external utilities
ajpaul25 Aug 9, 2020
90c38c4
add debian packaging
ajpaul25 Aug 9, 2020
db2ea7b
add necessary dirs for packaging
ajpaul25 Aug 9, 2020
820d939
Add necessary trailing slash to install command
ajpaul25 Aug 9, 2020
9b2a05e
update control file
ajpaul25 Aug 9, 2020
ea590a1
remove template line from readme
ajpaul25 Aug 9, 2020
5d3ef65
Merge pull request #5 from ajpaul25/debian_packaging
ajpaul25 Aug 12, 2020
720c07c
Merge pull request #6 from ajpaul25/simple_voter
ajpaul25 Aug 12, 2020
b8045c6
Merge pull request #7 from ajpaul25/upstream_alignment
ajpaul25 Aug 12, 2020
8122a99
Merge branch 'develop' into telemetry_ducking
ajpaul25 Aug 12, 2020
c66b7e5
Merge pull request #8 from ajpaul25/telemetry_ducking
ajpaul25 Aug 12, 2020
d5a0750
switch allstar-helpers to /usr/sbin
ajpaul25 Aug 12, 2020
4f8a5f7
add backup-server to package
ajpaul25 Aug 12, 2020
e93a8cc
Merge pull request #9 from ajpaul25/debian_packaging
ajpaul25 Aug 12, 2020
ba36cc0
Merge branch 'develop' into http_registration
ajpaul25 Aug 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 222 additions & 2 deletions asterisk/apps/app_rpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ struct rpt_link
long retxtimer;
long rerxtimer;
long rxlingertimer;
int rssi;
int retries;
int max_retries;
int reconnects;
Expand All @@ -885,6 +886,8 @@ struct rpt_link
int linkmode;
int newkeytimer;
char gott;
int voterlink; /*!< \brief set if node is defined as a voter rx */
int votewinner; /*!< \brief set if node won the rssi competition */
time_t lastkeytime;
time_t lastunkeytime;
#ifdef OLD_ASTERISK
Expand Down Expand Up @@ -1201,6 +1204,9 @@ static struct rpt
int gpsfeet;
int default_split_2m;
int default_split_70cm;
int votertype; /*!< \brief 0 none, 1 repeater, 2 voter rx */
int votermode; /*!< \brief 0 none, 1 one shot, 2 continuous */
int votermargin; /*!< \brief rssi margin to win a vote */
int dtmfkey;
char dias;
char dusbabek;
Expand All @@ -1224,6 +1230,7 @@ static struct rpt
time_t lasttxkeyedtime;
char keyed;
char txkeyed;
char rxchankeyed; /*!< \brief Receiver RxChan Key State */
char exttx;
char localtx;
char remrx;
Expand Down Expand Up @@ -1343,6 +1350,13 @@ static struct rpt
char dtmfkeybuf[MAXDTMF];
char sleepreq;
char sleep;
struct rpt_link *voted_link; /*!< \brief last winning link or NULL */
int rxrssi; /*!< \brief rx rssi from the rxchannel */
int voted_rssi; /*!< \brief last winning rssi */
int vote_counter; /*!< \brief count to frame used to vote the winner */
int voter_oneshot;
int votewinner;
int voteremrx; /* 0 no voters are keyed, 1 at least one voter is keyed */
char lastdtmfuser[MAXNODESTR];
char curdtmfuser[MAXNODESTR];
int sleeptimer;
Expand Down Expand Up @@ -4316,6 +4330,69 @@ static int linkcount(struct rpt *myrpt)
// ast_log(LOG_NOTICE, "numoflinks=%i\n",numoflinks);
return numoflinks;
}
/* Considers repeater received RSSI and all voter link RSSI information and
set values in myrpt structure.
*/
static int FindBestRssi(struct rpt *myrpt)
{
struct rpt_link *l;
struct rpt_link *bl;
int maxrssi;
int numoflinks;
char newboss;

bl=NULL;
maxrssi=0;
numoflinks=0;
newboss=0;

myrpt->voted_rssi=0;
if(myrpt->votewinner&&myrpt->rxchankeyed)
myrpt->voted_rssi=myrpt->rxrssi;
else if(myrpt->voted_link!=NULL && myrpt->voted_link->lastrealrx)
myrpt->voted_rssi=myrpt->voted_link->rssi;

if(myrpt->rxchankeyed)
maxrssi=myrpt->rxrssi;

l = myrpt->links.next;
while(l && (l != &myrpt->links)){
if(numoflinks >= MAX_STAT_LINKS){
ast_log(LOG_WARNING,
"[%s] number of links exceeds limit of %d \n",myrpt->name,MAX_STAT_LINKS);
break;
}
if(l->lastrealrx && (l->rssi > maxrssi))
{
maxrssi=l->rssi;
bl=l;
}
l->votewinner=0;
numoflinks++;
l = l->next;
}

if( !myrpt->voted_rssi ||
(myrpt->voted_link==NULL && !myrpt->votewinner) ||
(maxrssi>(myrpt->voted_rssi+myrpt->p.votermargin))
)
{
newboss=1;
myrpt->votewinner=0;
if(bl==NULL && myrpt->rxchankeyed)
myrpt->votewinner=1;
else if(bl!=NULL)
bl->votewinner=1;
myrpt->voted_link=bl;
myrpt->voted_rssi=maxrssi;
}

if(debug>4)
ast_log(LOG_NOTICE,"[%s] links=%i best rssi=%i from %s%s\n",
myrpt->name,numoflinks,maxrssi,bl==NULL?"rpt":bl->name,newboss?"*":"");

return numoflinks;
}
/*
* Retrieve a memory channel
* Return 0 if sucessful,
Expand Down Expand Up @@ -4756,6 +4833,39 @@ char str[200];
return;
}

/*
rssi_send() Send rx rssi out on all links.
*/
static void rssi_send(struct rpt *myrpt)
{
struct rpt_link *l;
struct ast_frame wf;
char str[200];
sprintf(str,"R %i",myrpt->rxrssi);
wf.frametype = AST_FRAME_TEXT;
wf.subclass = 0;
wf.offset = 0;
wf.mallocd = 0;
wf.datalen = strlen(str) + 1;
wf.samples = 0;
wf.src = "rssi_send";

l = myrpt->links.next;
/* otherwise, send it to all of em */
while(l != &myrpt->links)
{
if (l->name[0] == '0')
{
l = l->next;
continue;
}
wf.data = str;
if(debug>5)ast_log(LOG_NOTICE, "[%s] rssi=%i to %s\n", myrpt->name,myrpt->rxrssi,l->name);
if (l->chan) rpt_qwrite(l,&wf);
l = l->next;
}
}

static void mdc1200_cmd(struct rpt *myrpt, char *data)
{
char busy,*myval;
Expand Down Expand Up @@ -6352,6 +6462,17 @@ static char *cs_keywords[] = {"rptena","rptdis","apena","apdis","lnkena","lnkdis

}
#endif
val = (char *) ast_variable_retrieve(cfg,this,"votertype");
if (!val) val = "0";
rpt_vars[n].p.votertype=atoi(val);

val = (char *) ast_variable_retrieve(cfg,this,"votermode");
if (!val) val = "0";
rpt_vars[n].p.votermode=atoi(val);

val = (char *) ast_variable_retrieve(cfg,this,"votermargin");
if (!val) val = "10";
rpt_vars[n].p.votermargin=atoi(val);
val = (char *) ast_variable_retrieve(cfg,this,"telemdefault");
if (val) rpt_vars[n].p.telemdefault = atoi(val);
else rpt_vars[n].p.telemdefault = DEFAULT_RPT_TELEMDEFAULT;
Expand Down Expand Up @@ -9548,6 +9669,12 @@ struct mdcparams *mdcp;
imdone = 1;
break;
case LINKUNKEY:
/* if voting and a voter link unkeys but the main or another voter rx is still active */
if(myrpt->p.votertype==1 && (myrpt->rxchankeyed || myrpt->voteremrx ))
{
imdone = 1;
break;
}
if(myrpt->patchnoct && myrpt->callmode){ /* If no CT during patch configured, then don't send one */
imdone = 1;
break;
Expand Down Expand Up @@ -10765,6 +10892,11 @@ struct rpt_link *l;
break;
case UNKEY:
case LOCUNKEY:
/* if voting and the main rx unkeys but a voter link is still active */
if(myrpt->p.votertype==1 && (myrpt->rxchankeyed || myrpt->voteremrx ))
{
return;
}
if (myrpt->p.nounkeyct) return;
/* if any of the following are defined, go ahead and do it,
otherwise, dont bother */
Expand Down Expand Up @@ -11508,6 +11640,7 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
struct rpt_link *l;
int reconnects = 0;
int i,n;
int voterlink=0;
struct dahdi_confinfo ci; /* conference info */

if (strlen(node) < 1) return 1;
Expand Down Expand Up @@ -11566,6 +11699,11 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
s1 = sx;
}
s2 = strsep(&s,",");
}
if(s && strcmp(s,"VOTE")==0)
{
voterlink=1;
if(debug)ast_log(LOG_NOTICE,"NODE is a VOTER.\n");
}
rpt_mutex_lock(&myrpt->lock);
l = myrpt->links.next;
Expand Down Expand Up @@ -11639,6 +11777,7 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
l->newkeytimer = NEWKEYTIME;
l->iaxkey = 0;
l->newkey = 2;
l->voterlink=voterlink;
if (strncasecmp(s1,"echolink/",9) == 0) l->newkey = 0;
#ifdef ALLOW_LOCAL_CHANNELS
if ((strncasecmp(s1,"iax2/", 5) == 0) || (strncasecmp(s1, "local/", 6) == 0) ||
Expand Down Expand Up @@ -19568,6 +19707,7 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
myrpt->wasvox = 0;
myrpt->linkactivityflag = 0;
myrpt->linkactivitytimer = 0;
myrpt->vote_counter=10;
myrpt->rptinactwaskeyedflag = 0;
myrpt->rptinacttimer = 0;
if (myrpt->p.rxburstfreq)
Expand Down Expand Up @@ -19726,6 +19866,7 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
myrpt->name,lat,lon,elev);
rpt_mutex_lock(&myrpt->lock);
l = myrpt->links.next;
myrpt->voteremrx = 0; /* no voter remotes keyed */
while(l != &myrpt->links)
{
if (l->chan) ast_sendtext(l->chan,tmpstr);
Expand All @@ -19743,6 +19884,7 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
{
if (l->lastrx){
myrpt->remrx = 1;
if(l->voterlink)myrpt->voteremrx=1;
if ((l->name[0] > '0') && (l->name[0] <= '9')) /* Ignore '0' nodes */
strcpy(myrpt->lastnodewhichkeyedusup, l->name); /* Note the node which is doing the key up */
}
Expand Down Expand Up @@ -20699,6 +20841,35 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
if (debug) printf("@@@@ rpt:Hung Up\n");
break;
}

if(f->frametype == AST_FRAME_TEXT && myrpt->rxchankeyed)
{
char myrxrssi[32];

if(sscanf((char *)f->data, "R %s", myrxrssi) == 1)
{
myrpt->rxrssi=atoi(myrxrssi);
if(debug>7)ast_log(LOG_NOTICE,"[%s] rxchannel rssi=%i\n",
myrpt->name,myrpt->rxrssi);
if(myrpt->p.votertype==2)
rssi_send(myrpt);
}
}

/* if out voted drop DTMF frames */
if( myrpt->p.votermode &&
!myrpt->votewinner &&

( f->frametype == AST_FRAME_DTMF_BEGIN ||
f->frametype == AST_FRAME_DTMF_END
)
)
{
rpt_mutex_unlock(&myrpt->lock);
ast_frfree(f);
continue;
}

if (f->frametype == AST_FRAME_VOICE)
{
#ifdef _MDC_DECODE_H_
Expand Down Expand Up @@ -20860,6 +21031,40 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
}
if (dtmfed) ismuted = 1;
dtmfed = 0;

if(myrpt->p.votertype==1)
{
if(!myrpt->rxchankeyed)
myrpt->votewinner=0;

if(!myrpt->voteremrx)
myrpt->voted_link=NULL;

if(!myrpt->rxchankeyed&&!myrpt->voteremrx)
{
myrpt->voter_oneshot=0;
myrpt->voted_rssi=0;
}
}

if( myrpt->p.votertype==1 && myrpt->vote_counter && (myrpt->rxchankeyed||myrpt->voteremrx)
&& (myrpt->p.votermode==2||(myrpt->p.votermode==1&&!myrpt->voter_oneshot))
)
{
if(--myrpt->vote_counter<=0)
{
myrpt->vote_counter=10;
if(debug>6)ast_log(LOG_NOTICE,"[%s] vote rxrssi=%i\n",
myrpt->name,myrpt->rxrssi);
FindBestRssi(myrpt);
myrpt->voter_oneshot=1;
}
}
/* if a voting rx and not the winner, mute audio */
if(myrpt->p.votertype==1 && myrpt->voted_link!=NULL)
{
ismuted=1;
}
if (ismuted)
{
memset(AST_FRAME_DATAP(f),0,f->datalen);
Expand Down Expand Up @@ -21068,6 +21273,8 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
/* if RX un-key */
if (f->subclass == AST_CONTROL_RADIO_UNKEY)
{
/* clear rx channel rssi */
myrpt->rxrssi=0;
char asleep = myrpt->p.s[myrpt->p.sysstate_cur].sleepena & myrpt->sleep;

if ((!lasttx) || (myrpt->p.duplex > 1) || (myrpt->p.linktolink))
Expand Down Expand Up @@ -21352,7 +21559,7 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
if (l->mode != 1) totx = 0;
if (l->phonemode == 0 && l->chan && (l->lasttx != totx))
{
if (totx)
if ( totx && !l->voterlink)
{
if (l->newkey < 2) ast_indicate(l->chan,AST_CONTROL_RADIO_KEY);
}
Expand Down Expand Up @@ -21575,6 +21782,13 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
(!strncasecmp(l->chan->name,"echolink",8)) ||
(!strncasecmp(l->chan->name,"tlb",3)))) ismuted = 1;
l->dtmfed = 0;

/* if a voting rx link and not the winner, mute audio */
if(myrpt->p.votertype==1 && l->voterlink && myrpt->voted_link!=l)
{
ismuted=1;
}

if (ismuted)
{
memset(AST_FRAME_DATAP(f),0,f->datalen);
Expand Down Expand Up @@ -21603,7 +21817,13 @@ char tmpstr[300],lstr[MAXLINKLIST],lat[100],lon[100],elev[100];
}
else
{
if (!l->lastrx)
/* if a voting rx link and not the winner, mute audio */
if(myrpt->p.votertype==1 && l->voterlink && myrpt->voted_link!=l)
ismuted=1;
else
ismuted=0;

if ( !l->lastrx || ismuted )
memset(AST_FRAME_DATAP(f),0,f->datalen);
ast_write(l->pchan,f);
}
Expand Down
Loading