Fix invalid return in patty_ax25_aprs_is_send()
Fix invalid return in patty_ax25_aprs_is_send() wherein the number of bytes written to APRS-IS was returned, rather than the number of AX.25 packet bytes; the number of bytes read is the more important value as it is used later for repeating the frame to promiscuous mode SOCK_RAW sockets
This commit is contained in:
parent
9f6f775ee4
commit
54d6324dea
1 changed files with 34 additions and 24 deletions
|
@ -320,24 +320,30 @@ ssize_t patty_ax25_aprs_is_send(patty_ax25_aprs_is *aprs,
|
|||
size_t len) {
|
||||
patty_ax25_frame frame;
|
||||
|
||||
size_t offset = 0;
|
||||
size_t i = 0,
|
||||
o = 0,
|
||||
hop;
|
||||
|
||||
ssize_t decoded;
|
||||
|
||||
int formatted,
|
||||
i;
|
||||
int formatted;
|
||||
|
||||
char call[PATTY_AX25_ADDRSTRLEN+1];
|
||||
|
||||
if ((decoded = patty_ax25_frame_decode_address(&frame, buf, len)) < 0) {
|
||||
goto error;
|
||||
} else {
|
||||
i += decoded;
|
||||
}
|
||||
|
||||
if (patty_ax25_frame_decode_control(&frame,
|
||||
if ((decoded = patty_ax25_frame_decode_control(&frame,
|
||||
PATTY_AX25_FRAME_NORMAL,
|
||||
buf,
|
||||
decoded,
|
||||
len) < 0) {
|
||||
i,
|
||||
len)) < 0) {
|
||||
goto error;
|
||||
} else {
|
||||
i += decoded;
|
||||
}
|
||||
|
||||
if (!PATTY_AX25_FRAME_CONTROL_UI(frame.control)) {
|
||||
|
@ -354,55 +360,59 @@ ssize_t patty_ax25_aprs_is_send(patty_ax25_aprs_is *aprs,
|
|||
call)) < 0) {
|
||||
goto error;
|
||||
} else {
|
||||
offset += formatted;
|
||||
o += formatted;
|
||||
}
|
||||
|
||||
if (patty_ax25_ntop(&frame.dest, call, sizeof(call)) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((formatted = snprintf(aprs->tx_buf + offset,
|
||||
aprs->tx_bufsz - offset,
|
||||
if ((formatted = snprintf(aprs->tx_buf + o,
|
||||
aprs->tx_bufsz - o,
|
||||
"%s",
|
||||
call)) < 0) {
|
||||
goto error;
|
||||
} else {
|
||||
offset += formatted;
|
||||
o += formatted;
|
||||
}
|
||||
|
||||
for (i=0; i<frame.hops; i++) {
|
||||
if (patty_ax25_ntop(&frame.repeaters[i],
|
||||
for (hop=0; hop<frame.hops; hop++) {
|
||||
if (patty_ax25_ntop(&frame.repeaters[hop],
|
||||
call,
|
||||
sizeof(call)) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((formatted = snprintf(aprs->tx_buf + offset,
|
||||
aprs->tx_bufsz - offset,
|
||||
if ((formatted = snprintf(aprs->tx_buf + o,
|
||||
aprs->tx_bufsz - o,
|
||||
",%s",
|
||||
call)) < 0) {
|
||||
goto error;
|
||||
} else {
|
||||
offset += formatted;
|
||||
o += formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if (aprs->tx_bufsz - offset < frame.infolen + 3) {
|
||||
if (aprs->tx_bufsz < o + frame.infolen + 3) {
|
||||
errno = EOVERFLOW;
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
aprs->tx_buf[offset++] = ':';
|
||||
aprs->tx_buf[o++] = ':';
|
||||
|
||||
memcpy(aprs->tx_buf + offset, frame.info, frame.infolen);
|
||||
memcpy(aprs->tx_buf + o, frame.info, frame.infolen);
|
||||
|
||||
offset += frame.infolen;
|
||||
o += frame.infolen;
|
||||
|
||||
aprs->tx_buf[offset++] = '\r';
|
||||
aprs->tx_buf[offset++] = '\n';
|
||||
aprs->tx_buf[o++] = '\r';
|
||||
aprs->tx_buf[o++] = '\n';
|
||||
|
||||
return write(aprs->fd, aprs->tx_buf, offset);
|
||||
if (write(aprs->fd, aprs->tx_buf, o) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue