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

app_rpt: Correct 5 digit node lookup from 4 digit node #372

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions apps/app_rpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ static int nrpts = 0;

/* general settings */
enum rpt_dns_method rpt_node_lookup_method = DEFAULT_NODE_LOOKUP_METHOD;
int rpt_max_dns_node_length = 6;

int max_chan_stat[] = { 22000, 1000, 22000, 100, 22000, 2000, 22000 };

Expand Down Expand Up @@ -5537,6 +5538,17 @@ static int load_config(int reload)
rpt_node_lookup_method = DEFAULT_NODE_LOOKUP_METHOD;
}
}
val = (char *) ast_variable_retrieve(cfg, "general", "max_dns_node_length");
if (val) {
i = atoi(val);
if (i < 4) {
i = 4;
}
if (i > 63) {
i = 63;
}
rpt_max_dns_node_length = i;
}

/* process the sections looking for the nodes */
while ((this = ast_category_browse(cfg, this)) != NULL) {
Expand Down
9 changes: 7 additions & 2 deletions apps/app_rpt/rpt_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

extern struct rpt rpt_vars[MAXRPTS];
extern enum rpt_dns_method rpt_node_lookup_method;
extern int rpt_max_dns_node_length;

static struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS };

Expand Down Expand Up @@ -399,13 +400,15 @@ static int node_lookup_bydns(const char *node, char *nodedata, size_t nodedatale
return -1;
}
if (!result) {
ast_debug(4, "No SRV results returned for %s\n", domain);
return -1;
}

/* get the response */
record = ast_dns_result_get_records(result);

if(!record) {
ast_debug(4, "No SRV records returned for %s\n", domain);
ast_dns_result_free(result);
return -1;
}
Expand All @@ -422,12 +425,14 @@ static int node_lookup_bydns(const char *node, char *nodedata, size_t nodedatale
return -1;
}
if (!result) {
ast_debug(4, "No A results returned for %s\n", hostname);
return -1;
}

/* get the response */
record = ast_dns_result_get_records(result);
if (!record) {
ast_debug(4, "No A records returned for %s\n", hostname);
ast_dns_result_free(result);
return -1;
}
Expand Down Expand Up @@ -615,7 +620,7 @@ int node_lookup(struct rpt *myrpt, char *digitbuf, char *nodedata, size_t nodeda
}
ast_config_destroy(ourcfg);
}
myrpt->longestnode = longestnode;
myrpt->longestnode = MAX(longestnode, rpt_max_dns_node_length);
ast_mutex_unlock(&nodelookuplock);
}

Expand Down Expand Up @@ -1139,7 +1144,7 @@ void load_rpt_vars(int n, int init)
vp = vp->next;
}

rpt_vars[n].longestnode = longestnode;
rpt_vars[n].longestnode = MAX(longestnode, rpt_max_dns_node_length);

/* For this repeater, Determine the length of the longest function */
rpt_vars[n].longestfunc = 0;
Expand Down
Loading