Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / flight / pios / osx / inc / pios_tcp_priv.h
blob31ff754de14b5ef386264aacce52d639e96848a6
1 /**
2 ******************************************************************************
4 * @file pios_tcp_priv.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
6 * @brief TCP private definitions.
7 * @see The GNU Public License (GPL) Version 3
9 *****************************************************************************/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #ifndef PIOS_TCP_PRIV_H
27 #define PIOS_TCP_PRIV_H
29 #include <pios.h>
30 #include <stdio.h>
31 #include <pthread.h>
32 #include <sys/socket.h>
33 #include <arpa/inet.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <unistd.h>
37 #include <fcntl.h>
38 #include <netinet/in.h>
39 #include "fifo_buffer.h"
41 struct pios_tcp_cfg {
42 const char *ip;
43 uint16_t port;
46 typedef struct {
47 const struct pios_tcp_cfg *cfg;
48 pthread_t rxThread;
50 int socket;
51 struct sockaddr_in server;
52 struct sockaddr_in client;
53 uint32_t clientLength;
54 int socket_connection;
56 pthread_cond_t cond;
57 pthread_mutex_t mutex;
59 pios_com_callback tx_out_cb;
60 uint32_t tx_out_context;
61 pios_com_callback rx_in_cb;
62 uint32_t rx_in_context;
64 t_fifo_buffer rx_fifo;
65 uint8_t rx_buffer[PIOS_TCP_RX_BUFFER_SIZE];
66 uint8_t tx_buffer[PIOS_TCP_RX_BUFFER_SIZE];
67 } pios_tcp_dev;
69 extern int32_t PIOS_TCP_Init(uint32_t *tcp_id, const struct pios_tcp_cfg *cfg);
71 #endif /* PIOS_TCP_PRIV_H */