A spoonful of unions make the weird specs go down
This commit is contained in:
parent
508a2f8146
commit
447a266432
4 changed files with 18 additions and 5 deletions
|
@ -8,6 +8,11 @@
|
|||
|
||||
#define PATTY_AX25_MAX_HOPS 8
|
||||
|
||||
enum patty_ax25_version {
|
||||
PATTY_AX25_OLD,
|
||||
PATTY_AX25_2_0
|
||||
};
|
||||
|
||||
enum patty_ax25_proto {
|
||||
PATTY_AX25_PROTO_UNKNOWN = 0x00,
|
||||
PATTY_AX25_PROTO_ISO_8208 = 0x01,
|
||||
|
@ -38,7 +43,11 @@ typedef struct _patty_ax25_address {
|
|||
|
||||
int ssid;
|
||||
int last;
|
||||
int repeated;
|
||||
|
||||
union {
|
||||
int c;
|
||||
int repeated;
|
||||
};
|
||||
} patty_ax25_address;
|
||||
|
||||
typedef struct _patty_ax25_frame {
|
||||
|
@ -49,6 +58,7 @@ typedef struct _patty_ax25_frame {
|
|||
int hops;
|
||||
int repeated;
|
||||
|
||||
enum patty_ax25_version version;
|
||||
enum patty_ax25_frame_type type;
|
||||
|
||||
uint8_t control;
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
#define PATTY_AX25_ADDRESS_SSID_NUMBER(c) \
|
||||
((c & 0x1e) >> 1)
|
||||
|
||||
#define PATTY_AX25_ADDRESS_SSID_C(c) \
|
||||
((c & 0x80) == 0x80)
|
||||
|
||||
#define PATTY_AX25_ADDRESS_SSID_REPEATED(c) \
|
||||
((c & 0x80) == 0x80)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ CC = $(CROSS)cc
|
|||
CFLAGS = $(CGFLAGS) -fPIC -Wall -O2 -I$(INCLUDE_PATH)
|
||||
LDFLAGS =
|
||||
|
||||
HEADERS = kiss.h ax25.h
|
||||
HEADERS = kiss.h ax25.h ax25/macros.h
|
||||
OBJS = kiss.o ax25.o test.o
|
||||
|
||||
PROGRAM = test
|
||||
|
|
|
@ -49,9 +49,9 @@ static ssize_t frame_decode_address(patty_ax25_address *address, void *data, off
|
|||
/*
|
||||
* Now, unpack the data from the SSID field.
|
||||
*/
|
||||
address->repeated = PATTY_AX25_ADDRESS_SSID_REPEATED(ssid);
|
||||
address->ssid = PATTY_AX25_ADDRESS_SSID_NUMBER(ssid);
|
||||
address->last = PATTY_AX25_ADDRESS_OCTET_LAST(ssid);
|
||||
address->c = PATTY_AX25_ADDRESS_SSID_C(ssid);
|
||||
address->ssid = PATTY_AX25_ADDRESS_SSID_NUMBER(ssid);
|
||||
address->last = PATTY_AX25_ADDRESS_OCTET_LAST(ssid);
|
||||
|
||||
return 7;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue