| /******************************************************************************* | |
| * Copyright (c) 2014 IBM Corp. | |
| * | |
| * 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: | |
| * Allan Stockdill-Mander - initial API and implementation and/or initial documentation | |
| *******************************************************************************/ | |
| #ifndef __MQTT_LINUX_ | |
| #define __MQTT_LINUX_ | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <sys/param.h> | |
| #include <sys/time.h> | |
| #include <sys/select.h> | |
| #include <netinet/in.h> | |
| #include <netinet/tcp.h> | |
| #include <arpa/inet.h> | |
| #include <netdb.h> | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <errno.h> | |
| #include <fcntl.h> | |
| #include <stdbool.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <signal.h> | |
| // #include <openssl/ssl.h> | |
| // #include <openssl/err.h> | |
| //#include "DC_iot_port.h" | |
| typedef struct Timer Timer; | |
| struct Timer { | |
| struct timeval end_time; | |
| }; | |
| typedef struct Network Network; | |
| struct Network | |
| { | |
| int my_socket; | |
| bool is_support_ssl; | |
| bool ingnore_cert; | |
| int handle; | |
| int (*mqttread) (Network*, unsigned char*, int, int); | |
| int (*mqttwrite) (Network*, unsigned char*, int, int); | |
| void (*disconnect) (Network*); | |
| }; | |
| char expired(Timer*); | |
| void countdown_ms(Timer*, unsigned int); | |
| void countdown(Timer*, unsigned int); | |
| int left_ms(Timer*); | |
| void InitTimer(Timer*); | |
| int linux_read(Network*, unsigned char*, int, int); | |
| int linux_write(Network*, unsigned char*, int, int); | |
| void linux_disconnect(Network*); | |
| void NewNetwork(Network*); | |
| int ConnectNetwork(Network*, char*, int, bool ,bool ); | |
| #endif |