A spoonful of unions make the weird specs go down

This commit is contained in:
XANTRONIX Development 2015-07-18 02:17:35 -05:00
parent 508a2f8146
commit 447a266432
4 changed files with 18 additions and 5 deletions

View file

@ -8,6 +8,11 @@
#define PATTY_AX25_MAX_HOPS 8 #define PATTY_AX25_MAX_HOPS 8
enum patty_ax25_version {
PATTY_AX25_OLD,
PATTY_AX25_2_0
};
enum patty_ax25_proto { enum patty_ax25_proto {
PATTY_AX25_PROTO_UNKNOWN = 0x00, PATTY_AX25_PROTO_UNKNOWN = 0x00,
PATTY_AX25_PROTO_ISO_8208 = 0x01, PATTY_AX25_PROTO_ISO_8208 = 0x01,
@ -38,7 +43,11 @@ typedef struct _patty_ax25_address {
int ssid; int ssid;
int last; int last;
union {
int c;
int repeated; int repeated;
};
} patty_ax25_address; } patty_ax25_address;
typedef struct _patty_ax25_frame { typedef struct _patty_ax25_frame {
@ -49,6 +58,7 @@ typedef struct _patty_ax25_frame {
int hops; int hops;
int repeated; int repeated;
enum patty_ax25_version version;
enum patty_ax25_frame_type type; enum patty_ax25_frame_type type;
uint8_t control; uint8_t control;

View file

@ -10,6 +10,9 @@
#define PATTY_AX25_ADDRESS_SSID_NUMBER(c) \ #define PATTY_AX25_ADDRESS_SSID_NUMBER(c) \
((c & 0x1e) >> 1) ((c & 0x1e) >> 1)
#define PATTY_AX25_ADDRESS_SSID_C(c) \
((c & 0x80) == 0x80)
#define PATTY_AX25_ADDRESS_SSID_REPEATED(c) \ #define PATTY_AX25_ADDRESS_SSID_REPEATED(c) \
((c & 0x80) == 0x80) ((c & 0x80) == 0x80)

View file

@ -7,7 +7,7 @@ CC = $(CROSS)cc
CFLAGS = $(CGFLAGS) -fPIC -Wall -O2 -I$(INCLUDE_PATH) CFLAGS = $(CGFLAGS) -fPIC -Wall -O2 -I$(INCLUDE_PATH)
LDFLAGS = LDFLAGS =
HEADERS = kiss.h ax25.h HEADERS = kiss.h ax25.h ax25/macros.h
OBJS = kiss.o ax25.o test.o OBJS = kiss.o ax25.o test.o
PROGRAM = test PROGRAM = test

View file

@ -49,7 +49,7 @@ static ssize_t frame_decode_address(patty_ax25_address *address, void *data, off
/* /*
* Now, unpack the data from the SSID field. * Now, unpack the data from the SSID field.
*/ */
address->repeated = PATTY_AX25_ADDRESS_SSID_REPEATED(ssid); address->c = PATTY_AX25_ADDRESS_SSID_C(ssid);
address->ssid = PATTY_AX25_ADDRESS_SSID_NUMBER(ssid); address->ssid = PATTY_AX25_ADDRESS_SSID_NUMBER(ssid);
address->last = PATTY_AX25_ADDRESS_OCTET_LAST(ssid); address->last = PATTY_AX25_ADDRESS_OCTET_LAST(ssid);