fix mptp packet graphic, fix formatting
This commit is contained in:
parent
82cbd147b2
commit
e773ff7f09
@ -1,18 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
0 1 2 3 4 5 6 7
|
||||||
#####################################
|
###############
|
||||||
# FLAGS #
|
# FLAGS #
|
||||||
#####################################
|
###############
|
||||||
# SIZE #
|
# SIZE #
|
||||||
# #
|
# #
|
||||||
#####################################
|
###############
|
||||||
# DATA #
|
# DATA #
|
||||||
#...................................#
|
#.............#
|
||||||
|
|
||||||
[8 bits] FLAGS
|
[8 bits] FLAGS
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -57,18 +59,20 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MPTP_VERSION_SUPPORTED 0
|
// clang-format on
|
||||||
#define MPTP_VERSION_MAX 15 // 4 bits
|
|
||||||
#define MPTP_CODE_MAX 4 // 2 bits
|
|
||||||
|
|
||||||
typedef enum lm_mptp_request{
|
#define MPTP_VERSION_SUPPORTED 0
|
||||||
|
#define MPTP_VERSION_MAX 15 // 4 bits
|
||||||
|
#define MPTP_CODE_MAX 4 // 2 bits
|
||||||
|
|
||||||
|
typedef enum lm_mptp_request {
|
||||||
MPTP_C2S_PING = 0,
|
MPTP_C2S_PING = 0,
|
||||||
MPTP_C2S_INFO = 1,
|
MPTP_C2S_INFO = 1,
|
||||||
MPTP_C2S_LIST = 2,
|
MPTP_C2S_LIST = 2,
|
||||||
MPTP_C2S_PULL = 3,
|
MPTP_C2S_PULL = 3,
|
||||||
} lm_mptp_request_t;
|
} lm_mptp_request_t;
|
||||||
|
|
||||||
typedef enum lm_mptp_response{
|
typedef enum lm_mptp_response {
|
||||||
MPTP_S2C_PONG = 0,
|
MPTP_S2C_PONG = 0,
|
||||||
MPTP_S2C_COOL = 1,
|
MPTP_S2C_COOL = 1,
|
||||||
MPTP_S2C_BRUH = 2,
|
MPTP_S2C_BRUH = 2,
|
||||||
@ -76,18 +80,18 @@ typedef enum lm_mptp_response{
|
|||||||
} lm_mptp_response_t;
|
} lm_mptp_response_t;
|
||||||
|
|
||||||
typedef struct lm_mptp {
|
typedef struct lm_mptp {
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint16_t size;
|
uint16_t size;
|
||||||
char *data;
|
char *data;
|
||||||
} lm_mptp_t;
|
} lm_mptp_t;
|
||||||
|
|
||||||
void lm_mptp_flags_set(lm_mptp_t *packet, uint8_t version, bool is_request, uint8_t code, bool is_last);
|
void lm_mptp_flags_set(lm_mptp_t *packet, uint8_t version, bool is_request, uint8_t code, bool is_last);
|
||||||
#define MPTP_FLAGS_VERSION(m) (m->flags >> 4) & 15
|
#define MPTP_FLAGS_VERSION(m) (m->flags >> 4) & 15
|
||||||
#define MPTP_FLAGS_IS_REQUEST(m) ((m->flags >> 3) & 1) == 0
|
#define MPTP_FLAGS_IS_REQUEST(m) ((m->flags >> 3) & 1) == 0
|
||||||
#define MPTP_FLAGS_TYPE(m) (m->flags >> 1) & 3
|
#define MPTP_FLAGS_TYPE(m) (m->flags >> 1) & 3
|
||||||
#define MPTP_FLAGS_IS_LAST(m) (m->flags & 1) == 1
|
#define MPTP_FLAGS_IS_LAST(m) (m->flags & 1) == 1
|
||||||
|
|
||||||
int lm_mptp_connect(lm_url_t *url);
|
int lm_mptp_connect(lm_url_t *url);
|
||||||
bool lm_mptp_recv(int socket, lm_mptp_t *packet);
|
bool lm_mptp_recv(int socket, lm_mptp_t *packet);
|
||||||
bool lm_mptp_send(int socket, lm_mptp_t *packet);
|
bool lm_mptp_send(int socket, lm_mptp_t *packet);
|
||||||
void lm_mptp_disconnect(int socket);
|
void lm_mptp_disconnect(int socket);
|
||||||
|
Loading…
Reference in New Issue
Block a user