2014-05-24 22:04:42 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2014 Roger Light <roger@atchoo.org>
|
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
and Eclipse Distribution License v1.0 which accompany this distribution.
|
|
|
|
|
|
|
|
The Eclipse Public License is available at
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
and the Eclipse Distribution License is available at
|
|
|
|
http://www.eclipse.org/org/documents/edl-v10.php.
|
|
|
|
|
|
|
|
Contributors:
|
|
|
|
Roger Light - initial implementation and documentation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CLIENT_CONFIG_H
|
|
|
|
#define _CLIENT_CONFIG_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
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;
|
|
|
|
int pub_mode; /* pub */
|
|
|
|
char *file_input; /* pub */
|
|
|
|
char *message; /* pub */
|
|
|
|
long msglen; /* pub */
|
|
|
|
char *topic; /* pub */
|
|
|
|
char *bind_address;
|
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;
|
|
|
|
long will_payloadlen;
|
|
|
|
int will_qos;
|
|
|
|
bool will_retain;
|
|
|
|
#ifdef WITH_TLS
|
|
|
|
char *cafile;
|
|
|
|
char *capath;
|
|
|
|
char *certfile;
|
|
|
|
char *keyfile;
|
|
|
|
char *ciphers;
|
|
|
|
bool insecure;
|
|
|
|
char *tls_version;
|
|
|
|
# ifdef WITH_TLS_PSK
|
|
|
|
char *psk;
|
|
|
|
char *psk_identity;
|
|
|
|
# endif
|
2014-05-25 22:41:17 +00:00
|
|
|
#endif
|
2014-05-24 22:04:42 +00:00
|
|
|
bool clean_session; /* sub */
|
|
|
|
char **topics; /* sub */
|
|
|
|
int topic_count; /* sub */
|
|
|
|
bool no_retain; /* sub */
|
|
|
|
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-04-17 21:01:50 +00:00
|
|
|
bool hex_output; /* sub */
|
2015-01-30 22:23:51 +00:00
|
|
|
int msg_count; /* 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
|
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);
|
|
|
|
int client_id_generate(struct mosq_config *cfg, const char *id_base);
|
|
|
|
int client_connect(struct mosquitto *mosq, struct mosq_config *cfg);
|
|
|
|
|
|
|
|
#endif
|