packet
This commit is contained in:
parent
68915b1292
commit
4cec8d361c
|
@ -52,6 +52,27 @@ enum dect_slot_flags {
|
|||
DECT_SLOT_CIPHER = 0x2,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum dect_packet_types - DECT Physical Packet Types
|
||||
*
|
||||
* @DECT_PACKET_P00: short physical packet P00, 96 bits, A-field only
|
||||
* @DECT_PACKET_P08: low capacity physical packet P08j, 180 bits
|
||||
* @DECT_PACKET_P32: basic physical packet P32, 420 bits
|
||||
* @DECT_PACKET_P80: high capacity physical packet P80, 900 bits
|
||||
* @DECT_PACKET_P640j: variable capacity packet P640j, 712 bits
|
||||
* @DECT_PACKET_P672j: variable capacity packet P640j, 744 bits
|
||||
*/
|
||||
enum dect_packet_types {
|
||||
DECT_PACKET_P00,
|
||||
DECT_PACKET_P08,
|
||||
DECT_PACKET_P32,
|
||||
DECT_PACKET_P80,
|
||||
DECT_PACKET_P640j,
|
||||
DECT_PACKET_P672j,
|
||||
__DECT_PACKET_MAX
|
||||
};
|
||||
#define DECT_PACKET_MAX (__DECT_PACKET_MAX - 1)
|
||||
|
||||
#define DECT_PHASE_OFFSET_SCALE 1024
|
||||
|
||||
enum dect_slot_attrs {
|
||||
|
@ -59,6 +80,7 @@ enum dect_slot_attrs {
|
|||
DECTA_SLOT_NUM,
|
||||
DECTA_SLOT_STATE,
|
||||
DECTA_SLOT_FLAGS,
|
||||
DECTA_SLOT_PACKET,
|
||||
DECTA_SLOT_CARRIER,
|
||||
DECTA_SLOT_FREQUENCY,
|
||||
DECTA_SLOT_PHASEOFF,
|
||||
|
|
|
@ -838,6 +838,7 @@ struct nl_dect_transceiver_slot {
|
|||
uint8_t dts_valid;
|
||||
uint8_t dts_state;
|
||||
uint32_t dts_flags;
|
||||
uint8_t dts_packet;
|
||||
uint8_t dts_carrier;
|
||||
uint8_t dts_rssi;
|
||||
uint32_t dts_frequency;
|
||||
|
|
|
@ -48,6 +48,9 @@ extern uint8_t nl_dect_slot_str2state(const char *);
|
|||
extern const char * nl_dect_slot_flags2str(uint32_t, char *, size_t);
|
||||
extern uint32_t nl_dect_slot_str2flags(const char *);
|
||||
|
||||
extern const char * nl_dect_slot_packet2str(uint8_t, char *, size_t);
|
||||
extern uint8_t nl_dect_slot_str2packet(const char *);
|
||||
|
||||
extern int nl_dect_transceiver_alloc_cache(struct nl_sock *,
|
||||
struct nl_cache **);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ static struct nla_policy slot_policy[DECTA_SLOT_MAX + 1] = {
|
|||
[DECTA_SLOT_NUM] = { .type = NLA_U8 },
|
||||
[DECTA_SLOT_STATE] = { .type = NLA_U8 },
|
||||
[DECTA_SLOT_FLAGS] = { .type = NLA_U32 },
|
||||
[DECTA_SLOT_PACKET] = { .type = NLA_U8 },
|
||||
[DECTA_SLOT_CARRIER] = { .type = NLA_U8 },
|
||||
[DECTA_SLOT_FREQUENCY] = { .type = NLA_U32 },
|
||||
[DECTA_SLOT_PHASEOFF] = { .type = NLA_U32 },
|
||||
|
@ -80,6 +81,8 @@ static int slot_parser(struct nl_dect_transceiver *trx, struct nlattr *nla)
|
|||
dts->dts_state = nla_get_u8(tb[DECTA_SLOT_STATE]);
|
||||
if (tb[DECTA_SLOT_FLAGS] != NULL)
|
||||
dts->dts_flags = nla_get_u32(tb[DECTA_SLOT_FLAGS]);
|
||||
if (tb[DECTA_SLOT_PACKET] != NULL)
|
||||
dts->dts_packet = nla_get_u8(tb[DECTA_SLOT_PACKET]);
|
||||
if (tb[DECTA_SLOT_CARRIER] != NULL)
|
||||
dts->dts_carrier = nla_get_u8(tb[DECTA_SLOT_CARRIER]);
|
||||
if (tb[DECTA_SLOT_FREQUENCY] != NULL)
|
||||
|
|
|
@ -50,16 +50,25 @@ static void slot_dump(struct nl_dect_transceiver_slot *dts, unsigned int n,
|
|||
nl_dump(p, ",%s", buf);
|
||||
}
|
||||
nl_dump(p, "> ");
|
||||
nl_dump(p, "carrier: %u (%u.%03u MHz", dts->dts_carrier,
|
||||
dts->dts_frequency / 1000, dts->dts_frequency % 1000);
|
||||
|
||||
if (dts->dts_state == DECT_SLOT_RX) {
|
||||
offset = (int64_t)dts->dts_frequency * dts->dts_phaseoff /
|
||||
DECT_PHASE_OFFSET_SCALE;
|
||||
nl_dump(p, " %+" PRId64 ".%03" PRIu64 " kHz",
|
||||
offset / 1000000, llabs(offset) % 1000000 / 1000);
|
||||
if (dts->dts_state != DECT_SLOT_IDLE) {
|
||||
nl_dump(p, "packet: %s ",
|
||||
nl_dect_slot_packet2str(dts->dts_packet, buf,
|
||||
sizeof(buf)));
|
||||
|
||||
nl_dump(p, "carrier: %u (%u.%03u MHz", dts->dts_carrier,
|
||||
dts->dts_frequency / 1000, dts->dts_frequency % 1000);
|
||||
|
||||
if (dts->dts_state == DECT_SLOT_RX) {
|
||||
offset = (int64_t)dts->dts_frequency *
|
||||
dts->dts_phaseoff /
|
||||
DECT_PHASE_OFFSET_SCALE;
|
||||
nl_dump(p, " %+" PRId64 ".%03" PRIu64 " kHz",
|
||||
offset / 1000000,
|
||||
llabs(offset) % 1000000 / 1000);
|
||||
}
|
||||
nl_dump(p, ")");
|
||||
}
|
||||
nl_dump(p, ")");
|
||||
|
||||
if (dts->dts_state == DECT_SLOT_RX)
|
||||
nl_dump(p, " signal level: %.2fdBm",
|
||||
|
@ -271,6 +280,25 @@ uint32_t nl_dect_slot_str2flags(const char *str)
|
|||
return __str2flags(str, slot_flags, ARRAY_SIZE(slot_flags));
|
||||
}
|
||||
|
||||
static struct trans_tbl packet_types[] = {
|
||||
__ADD(DECT_PACKET_P00, P00)
|
||||
__ADD(DECT_PACKET_P08, P08)
|
||||
__ADD(DECT_PACKET_P32, P32)
|
||||
__ADD(DECT_PACKET_P80, P80)
|
||||
__ADD(DECT_PACKET_P640j, P640j)
|
||||
__ADD(DECT_PACKET_P640j, P672j)
|
||||
};
|
||||
|
||||
const char *nl_dect_slot_packet2str(uint8_t pkt, char *buf, size_t len)
|
||||
{
|
||||
return __type2str(pkt, buf, len, packet_types, ARRAY_SIZE(packet_types));
|
||||
}
|
||||
|
||||
uint8_t nl_dect_slot_str2packet(const char *str)
|
||||
{
|
||||
return __str2type(str, packet_types, ARRAY_SIZE(packet_types));
|
||||
}
|
||||
|
||||
int nl_dect_transceiver_build_msg(struct nl_msg *msg, struct nl_dect_transceiver *trx)
|
||||
{
|
||||
struct dectmsg dm = {
|
||||
|
|
Reference in New Issue