blob: 6ca888a00cc1eee833c7126f261e67994aa1dcf3 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001/*******************************************************************************
2 * Copyright (c) 2014 IBM Corp.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Allan Stockdill-Mander - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17#ifndef __MQTT_LINUX_
18#define __MQTT_LINUX_
19
20#include <sys/types.h>
21#include <sys/socket.h>
22#include <sys/param.h>
23#include <sys/time.h>
24#include <sys/select.h>
25#include <netinet/in.h>
26#include <netinet/tcp.h>
27#include <arpa/inet.h>
28#include <netdb.h>
29#include <stdio.h>
30#include <unistd.h>
31#include <errno.h>
32#include <fcntl.h>
33#include <stdbool.h>
34#include <stdlib.h>
35#include <string.h>
36#include <signal.h>
37
38// #include <openssl/ssl.h>
39// #include <openssl/err.h>
40//#include "DC_iot_port.h"
41
42typedef struct Timer Timer;
43
44struct Timer {
45 struct timeval end_time;
46};
47
48typedef struct Network Network;
49struct Network
50{
51 int my_socket;
52 bool is_support_ssl;
53 bool ingnore_cert;
54 int handle;
55 int (*mqttread) (Network*, unsigned char*, int, int);
56 int (*mqttwrite) (Network*, unsigned char*, int, int);
57 void (*disconnect) (Network*);
58};
59
60char expired(Timer*);
61void countdown_ms(Timer*, unsigned int);
62void countdown(Timer*, unsigned int);
63int left_ms(Timer*);
64
65void InitTimer(Timer*);
66
67int linux_read(Network*, unsigned char*, int, int);
68int linux_write(Network*, unsigned char*, int, int);
69void linux_disconnect(Network*);
70void NewNetwork(Network*);
71
72int ConnectNetwork(Network*, char*, int, bool ,bool );
73
74#endif