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

Add support for an info message on the EchoLink connect page #432

Merged
merged 24 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
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
66 changes: 37 additions & 29 deletions channels/chan_echolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ do not use 127.0.0.1
#define EL_IP_SIZE 16
#define EL_CALL_SIZE 12
#define EL_NAME_SIZE 32
#define EL_MESSAGE_SIZE 256
#define EL_APRS_SIZE 200
#define EL_PWD_SIZE 16
#define EL_EMAIL_SIZE 32
Expand Down Expand Up @@ -217,6 +218,7 @@ do not use 127.0.0.1

#define DELIMCHR ','
#define QUOTECHR 34
#define EL_INIT_BUFFER = sizeof("oNDATA\rWelcome to AllStar Node 123456\rEcholink Node 123456\rNumber \r \rSystems Linked: \r") + 300 /* initial string buffer size for ast_str buffer */
/*
* If you want to compile/link this code
* on "BIG-ENDIAN" platforms, then
Expand Down Expand Up @@ -384,6 +386,7 @@ struct el_instance {
char name[EL_NAME_SIZE];
char mycall[EL_CALL_SIZE];
char myname[EL_NAME_SIZE];
char mymessage[EL_MESSAGE_SIZE];
char mypwd[EL_PWD_SIZE];
char myemail[EL_EMAIL_SIZE];
char myqth[EL_QTH_SIZE];
Expand Down Expand Up @@ -859,7 +862,7 @@ static struct eldb *el_db_put(const char *nodenum, const char *ipaddr, const cha
* \param pkt_len Length of packet buffer
* \param call Pointer to callsign
* \param name Pointer to node name
* \param astnode Pointer to AllstarLink node number
* \param astnode Pointer to AllStarLink node number
* \retval 0 Unsuccessful - pkt to small
* \retval Successful length
*/
Expand Down Expand Up @@ -899,7 +902,7 @@ static int rtcp_make_sdes(unsigned char *pkt, int pkt_len, const char *call, con
ap += l;

if (astnode) {
snprintf(line, EL_CALL_SIZE + EL_NAME_SIZE, "Allstar %s", astnode);
snprintf(line, EL_CALL_SIZE + EL_NAME_SIZE, "AllStar %s", astnode);
*ap++ = 6;
*ap++ = l = strlen(line);
memcpy(ap, line, l);
Expand Down Expand Up @@ -1601,14 +1604,14 @@ static int el_text(struct ast_channel *ast, const char *text)
j = 0;
k = 0;
for (x = 0; x < i; x++) {
/* Process allstar node numbers - skip over those that begin with '3' which are echolink */
/* Process AllStar node numbers - skip over those that begin with '3' which are echolink */
if ((*(strs[x] + 1) != '3')) {
if (strlen(pkt + k) >= 32) {
k = strlen(pkt);
strncat(pkt, "\r ", pkt_len - k);
}
if (!j++) {
strncat(pkt, "Allstar:", pkt_len - strlen(pkt));
strncat(pkt, "AllStar:", pkt_len - strlen(pkt));
}
pkt_actual_len = strlen(pkt);
if (*strs[x] == 'T') {
Expand Down Expand Up @@ -1799,40 +1802,34 @@ static void lookup_node_callsign(const void *nodep, const VISIT which, void *clo
static void send_info(const void *nodep, const VISIT which, const int depth)
{
struct sockaddr_in sin;
char pkt[5120], *cp;
struct ast_str *pkt;
char *cp;
struct el_instance *instp = (*(struct el_node **) nodep)->instp;
int i, j;

if ((which == leaf) || (which == postorder)) {
pkt = ast_str_create(EL_INIT_BUFFER);
if (!pkt) {
return;
}

if ((which == leaf) || (which == postorder)) {
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(instp->audio_port);
sin.sin_addr.s_addr = inet_addr((*(struct el_node **) nodep)->ip);

i = snprintf(pkt, sizeof(pkt), "oNDATA\rWelcome to Allstar Node %s\r", instp->astnode);
if (i >= sizeof(pkt)) {
ast_log(LOG_WARNING, "Exceeded buffer size");
return;
}
j = snprintf(pkt + i, sizeof(pkt) - i, "Echolink Node %s\rNumber %u\r \r", instp->mycall, instp->mynode);
if (j >= sizeof(pkt) - i) {
ast_log(LOG_WARNING, "Exceeded buffer size");
return;

ast_str_set(pkt, 0, "oNDATA\rWelcome to AllStar Node %s\r", instp->astnode);
ast_str_append(pkt, 0, "Echolink Node %s\rNumber %u\r \r", instp->mycall, instp->mynode);

if (instp->mymessage[0] != '\0') {
ast_str_append(pkt, 0, "%s\n\n", instp->mymessage);
}

if ((*(struct el_node **) nodep)->pvt && (*(struct el_node **) nodep)->pvt->linkstr) {
i = strlen(pkt);
strncat(pkt + i, "Systems Linked:\r", sizeof(pkt) - i);
cp = ast_strdup((*(struct el_node **) nodep)->pvt->linkstr);
if (cp) {
i = strlen(pkt);
strncat(pkt + i, cp, sizeof(pkt) - i);
ast_free(cp);
}

if (cp = cp = (*(struct el_node **) nodep)->pvt ? (*(struct el_node **) nodep)->pvt->linkstr : NULL) {
ast_str_append(pkt, 0, "Systems Linked:\r%s", cp);
}
sendto(instp->audio_sock, pkt, strlen(pkt), 0, (struct sockaddr *) &sin, sizeof(sin));


sendto(instp->audio_sock, ast_str_buffer(pkt), ast_str_len(pkt), 0, (struct sockaddr *) &sin, sizeof(sin));
ast_free(pkt);
instp->tx_ctrl_packets++;
(*(struct el_node **) nodep)->tx_ctrl_packets++;
}
Expand Down Expand Up @@ -3818,6 +3815,17 @@ static int store_config(struct ast_config *cfg, char *ctg)
ast_copy_string(instp->myname, val, sizeof(instp->myname));
}

val = ast_variable_retrieve(cfg, ctg, "message");
ast_copy_string(instp->mymessage, S_OR(val, ""), sizeof(instp->mymessage));
if (instp->mymessage[0] != '\0') {
char *p = instp->mymessage;
while ((p = strstr(p, "\\n")) != NULL) {
*p = '\n'; /* Replace the literal \n with a newline character */
memmove(p + 1, p + 2, strlen(p + 2) + 1); /* Shift the string to remove the \n */
p++;
}
}

val = ast_variable_retrieve(cfg, ctg, "recfile");
if (!val) {
ast_copy_string(instp->fdr_file, "/tmp/echolink_recorded.gsm", FILENAME_MAX - 1);
Expand Down
3 changes: 3 additions & 0 deletions configs/rpt/echolink.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ height = 0 ; 0=10 1=20 2=40 3=80 4=160 5=320 6=640 7=1280 8=2560 9=5120 (A
gain = 0 ; Gain in db (0-9)
dir = 0 ; 0=omni 1=45deg 2=90deg 3=135deg 4=180deg 5=225deg 6=270deg 7=315deg 8=360deg (Direction)

; Message to show on the echolink connect page. Use \n for new lines.
; message = This is the first line\nThis is another line\nThis is another line

maxstns = 20 ; Max Stations

rtcptimeout = 10 ; Max number of missed heartbeats from EL
Expand Down