Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
90 #endif /* UDP_SOCKET_H */
int udp_socket_send(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Send a packet from buffer, blocking.
Definition: udp_socket.c:119
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:140
int udp_socket_recv_dontwait(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Receive a UDP packet, dont wait.
Definition: udp_socket.c:159
int sockfd
Definition: udp_socket.h:35
unsigned long uint32_t
Definition: types.h:18
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_recvbuf(struct UdpSocket *sock, int buf_size)
Definition: udp_socket.c:203
struct sockaddr_in addr_in
Definition: udp_socket.h:36
struct sockaddr_in addr_out
Definition: udp_socket.h:37
unsigned char uint8_t
Definition: types.h:14
int udp_socket_recv(struct UdpSocket *sock, uint8_t *buffer, uint32_t len)
Receive one UDP packet.
Definition: udp_socket.c:184
int udp_socket_subscribe_multicast(struct UdpSocket *sock, const char *multicast_addr)
Definition: udp_socket.c:193