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

Bugfix Third Party Filtering #433

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion src/kissutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
#include "kiss_frame.h"
#include "dwsock.h"
#include "audio.h" // for DEFAULT_TXDELAY, etc.
#include "dtime_now.h"


// TODO: define in one place, use everywhere.
Expand Down
40 changes: 27 additions & 13 deletions src/pfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void next_token (pfstate_t *pf);
static void print_error (pfstate_t *pf, char *msg);

static int filt_bodgu (pfstate_t *pf, char *pattern);
static int filt_t (pfstate_t *pf);
static int filt_t (pfstate_t *pf, char * typeChar);
static int filt_r (pfstate_t *pf, char *sdist);
static int filt_s (pfstate_t *pf);
static int filt_i (pfstate_t *pf);
Expand Down Expand Up @@ -201,6 +201,7 @@ int pfilter (int from_chan, int to_chan, char *filter, packet_t pp, int is_aprs)
char *p;
int result;


assert (from_chan >= 0 && from_chan <= MAX_CHANS);
assert (to_chan >= 0 && to_chan <= MAX_CHANS);

Expand Down Expand Up @@ -547,13 +548,11 @@ static int parse_filter_spec (pfstate_t *pf)

else if (pf->token_str[0] == 'b' && ispunct(pf->token_str[1])) {
/* Budlist - source address */
char addr[AX25_MAX_ADDR_LEN];
ax25_get_addr_with_ssid (pf->pp, AX25_SOURCE, addr);
result = filt_bodgu (pf, addr);
result = filt_bodgu (pf, pf->decoded.g_src);

if (s_debug >= 2) {
text_color_set(DW_COLOR_DEBUG);
dw_printf (" %s returns %s for %s\n", pf->token_str, bool2text(result), addr);
dw_printf (" %s returns %s for %s\n", pf->token_str, bool2text(result), pf->decoded.g_src);
}
}

Expand Down Expand Up @@ -671,15 +670,12 @@ static int parse_filter_spec (pfstate_t *pf)
/* t - type: position, weather, etc. */

else if (pf->token_str[0] == 't' && ispunct(pf->token_str[1])) {

result = filt_t (pf);
char typeChar = 0;
result = filt_t (pf, &typeChar);

if (s_debug >= 2) {
char *infop = NULL;
(void) ax25_get_info (pf->pp, (unsigned char **)(&infop));

text_color_set(DW_COLOR_DEBUG);
dw_printf (" %s returns %s for %c data type indicator\n", pf->token_str, bool2text(result), *infop);
dw_printf (" %s returns %s for %c data type indicator\n", pf->token_str, bool2text(result), typeChar);
}
}

Expand Down Expand Up @@ -857,18 +853,35 @@ int is_telem_metadata (char *infop)
}


static int filt_t (pfstate_t *pf)
static int filt_t (pfstate_t *pf, char * typeChar)
{
char src[AX25_MAX_ADDR_LEN];
char *infop = NULL;
char *f;
int isThirdParty = 0;

memset (src, 0, sizeof(src));
ax25_get_addr_with_ssid (pf->pp, AX25_SOURCE, src);
(void) ax25_get_info (pf->pp, (unsigned char **)(&infop));

if (*infop == '}') {
// We have a 3d party packet, dig inside it to get the actual type.
packet_t pp_payload = ax25_from_text ((char*)infop+1, 0);
if (pp_payload == NULL) {
print_error (pf, "Invalid third party payload\n");
return (0);
}
memset (src, 0, sizeof(src));
ax25_get_addr_with_ssid (pp_payload, AX25_SOURCE, src);
(void) ax25_get_info (pp_payload, (unsigned char **)(&infop));
ax25_delete(pp_payload);
isThirdParty = 1;
}

assert (infop != NULL);

*typeChar = *infop;

for (f = pf->token_str + 2; *f != '\0'; f++) {
switch (*f) {

Expand Down Expand Up @@ -920,7 +933,8 @@ static int filt_t (pfstate_t *pf)
break;

case 'h': /* third party Header - my extension */
if (*infop == '}') return (1);
*typeChar = '}';
return (isThirdParty);
break;

case 'w': /* Weather */
Expand Down