Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gec_dl.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Michal Podhradsky <michal.podhradsky@aggiemail.usu.edu>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
26#ifndef GEC_DL_H
27#define GEC_DL_H
28
29#include "pprzlink/pprzlink_transport.h"
30#include "pprzlink/pprz_transport.h"
32#include "pprz_mutex.h"
33
34#include "mcu_periph/uart.h"
35#if USE_USB_SERIAL || USE_USB_SERIAL_DEBUG
37#endif
38#if USE_UDP
39#include "mcu_periph/udp.h"
40#endif
41
42// MSG_ID for key exchange messages.
43// Update if IDs change in messages.xml
44#define KEY_EXCHANGE_MSG_ID_UAV 239
45#define KEY_EXCHANGE_MSG_ID_GCS 159
46#define WHITELIST_LEN 20
47
58
68
70 // pprz encapsulation layer
72
73 // generic reception interface
75
76 // generic transmission interface
78 // buffered tx message
81
82 // ecnryption primitives
85
86 // optional mutex
88};
89
91extern struct gec_transport gec_tp;
92
94extern void gec_dl_init(void);
95
97extern void gec_dl_event(void);
98
100
103 uint8_t *buf, bool *msg_available);
104
105void gec_process_sts_msg(struct link_device *dev, struct gec_transport *trans, uint8_t *buf);
106
107void respond_sts(struct link_device *dev, struct gec_transport *trans, uint8_t *buf);
108void finish_sts(struct link_device *dev, struct gec_transport *trans,
109 uint8_t *buf);
110
113bool gec_decrypt_message(uint8_t *buf, volatile uint8_t *payload_len);
114bool gec_encrypt_message(uint8_t *buf, uint8_t *payload_len);
115
116void gec_process_msg1(uint8_t *buf);
117bool gec_process_msg3(uint8_t *buf);
118
119#endif /* GEC_DL_H */
120
Galois embedded crypto implementation.
bool message_ready
Definition gec_dl.h:66
void gec_dl_init(void)
Init function.
Definition gec_dl.c:345
void gec_check_and_parse(struct link_device *dev, struct gec_transport *trans, uint8_t *buf, bool *msg_available)
Parsing a frame data and copy the payload to the datalink buffer.
uint8_t whitelist[WHITELIST_LEN]
Definition gec_dl.h:54
bool gec_process_msg3(uint8_t *buf)
Process incoming message (expected MSG3) if the right (KEY_EXCHANGE) message received with the right ...
Definition gec_dl.c:744
void respond_sts(struct link_device *dev, struct gec_transport *trans, uint8_t *buf)
void gec_add_to_whitelist(struct gec_whitelist *whitelist, uint8_t id)
Definition gec_dl.c:800
uint8_t msg[TRANSPORT_PAYLOAD_LEN]
Definition gec_dl.h:64
void gec_dl_event(void)
Datalink Event.
Definition gec_dl.c:533
bool gec_encrypt_message(uint8_t *buf, uint8_t *payload_len)
Attempts message encryption Adds crypto_byte, counter and tag Returns encrypted pprzlink message (cry...
Definition gec_dl.c:371
struct gec_transport gec_tp
PPRZ transport structure.
Definition gec_dl.c:70
void gec_process_sts_msg(struct link_device *dev, struct gec_transport *trans, uint8_t *buf)
void finish_sts(struct link_device *dev, struct gec_transport *trans, uint8_t *buf)
uint8_t idx
Definition gec_dl.h:55
bool init
Definition gec_dl.h:56
bool gec_is_in_the_whitelist(struct gec_whitelist *whitelist, uint8_t id)
Definition gec_dl.c:814
bool gec_decrypt_message(uint8_t *buf, volatile uint8_t *payload_len)
Attemp message decryption If a message is unencrypted, pass it through only if the MSG_ID is in the w...
Definition gec_dl.c:430
void gec_process_msg1(uint8_t *buf)
NOTE: for RESPONDER party only Process incoming message (expected MSG1) if the right (KEY_EXCHANGE) m...
Definition gec_dl.c:597
uint8_t len
Definition gec_dl.h:65
#define WHITELIST_LEN
Definition gec_dl.h:46
void gec_transport_init(struct gec_transport *t)
Definition gec_dl.c:325
Whitelist for sending and receiving unencrypted messages (mostly for KEY_EXCHANGE messages)
Definition gec_dl.h:53
Auxilliary message buffer for storing precomputed key exchange messages.
Definition gec_dl.h:63
uint16_t foo
Definition main_demo5.c:58
Utility functions and macros to abstract some RTOS functionalities such as mutexes.
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
uint8_t tx_msg_idx
Definition gec_dl.h:80
struct gec_sts_ctx sts
Definition gec_dl.h:83
uint8_t tx_msg[TRANSPORT_PAYLOAD_LEN]
Definition gec_dl.h:79
struct transport_tx trans_tx
Definition gec_dl.h:77
PPRZ_MUTEX(mtx_tx)
struct transport_rx trans_rx
Definition gec_dl.h:74
struct pprz_transport pprz_tp
Definition gec_dl.h:71
struct gec_whitelist whitelist
Definition gec_dl.h:84
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
arch independent UDP API
arch independent USB API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.