-
Notifications
You must be signed in to change notification settings - Fork 2
/
nnb_opt.h
125 lines (110 loc) · 2.74 KB
/
nnb_opt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef NNB_OPT_H
#define NNB_OPT_H
#include <assert.h>
#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <nng/mqtt/mqtt_client.h>
#include <nng/nng.h>
#include <nng/supplemental/util/platform.h>
typedef struct {
bool enable;
char *cacert;
char *cert;
char *key;
char *keypass;
} tls_opt;
typedef struct {
char * host;
char * username;
char * password;
int port;
int version;
int count;
int startnumber;
int interval;
int keepalive;
bool clean;
tls_opt tls;
// TODO future
// char ifaddr[64];
// char prefix[64];
} nnb_conn_opt;
typedef struct {
char * host;
char * username;
char * password;
char * topic;
int port;
int version;
int count;
int startnumber;
int interval;
int keepalive;
int qos;
bool clean;
tls_opt tls;
// TODO future
// bool ws;
// char ifaddr[64];
// char prefix[64];
} nnb_sub_opt;
typedef struct {
char * host;
char * username;
char * password;
char * topic;
int port;
int version;
int count;
int startnumber;
int interval;
int interval_of_msg;
int size;
int limit;
int keepalive;
int qos;
bool retain;
bool clean;
tls_opt tls;
// TODO future
// bool ws;
// char ifaddr[64];
// char prefix[64];
} nnb_pub_opt;
static struct option long_options[] = {
{ "host", required_argument, NULL, 0 },
{ "port", required_argument, NULL, 0 },
{ "topic", required_argument, NULL, 0 },
{ "version", required_argument, NULL, 0 },
{ "count", required_argument, NULL, 0 },
{ "startnumber", required_argument, NULL, 0 },
{ "interval", required_argument, NULL, 0 },
{ "username", required_argument, NULL, 0 },
{ "password", required_argument, NULL, 0 },
{ "keepalive", required_argument, NULL, 0 },
{ "clean", required_argument, NULL, 0 },
{ "limit", required_argument, NULL, 0 },
{ "qos", required_argument, NULL, 0 },
{ "size", required_argument, NULL, 0 },
{ "retain", required_argument, NULL, 0 },
{ "interval_of_msg", required_argument, NULL, 0 },
{ "ssl", no_argument, NULL, 0 },
{ "cafile", required_argument, NULL, 0 },
{ "certfile", required_argument, NULL, 0 },
{ "keyfile", required_argument, NULL, 0 },
{ "keypass", required_argument, NULL, 0 },
// { "ifaddr", required_argument, NULL, 0 },
// { "prefix", required_argument, NULL, 0 },
{ "help", no_argument, NULL, 0 }, { NULL, 0, NULL, 0 }
};
nnb_conn_opt *nnb_conn_opt_init(int argc, char **argv);
void nnb_conn_opt_destory(nnb_conn_opt *opt);
nnb_sub_opt *nnb_sub_opt_init(int argc, char **argv);
void nnb_sub_opt_destory(nnb_sub_opt *opt);
nnb_pub_opt *nnb_pub_opt_init(int argc, char **argv);
void nnb_pub_opt_destory(nnb_pub_opt *opt);
#endif