Point pb->qconst_start where it belongs - to the q in the Q construct.

git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@205 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
Heikki Hannikainen 2008-03-21 17:29:34 +00:00
parent 24ccaefda9
commit 7237ce7f88
3 changed files with 29 additions and 8 deletions

View File

@ -377,6 +377,7 @@ int incoming_parse(struct worker_t *self, struct client_t *c, char *s, int len)
const char *info_end; /* end of the info */
char *dstcall_end; /* end of dstcall ([:,]) */
char *via_start; /* start of the digipeater path (after dstcall,) */
char *q_start = NULL; /* start of the Q construct (points to the 'q') */
const char *data; /* points to original incoming path/payload separating ':' character */
int datalen; /* length of the data block excluding tail \r\n */
int pathlen; /* length of the path == data-s */
@ -446,7 +447,7 @@ int incoming_parse(struct worker_t *self, struct client_t *c, char *s, int len)
* to the end of the path later
*/
path_append_len = q_process( c, path_append, sizeof(path_append),
via_start, &path_end, pathlen,
via_start, &path_end, pathlen, &q_start,
originated_by_client );
if (path_append_len < 0) {
@ -473,14 +474,23 @@ int incoming_parse(struct worker_t *self, struct client_t *c, char *s, int len)
/* Copy the unmodified part of the packet header */
memcpy(pb->data, s, path_end - s);
p = pb->data + (path_end - s);
pb->qconst_start = p; // FIXME: wrong pointer.. usually couple tokens beyond qcons...
// Used by d- and e-filters.
/* If q_process left q_start unmodified (as NULL), it wants to say
* that it produced a new Q construct, which is returned in
* path_append. If it points somewhere in the header, then fine,
* it points to an existing Q construct.
*/
if (q_start == NULL && path_append_len > 0)
pb->qconst_start = p + 1;
else if (q_start > s && q_start < path_end)
pb->qconst_start = q_start;
/* Copy the modified or appended part of the packet header -- qcons */
memcpy(p, path_append, path_append_len);
p += path_append_len;
// hlog(LOG_DEBUG, "q construct: %.*s", 3, pb->qconst_start);
/* Copy the unmodified end of the packet (including the :) */
memcpy(p, info_start - 1, datalen);
info_start = p + 1;
@ -501,8 +511,8 @@ int incoming_parse(struct worker_t *self, struct client_t *c, char *s, int len)
pb->dstcall_len = via_start - src_end - 1;
pb->info_start = info_start;
// hlog(LOG_DEBUG, "After parsing and Qc algorithm: %.*s", pb->packet_len-2, pb->data);
// hlog(LOG_DEBUG, "After parsing and Qc algorithm: %.*s", pb->packet_len-2, pb->data);
/* just try APRS parsing */
rc = parse_aprs(self, pb);

View File

@ -195,7 +195,8 @@ int q_dropcheck(struct client_t *c, char *new_q, int new_q_size,
* reuse some code snippets.
*/
int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start, char **path_end, int pathlen, int originated_by_client)
int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
char **path_end, int pathlen, char **new_q_start, int originated_by_client)
{
char *q_start = NULL; /* points to the , before the Q construct */
char *q_nextcall = NULL; /* points to the , after the Q construct */
@ -354,6 +355,8 @@ int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
*(q_start + 3) = 'o';
q_type = 'o';
// fprintf(stderr, "\treplaced qAR with qAo\n");
/* Not going to modify the construct, update pointer to it */
*new_q_start = q_start + 1;
}
} else if (pathlen > 2 && *(*path_end -1) == 'I' && *(*path_end -2) == ',') {
// fprintf(stderr, "\tpath has ,I in the end\n");
@ -389,6 +392,7 @@ int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
q_proto = 'A';
q_type = 'O';
}
/* Skip to "All packets with q constructs" */
return q_dropcheck(c, new_q, new_q_size, new_q_len, q_proto, q_type, q_start, *path_end);
}
@ -399,6 +403,8 @@ int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
*/
if (q_proto) {
// fprintf(stderr, "\texisting q construct\n");
/* Not going to modify the construct, update pointer to it */
*new_q_start = q_start + 1;
/* Skip to "All packets with q constructs" */
return q_dropcheck(c, new_q, new_q_size, new_q_len, q_proto, q_type, q_start, *path_end);
}
@ -513,6 +519,10 @@ int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
}
}
/* If we haven't generated a new Q construct, return a pointer to the existing one */
if (!new_q_len)
*new_q_start = q_start + 1;
return q_dropcheck(c, new_q, new_q_size, new_q_len, q_proto, q_type, q_start, *path_end);
}

View File

@ -24,6 +24,7 @@
#include "worker.h" /* struct client_t */
extern int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start, char **path_end, int pathlen, int originated_by_client);
extern int q_process(struct client_t *c, char *new_q, int new_q_size, char *via_start,
char **path_end, int pathlen, char **new_q_start, int originated_by_client);
#endif