mirror of https://github.com/wb2osz/direwolf.git
Proper trimming at CR/LF for RF>IS IGate.
This commit is contained in:
parent
2fec597581
commit
7f77b29e89
54
ax25_pad.c
54
ax25_pad.c
|
@ -1578,9 +1578,9 @@ int ax25_get_rr (packet_t this_p, int n)
|
||||||
*
|
*
|
||||||
* Purpose: Obtain Information part of current packet.
|
* Purpose: Obtain Information part of current packet.
|
||||||
*
|
*
|
||||||
* Inputs: None.
|
* Inputs: this_p - Packet object pointer.
|
||||||
*
|
*
|
||||||
* Outputs: paddr - Starting address is returned here.
|
* Outputs: paddr - Starting address of information part is returned here.
|
||||||
*
|
*
|
||||||
* Assumption: ax25_from_text or ax25_from_frame was called first.
|
* Assumption: ax25_from_text or ax25_from_frame was called first.
|
||||||
*
|
*
|
||||||
|
@ -1621,6 +1621,56 @@ int ax25_get_info (packet_t this_p, unsigned char **paddr)
|
||||||
|
|
||||||
*paddr = info_ptr;
|
*paddr = info_ptr;
|
||||||
return (info_len);
|
return (info_len);
|
||||||
|
|
||||||
|
} /* end ax25_get_info */
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Name: ax25_cut_at_crlf
|
||||||
|
*
|
||||||
|
* Purpose: Truncate the information part at the first CR or LF.
|
||||||
|
* This is used for the RF>IS IGate function.
|
||||||
|
* CR/LF is used as record separator so we must remove it
|
||||||
|
* before packaging up packet to sending to server.
|
||||||
|
*
|
||||||
|
* Inputs: this_p - Packet object pointer.
|
||||||
|
*
|
||||||
|
* Outputs: Packet is modified in place.
|
||||||
|
*
|
||||||
|
* Returns: Number of characters removed from the end.
|
||||||
|
* 0 if not changed.
|
||||||
|
*
|
||||||
|
* Assumption: ax25_from_text or ax25_from_frame was called first.
|
||||||
|
*
|
||||||
|
*------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
int ax25_cut_at_crlf (packet_t this_p)
|
||||||
|
{
|
||||||
|
unsigned char *info_ptr;
|
||||||
|
int info_len;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
|
||||||
|
assert (this_p->magic1 == MAGIC);
|
||||||
|
assert (this_p->magic2 == MAGIC);
|
||||||
|
|
||||||
|
info_len = ax25_get_info (this_p, &info_ptr);
|
||||||
|
|
||||||
|
// Can't use strchr because there is potential of nul character.
|
||||||
|
|
||||||
|
for (j = 0; j < info_len; j++) {
|
||||||
|
|
||||||
|
if (info_ptr[j] == '\r' || info_ptr[j] == '\n') {
|
||||||
|
|
||||||
|
int chop = info_len - j;
|
||||||
|
|
||||||
|
this_p->frame_len -= chop;
|
||||||
|
return (chop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,7 @@ extern int ax25_get_first_not_repeated(packet_t pp);
|
||||||
extern int ax25_get_rr (packet_t this_p, int n);
|
extern int ax25_get_rr (packet_t this_p, int n);
|
||||||
|
|
||||||
extern int ax25_get_info (packet_t pp, unsigned char **paddr);
|
extern int ax25_get_info (packet_t pp, unsigned char **paddr);
|
||||||
|
extern int ax25_cut_at_crlf (packet_t this_p);
|
||||||
|
|
||||||
extern void ax25_set_nextp (packet_t this_p, packet_t next_p);
|
extern void ax25_set_nextp (packet_t this_p, packet_t next_p);
|
||||||
|
|
||||||
|
|
19
igate.c
19
igate.c
|
@ -870,7 +870,6 @@ void igate_send_rec_packet (int chan, packet_t recv_pp)
|
||||||
packet_t pp;
|
packet_t pp;
|
||||||
int n;
|
int n;
|
||||||
unsigned char *pinfo;
|
unsigned char *pinfo;
|
||||||
char *p;
|
|
||||||
int info_len;
|
int info_len;
|
||||||
|
|
||||||
|
|
||||||
|
@ -995,33 +994,25 @@ void igate_send_rec_packet (int chan, packet_t recv_pp)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cut the information part at the first CR or LF.
|
* Cut the information part at the first CR or LF.
|
||||||
|
* This is required because CR/LF is used as record separator when sending to server.
|
||||||
* Do NOT trim trailing spaces.
|
* Do NOT trim trailing spaces.
|
||||||
|
* Starting in 1.4 we preserve any nul characters in the information part.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
info_len = ax25_get_info (pp, &pinfo);
|
if (ax25_cut_at_crlf (pp) > 0) {
|
||||||
(void)(info_len);
|
|
||||||
|
|
||||||
if ((p = strchr ((char*)pinfo, '\r')) != NULL) {
|
|
||||||
if (s_debug >= 1) {
|
if (s_debug >= 1) {
|
||||||
text_color_set(DW_COLOR_DEBUG);
|
text_color_set(DW_COLOR_DEBUG);
|
||||||
dw_printf ("Rx IGate: Truncated information part at CR.\n");
|
dw_printf ("Rx IGate: Truncated information part at CR.\n");
|
||||||
}
|
}
|
||||||
*p = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p = strchr ((char*)pinfo, '\n')) != NULL) {
|
info_len = ax25_get_info (pp, &pinfo);
|
||||||
if (s_debug >= 1) {
|
|
||||||
text_color_set(DW_COLOR_DEBUG);
|
|
||||||
dw_printf ("Rx IGate: Truncated information part at LF.\n");
|
|
||||||
}
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Someone around here occasionally sends a packet with no information part.
|
* Someone around here occasionally sends a packet with no information part.
|
||||||
*/
|
*/
|
||||||
if (strlen((char*)pinfo) == 0) {
|
if (info_len == 0) {
|
||||||
|
|
||||||
if (s_debug >= 1) {
|
if (s_debug >= 1) {
|
||||||
text_color_set(DW_COLOR_DEBUG);
|
text_color_set(DW_COLOR_DEBUG);
|
||||||
|
|
Loading…
Reference in New Issue