liubin | 281ac46 | 2023-07-19 14:22:54 +0800 | [diff] [blame] | 1 | /*******************************************************************************
|
| 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 |
|
| 42 | typedef struct Timer Timer;
|
| 43 |
|
| 44 | struct Timer {
|
| 45 | struct timeval end_time;
|
| 46 | };
|
| 47 |
|
| 48 | typedef struct Network Network;
|
| 49 | struct 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 |
|
| 60 | char expired(Timer*);
|
| 61 | void countdown_ms(Timer*, unsigned int);
|
| 62 | void countdown(Timer*, unsigned int);
|
| 63 | int left_ms(Timer*);
|
| 64 |
|
| 65 | void InitTimer(Timer*);
|
| 66 |
|
| 67 | int linux_read(Network*, unsigned char*, int, int);
|
| 68 | int linux_write(Network*, unsigned char*, int, int);
|
| 69 | void linux_disconnect(Network*);
|
| 70 | void NewNetwork(Network*);
|
| 71 |
|
| 72 | int ConnectNetwork(Network*, char*, int, bool ,bool );
|
| 73 |
|
| 74 | #endif |