FreeNOS
socket.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIBPOSIX_SYS_SOCKET_H
19 #define __LIBPOSIX_SYS_SOCKET_H
20 
21 #include <Macros.h>
22 #include "types.h"
23 
35 struct sockaddr
36 {
39 };
40 
44 struct iovec
45 {
46  void *iov_base;
47  size_t iov_len;
48 };
49 
50 typedef Size socklen_t;
51 
55 struct msghdr
56 {
57  void *msg_name;
59  struct iovec *msg_iov;
60  size_t msg_iovlen;
61  void *msg_control;
63  int msg_flags;
64 };
65 
75 extern C int connect(int sockfd, struct sockaddr *addr, socklen_t addrlen);
76 
89 extern C int recvfrom(int sockfd, void *buf, size_t len, int flags,
90  struct sockaddr *addr, socklen_t addrlen);
91 
104 extern C int sendto(int sockfd, const void *buf, size_t len, int flags,
105  const struct sockaddr *addr, socklen_t addrlen);
106 
116 extern C int sendmsg(int sockfd, const struct msghdr *msg, int flags);
117 
123 #endif /* __LIBPOSIX_SYS_SOCKET_H */
Macros.h
socklen_t
Size socklen_t
Definition: socket.h:50
types.h
msghdr::msg_controllen
size_t msg_controllen
Definition: socket.h:62
flags
u32 flags
Definition: IntelACPI.h:66
sockaddr::port
u16 port
Definition: socket.h:38
msghdr::msg_iov
struct iovec * msg_iov
Definition: socket.h:59
sockaddr
Defines a socket address and port pair.
Definition: socket.h:35
recvfrom
C int recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t addrlen)
Receive a single datagram from a socket.
Definition: recvfrom.cpp:25
msghdr::msg_iovlen
size_t msg_iovlen
Definition: socket.h:60
C
#define C
Used to define external C functions.
Definition: Macros.h:134
msghdr::msg_control
void * msg_control
Definition: socket.h:61
msghdr
Describes one or more datagrams.
Definition: socket.h:55
u16
unsigned short u16
Unsigned 16-bit number.
Definition: Types.h:56
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
iovec::iov_base
void * iov_base
Definition: socket.h:46
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
sendto
C int sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen)
Send a single datagram to a remote host.
Definition: sendto.cpp:25
msghdr::msg_name
void * msg_name
Definition: socket.h:57
msghdr::msg_flags
int msg_flags
Definition: socket.h:63
iovec
Input/Output vector for multi-packet operations.
Definition: socket.h:44
iovec::iov_len
size_t iov_len
Definition: socket.h:47
sockaddr::addr
u32 addr
Definition: socket.h:37
connect
C int connect(int sockfd, struct sockaddr *addr, socklen_t addrlen)
Connect a socket to an address/port.
Definition: connect.cpp:23
msghdr::msg_namelen
socklen_t msg_namelen
Definition: socket.h:58
sendmsg
C int sendmsg(int sockfd, const struct msghdr *msg, int flags)
Send multiple datagrams to a remote host.
Definition: sendmsg.cpp:24