2014-05-24 22:04:42 +00:00
|
|
|
/*
|
2020-02-27 23:26:58 +00:00
|
|
|
Copyright (c) 2014-2020 Roger Light <roger@atchoo.org>
|
2014-05-24 22:04:42 +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
|
2014-05-24 22:04:42 +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/
|
2014-05-24 22:04:42 +00:00
|
|
|
and the Eclipse Distribution License is available at
|
|
|
|
http://www.eclipse.org/org/documents/edl-v10.php.
|
|
|
|
|
|
|
|
Contributors:
|
|
|
|
Roger Light - initial implementation and documentation.
|
|
|
|
*/
|
|
|
|
|
2016-03-13 18:43:13 +00:00
|
|
|
#ifndef CLIENT_CONFIG_H
|
|
|
|
#define CLIENT_CONFIG_H
|
2014-05-24 22:04:42 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2019-04-25 20:22:51 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
# include <winsock2.h>
|
|
|
|
#else
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-24 22:04:42 +00:00
|
|
|
/* pub_client.c modes */
|
|
|
|
#define MSGMODE_NONE 0
|
|
|
|
#define MSGMODE_CMD 1
|
|
|
|
#define MSGMODE_STDIN_LINE 2
|
|
|
|
#define MSGMODE_STDIN_FILE 3
|
|
|
|
#define MSGMODE_FILE 4
|
|
|
|
#define MSGMODE_NULL 5
|
|
|
|
|
|
|
|
#define CLIENT_PUB 1
|
|
|
|
#define CLIENT_SUB 2
|
2019-03-30 21:19:51 +00:00
|
|
|
#define CLIENT_RR 3
|
|
|
|
#define CLIENT_RESPONSE_TOPIC 4
|
2014-05-24 22:04:42 +00:00
|
|
|
|
2019-10-08 19:49:34 +00:00
|
|
|
#define PORT_UNDEFINED -1
|
|
|
|
#define PORT_UNIX 0
|
|
|
|
|
2014-05-24 22:04:42 +00:00
|
|
|
struct mosq_config {
|
|
|
|
char *id;
|
|
|
|
char *id_prefix;
|
2015-01-27 00:32:20 +00:00
|
|
|
int protocol_version;
|
2014-05-24 22:04:42 +00:00
|
|
|
int keepalive;
|
|
|
|
char *host;
|
|
|
|
int port;
|
|
|
|
int qos;
|
|
|
|
bool retain;
|
2019-03-30 21:19:51 +00:00
|
|
|
int pub_mode; /* pub, rr */
|
|
|
|
char *file_input; /* pub, rr */
|
|
|
|
char *message; /* pub, rr */
|
2020-04-16 22:26:14 +00:00
|
|
|
int msglen; /* pub, rr */
|
2019-03-30 21:19:51 +00:00
|
|
|
char *topic; /* pub, rr */
|
2014-05-24 22:04:42 +00:00
|
|
|
char *bind_address;
|
2019-04-11 18:13:59 +00:00
|
|
|
int repeat_count; /* pub */
|
|
|
|
struct timeval repeat_delay; /* pub */
|
2014-11-12 20:47:16 +00:00
|
|
|
#ifdef WITH_SRV
|
2014-05-24 22:04:42 +00:00
|
|
|
bool use_srv;
|
2014-11-12 20:47:16 +00:00
|
|
|
#endif
|
2014-05-24 22:04:42 +00:00
|
|
|
bool debug;
|
|
|
|
bool quiet;
|
|
|
|
unsigned int max_inflight;
|
|
|
|
char *username;
|
|
|
|
char *password;
|
|
|
|
char *will_topic;
|
|
|
|
char *will_payload;
|
2020-04-16 22:26:14 +00:00
|
|
|
int will_payloadlen;
|
2014-05-24 22:04:42 +00:00
|
|
|
int will_qos;
|
|
|
|
bool will_retain;
|
|
|
|
#ifdef WITH_TLS
|
|
|
|
char *cafile;
|
|
|
|
char *capath;
|
|
|
|
char *certfile;
|
|
|
|
char *keyfile;
|
|
|
|
char *ciphers;
|
|
|
|
bool insecure;
|
2019-04-11 10:52:34 +00:00
|
|
|
char *tls_alpn;
|
2014-05-24 22:04:42 +00:00
|
|
|
char *tls_version;
|
2018-08-09 19:37:33 +00:00
|
|
|
char *tls_engine;
|
2019-02-26 17:11:29 +00:00
|
|
|
char *tls_engine_kpass_sha1;
|
2018-08-09 19:37:33 +00:00
|
|
|
char *keyform;
|
2020-12-01 11:51:13 +00:00
|
|
|
bool tls_use_os_certs;
|
2018-12-09 13:40:38 +00:00
|
|
|
# ifdef FINAL_WITH_TLS_PSK
|
2014-05-24 22:04:42 +00:00
|
|
|
char *psk;
|
|
|
|
char *psk_identity;
|
|
|
|
# endif
|
2014-05-25 22:41:17 +00:00
|
|
|
#endif
|
2017-07-17 19:43:06 +00:00
|
|
|
bool clean_session;
|
2019-10-15 13:44:25 +00:00
|
|
|
char **topics; /* sub, rr */
|
|
|
|
int topic_count; /* sub, rr */
|
2018-09-27 21:16:38 +00:00
|
|
|
bool exit_after_sub; /* sub */
|
2014-05-24 22:04:42 +00:00
|
|
|
bool no_retain; /* sub */
|
2016-02-02 20:57:37 +00:00
|
|
|
bool retained_only; /* sub */
|
2019-03-02 22:14:54 +00:00
|
|
|
bool remove_retained; /* sub */
|
2014-05-24 22:04:42 +00:00
|
|
|
char **filter_outs; /* sub */
|
|
|
|
int filter_out_count; /* sub */
|
2015-12-29 20:15:00 +00:00
|
|
|
char **unsub_topics; /* sub */
|
|
|
|
int unsub_topic_count; /* sub */
|
2014-05-24 22:04:42 +00:00
|
|
|
bool verbose; /* sub */
|
|
|
|
bool eol; /* sub */
|
2015-01-30 22:23:51 +00:00
|
|
|
int msg_count; /* sub */
|
2019-10-15 13:44:25 +00:00
|
|
|
char *format; /* sub, rr */
|
|
|
|
bool pretty; /* sub, rr */
|
2020-04-16 22:26:14 +00:00
|
|
|
unsigned int timeout; /* sub */
|
2018-12-14 13:21:53 +00:00
|
|
|
int sub_opts; /* sub */
|
2020-01-30 11:19:09 +00:00
|
|
|
long session_expiry_interval;
|
2020-03-03 14:12:30 +00:00
|
|
|
int random_filter; /* sub */
|
2014-09-29 23:56:57 +00:00
|
|
|
#ifdef WITH_SOCKS
|
|
|
|
char *socks5_host;
|
|
|
|
int socks5_port;
|
|
|
|
char *socks5_username;
|
|
|
|
char *socks5_password;
|
|
|
|
#endif
|
2018-10-31 12:38:39 +00:00
|
|
|
mosquitto_property *connect_props;
|
|
|
|
mosquitto_property *publish_props;
|
|
|
|
mosquitto_property *subscribe_props;
|
|
|
|
mosquitto_property *unsubscribe_props;
|
|
|
|
mosquitto_property *disconnect_props;
|
|
|
|
mosquitto_property *will_props;
|
2018-11-01 15:47:21 +00:00
|
|
|
bool have_topic_alias; /* pub */
|
2019-03-30 21:19:51 +00:00
|
|
|
char *response_topic; /* rr */
|
2019-12-18 13:47:34 +00:00
|
|
|
bool tcp_nodelay;
|
2014-05-24 22:04:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int client_config_load(struct mosq_config *config, int pub_or_sub, int argc, char *argv[]);
|
2014-11-16 23:41:06 +00:00
|
|
|
void client_config_cleanup(struct mosq_config *cfg);
|
2014-05-24 22:04:42 +00:00
|
|
|
int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg);
|
2019-03-13 14:11:50 +00:00
|
|
|
int client_id_generate(struct mosq_config *cfg);
|
2014-05-24 22:04:42 +00:00
|
|
|
int client_connect(struct mosquitto *mosq, struct mosq_config *cfg);
|
|
|
|
|
2018-10-31 12:38:39 +00:00
|
|
|
int cfg_parse_property(struct mosq_config *cfg, int argc, char *argv[], int *idx);
|
|
|
|
|
2019-05-21 10:23:00 +00:00
|
|
|
void err_printf(const struct mosq_config *cfg, const char *fmt, ...);
|
|
|
|
|
2014-05-24 22:04:42 +00:00
|
|
|
#endif
|