Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
udp_socket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2015 The Paparazzi Team
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
28 #ifndef UDP_SOCKET_H
29 #define UDP_SOCKET_H
30 
31 #include <netinet/in.h>
32 #include "std.h"
33 
34 struct UdpSocket {
35  int sockfd;
36  struct sockaddr_in addr_in;
37  struct sockaddr_in addr_out;
38 };
39 
49 extern int udp_socket_create(struct UdpSocket *sock, char *host, int port_out, int port_in, bool broadcast);
50 
58 extern int udp_socket_send(struct UdpSocket *sock, uint8_t *buffer, uint32_t len);
59 
67 extern int udp_socket_send_dontwait(struct UdpSocket *sock, uint8_t *buffer, uint32_t len);
68 
76 extern int udp_socket_recv_dontwait(struct UdpSocket *sock, uint8_t *buffer, uint32_t len);
77 
85 extern int udp_socket_recv(struct UdpSocket *sock, uint8_t *buffer, uint32_t len);
86 
87 extern int udp_socket_subscribe_multicast(struct UdpSocket *sock, const char *multicast_addr);
88 extern int udp_socket_set_recvbuf(struct UdpSocket *sock, int buf_size);
89 extern int udp_socket_set_sendbuf(struct UdpSocket *sock, int buf_size);
90 #endif /* UDP_SOCKET_H */
int udp_socket_recv(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Receive one UDP packet.
Definition: udp_socket.c:185
int udp_socket_subscribe_multicast(struct UdpSocket *sock, const char *multicast_addr)
Definition: udp_socket.c:194
int udp_socket_send_dontwait(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Send a packet from buffer, non-blocking.
Definition: udp_socket.c:141
int udp_socket_set_recvbuf(struct UdpSocket *sock, int buf_size)
Definition: udp_socket.c:205
int udp_socket_create(struct UdpSocket *sock, char *host, int port_out, int port_in, bool broadcast)
Create UDP network (in/out sockets).
Definition: udp_socket.c:49
int udp_socket_set_sendbuf(struct UdpSocket *sock, int buf_size)
Definition: udp_socket.c:220
struct sockaddr_in addr_in
Definition: udp_socket.h:36
struct sockaddr_in addr_out
Definition: udp_socket.h:37
int sockfd
Definition: udp_socket.h:35
int udp_socket_send(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Send a packet from buffer, blocking.
Definition: udp_socket.c:120
int udp_socket_recv_dontwait(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Receive a UDP packet, dont wait.
Definition: udp_socket.c:160
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98