2015-04-29 20:23:59 +00:00
|
|
|
/*
|
2020-02-27 23:26:58 +00:00
|
|
|
Copyright (c) 2010-2020 Roger Light <roger@atchoo.org>
|
2015-04-29 20:23:59 +00:00
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials
|
2020-11-25 17:34:21 +00:00
|
|
|
are made available under the terms of the Eclipse Public License 2.0
|
2015-04-29 20:23:59 +00:00
|
|
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
|
|
|
|
|
|
|
The Eclipse Public License is available at
|
2020-11-25 17:34:21 +00:00
|
|
|
https://www.eclipse.org/legal/epl-2.0/
|
2015-04-29 20:23:59 +00:00
|
|
|
and the Eclipse Distribution License is available at
|
|
|
|
http://www.eclipse.org/org/documents/edl-v10.php.
|
|
|
|
|
2020-12-01 18:21:59 +00:00
|
|
|
SPDX-License-Identifier: EPL-2.0 OR EDL-1.0
|
|
|
|
|
2015-04-29 20:23:59 +00:00
|
|
|
Contributors:
|
|
|
|
Roger Light - initial implementation and documentation.
|
|
|
|
*/
|
2016-03-13 18:43:13 +00:00
|
|
|
#ifndef PACKET_MOSQ_H
|
|
|
|
#define PACKET_MOSQ_H
|
2015-04-29 20:23:59 +00:00
|
|
|
|
2015-04-29 20:37:47 +00:00
|
|
|
#include "mosquitto_internal.h"
|
|
|
|
#include "mosquitto.h"
|
2015-04-29 20:23:59 +00:00
|
|
|
|
2015-05-16 13:16:40 +00:00
|
|
|
int packet__alloc(struct mosquitto__packet *packet);
|
|
|
|
void packet__cleanup(struct mosquitto__packet *packet);
|
2019-07-30 17:42:31 +00:00
|
|
|
void packet__cleanup_all(struct mosquitto *mosq);
|
2020-11-27 15:30:11 +00:00
|
|
|
void packet__cleanup_all_no_locks(struct mosquitto *mosq);
|
2015-05-16 13:16:40 +00:00
|
|
|
int packet__queue(struct mosquitto *mosq, struct mosquitto__packet *packet);
|
2015-04-29 20:23:59 +00:00
|
|
|
|
2019-02-18 19:46:39 +00:00
|
|
|
int packet__check_oversize(struct mosquitto *mosq, uint32_t remaining_length);
|
|
|
|
|
2015-05-16 13:16:40 +00:00
|
|
|
int packet__read_byte(struct mosquitto__packet *packet, uint8_t *byte);
|
|
|
|
int packet__read_bytes(struct mosquitto__packet *packet, void *bytes, uint32_t count);
|
2020-10-17 00:23:08 +00:00
|
|
|
int packet__read_binary(struct mosquitto__packet *packet, uint8_t **data, uint16_t *length);
|
|
|
|
int packet__read_string(struct mosquitto__packet *packet, char **str, uint16_t *length);
|
2015-05-16 13:16:40 +00:00
|
|
|
int packet__read_uint16(struct mosquitto__packet *packet, uint16_t *word);
|
2018-08-29 21:13:41 +00:00
|
|
|
int packet__read_uint32(struct mosquitto__packet *packet, uint32_t *word);
|
2020-10-17 00:23:08 +00:00
|
|
|
int packet__read_varint(struct mosquitto__packet *packet, uint32_t *word, uint8_t *bytes);
|
2015-04-29 20:23:59 +00:00
|
|
|
|
2015-05-16 13:16:40 +00:00
|
|
|
void packet__write_byte(struct mosquitto__packet *packet, uint8_t byte);
|
|
|
|
void packet__write_bytes(struct mosquitto__packet *packet, const void *bytes, uint32_t count);
|
|
|
|
void packet__write_string(struct mosquitto__packet *packet, const char *str, uint16_t length);
|
|
|
|
void packet__write_uint16(struct mosquitto__packet *packet, uint16_t word);
|
2018-08-29 21:13:41 +00:00
|
|
|
void packet__write_uint32(struct mosquitto__packet *packet, uint32_t word);
|
2020-10-17 00:23:08 +00:00
|
|
|
int packet__write_varint(struct mosquitto__packet *packet, uint32_t word);
|
2015-04-29 20:23:59 +00:00
|
|
|
|
2020-10-17 00:23:08 +00:00
|
|
|
unsigned int packet__varint_bytes(uint32_t word);
|
2018-10-25 09:24:19 +00:00
|
|
|
|
2015-05-16 13:16:40 +00:00
|
|
|
int packet__write(struct mosquitto *mosq);
|
|
|
|
int packet__read(struct mosquitto *mosq);
|
2015-04-29 20:23:59 +00:00
|
|
|
|
|
|
|
#endif
|