1
1
//
2
2
// This file is part of Dire Wolf, an amateur radio packet TNC.
3
3
//
4
- // Copyright (C) 2016 John Langner, WB2OSZ
4
+ // Copyright (C) 2016, 2017 John Langner, WB2OSZ
5
5
//
6
6
// This program is free software: you can redistribute it and/or modify
7
7
// it under the terms of the GNU General Public License as published by
59
59
60
60
61
61
static packet_t cdigipeat_match (int from_chan , packet_t pp , char * mycall_rec , char * mycall_xmit ,
62
- regex_t * alias , int to_chan , char * filter_str );
62
+ int has_alias , regex_t * alias , int to_chan , char * cfilter_str );
63
63
64
64
65
65
/*
@@ -149,9 +149,10 @@ void cdigipeater (int from_chan, packet_t pp)
149
149
packet_t result ;
150
150
151
151
result = cdigipeat_match (from_chan , pp , save_audio_config_p -> achan [from_chan ].mycall ,
152
- save_audio_config_p -> achan [to_chan ].mycall ,
153
- & save_cdigi_config_p -> alias [from_chan ][to_chan ], to_chan ,
154
- save_cdigi_config_p -> filter_str [from_chan ][to_chan ]);
152
+ save_audio_config_p -> achan [to_chan ].mycall ,
153
+ save_cdigi_config_p -> has_alias [from_chan ][to_chan ],
154
+ & (save_cdigi_config_p -> alias [from_chan ][to_chan ]), to_chan ,
155
+ save_cdigi_config_p -> cfilter_str [from_chan ][to_chan ]);
155
156
if (result != NULL ) {
156
157
tq_append (to_chan , TQ_PRIO_0_HI , result );
157
158
cdigi_count [from_chan ][to_chan ]++ ;
@@ -171,9 +172,10 @@ void cdigipeater (int from_chan, packet_t pp)
171
172
packet_t result ;
172
173
173
174
result = cdigipeat_match (from_chan , pp , save_audio_config_p -> achan [from_chan ].mycall ,
174
- save_audio_config_p -> achan [to_chan ].mycall ,
175
- & save_cdigi_config_p -> alias [from_chan ][to_chan ], to_chan ,
176
- save_cdigi_config_p -> filter_str [from_chan ][to_chan ]);
175
+ save_audio_config_p -> achan [to_chan ].mycall ,
176
+ save_cdigi_config_p -> has_alias [from_chan ][to_chan ],
177
+ & (save_cdigi_config_p -> alias [from_chan ][to_chan ]), to_chan ,
178
+ save_cdigi_config_p -> cfilter_str [from_chan ][to_chan ]);
177
179
if (result != NULL ) {
178
180
tq_append (to_chan , TQ_PRIO_0_HI , result );
179
181
cdigi_count [from_chan ][to_chan ]++ ;
@@ -203,12 +205,15 @@ void cdigipeater (int from_chan, packet_t pp)
203
205
* packet is to be transmitted. Could be the same as
204
206
* mycall_rec or different.
205
207
*
206
- * alias - Compiled pattern for my station aliases.
207
- * Could be NULL if no aliases.
208
+ * has_alias - True if we have an alias.
209
+ *
210
+ * alias - Optional compiled pattern for my station aliases.
211
+ * Do NOT attempt to use this if 'has_alias' is false.
208
212
*
209
213
* to_chan - Channel number that we are transmitting to.
210
214
*
211
- * filter_str - Filter expression string or NULL.
215
+ * cfilter_str - Filter expression string for the from/to channel pair or NULL.
216
+ * Note that only a subset of the APRS filters are applicable here.
212
217
*
213
218
* Returns: Packet object for transmission or NULL.
214
219
* The original packet is not modified. The caller is responsible for freeing it.
@@ -227,20 +232,38 @@ void cdigipeater (int from_chan, packet_t pp)
227
232
228
233
229
234
static packet_t cdigipeat_match (int from_chan , packet_t pp , char * mycall_rec , char * mycall_xmit ,
230
- regex_t * alias , int to_chan , char * filter_str )
235
+ int has_alias , regex_t * alias , int to_chan , char * cfilter_str )
231
236
{
232
237
int r ;
233
238
char repeater [AX25_MAX_ADDR_LEN ];
234
239
int err ;
235
240
char err_msg [100 ];
236
241
242
+ #if DEBUG
243
+ text_color_set (DW_COLOR_DEBUG );
244
+ dw_printf ("cdigipeat_match (from_chan=%d, pp=%p, mycall_rec=%s, mycall_xmit=%s, has_alias=%d, alias=%p, to_chan=%d, cfilter_str=%s\n" ,
245
+ from_chan , pp , mycall_rec , mycall_xmit , has_alias , alias , to_chan , cfilter_str );
246
+ #endif
247
+
237
248
/*
238
249
* First check if filtering has been configured.
250
+ * Note that we have three different config file filter commands:
251
+ *
252
+ * FILTER - APRS digipeating and IGate client side.
253
+ * Originally this was the only one.
254
+ * Should we change it to AFILTER to make it clearer?
255
+ * CFILTER - Similar for connected moded digipeater.
256
+ * IGFILTER - APRS-IS (IGate) server side - completely diffeent.
257
+ * Confusing with similar name but much different idea.
258
+ * Maybe this should be renamed to SUBSCRIBE or something like that.
259
+ *
260
+ * Logically this should come later, after an address/alias match.
261
+ * But here we only have to do it once.
239
262
*/
240
263
241
- if (filter_str != NULL ) {
264
+ if (cfilter_str != NULL ) {
242
265
243
- if (pfilter (from_chan , to_chan , filter_str , pp , 0 ) != 1 ) {
266
+ if (pfilter (from_chan , to_chan , cfilter_str , pp , 0 ) != 1 ) {
244
267
return (NULL );
245
268
}
246
269
}
@@ -286,7 +309,11 @@ static packet_t cdigipeat_match (int from_chan, packet_t pp, char *mycall_rec, c
286
309
/*
287
310
* If we have an alias match, substitute MYCALL.
288
311
*/
289
- if (alias != NULL ) {
312
+ if (has_alias ) {
313
+ #if DEBUG
314
+ text_color_set (DW_COLOR_DEBUG );
315
+ dw_printf ("Checking %s for alias match.\n" , repeater );
316
+ #endif
290
317
err = regexec (alias ,repeater ,0 ,NULL ,0 );
291
318
if (err == 0 ) {
292
319
packet_t result ;
@@ -304,6 +331,12 @@ static packet_t cdigipeat_match (int from_chan, packet_t pp, char *mycall_rec, c
304
331
dw_printf ("%s\n" , err_msg );
305
332
}
306
333
}
334
+ else {
335
+ #if DEBUG
336
+ text_color_set (DW_COLOR_DEBUG );
337
+ dw_printf ("No alias was specified.\n" );
338
+ #endif
339
+ }
307
340
308
341
/*
309
342
* Don't repeat it if we get here.
0 commit comments