First successful run of src/decode.c
This commit is contained in:
parent
a8db220bbd
commit
3759469611
3 changed files with 11 additions and 6 deletions
|
@ -12,7 +12,7 @@
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
typedef struct _patty_ax25_addr {
|
typedef struct _patty_ax25_addr {
|
||||||
uint8_t callsign[6];
|
char callsign[6];
|
||||||
uint8_t ssid;
|
uint8_t ssid;
|
||||||
} patty_ax25_addr;
|
} patty_ax25_addr;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -252,13 +251,13 @@ int patty_ax25_ntop(const patty_ax25_addr *addr,
|
||||||
goto error_invalid_args;
|
goto error_invalid_args;
|
||||||
} else if (c == ' ' && !space) {
|
} else if (c == ' ' && !space) {
|
||||||
space = 1;
|
space = 1;
|
||||||
} else if (space) {
|
} else if (c != ' ' && space) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
||||||
goto error_invalid_args;
|
goto error_invalid_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest[o++] = c;
|
dest[o++] = space? '\0': c;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest[o] = '\0';
|
dest[o] = '\0';
|
||||||
|
|
10
src/frame.c
10
src/frame.c
|
@ -19,7 +19,7 @@ static ssize_t validate_station(void *data,
|
||||||
|
|
||||||
if (c == ' ' && !space) {
|
if (c == ' ' && !space) {
|
||||||
space = 1;
|
space = 1;
|
||||||
} else if (space) {
|
} else if (c != ' ' && space) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -52,6 +52,8 @@ static ssize_t decode_hops(patty_ax25_frame *frame,
|
||||||
if ((decoded = validate_station(data, offset)) < 0) {
|
if ((decoded = validate_station(data, offset)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
|
memcpy(&frame->repeaters[i], addr, sizeof(*addr));
|
||||||
|
|
||||||
offset += decoded;
|
offset += decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ static ssize_t decode_hops(patty_ax25_frame *frame,
|
||||||
* If the last hop does not have the address extension bit set, then
|
* If the last hop does not have the address extension bit set, then
|
||||||
* that's a big problem.
|
* that's a big problem.
|
||||||
*/
|
*/
|
||||||
if (addr && PATTY_AX25_ADDRESS_OCTET_LAST(addr->ssid)) {
|
if (addr && !PATTY_AX25_ADDRESS_OCTET_LAST(addr->ssid)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -87,12 +89,16 @@ static ssize_t decode_address(patty_ax25_frame *frame,
|
||||||
if ((decoded = validate_station(data, offset)) < 0) {
|
if ((decoded = validate_station(data, offset)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
|
memcpy(&frame->dest, ((uint8_t *)data) + offset, sizeof(frame->dest));
|
||||||
|
|
||||||
offset += decoded;
|
offset += decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((decoded = validate_station(data, offset)) < 0) {
|
if ((decoded = validate_station(data, offset)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
|
memcpy(&frame->src, ((uint8_t *)data) + offset, sizeof(frame->src));
|
||||||
|
|
||||||
offset += decoded;
|
offset += decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue