00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __LWES_NET_FUNCTIONS_H
00021 #define __LWES_NET_FUNCTIONS_H
00022
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <ctype.h>
00026 #include <errno.h>
00027 #include <sys/types.h>
00028 #include <sys/time.h>
00029 #include <sys/socket.h>
00030 #include <netinet/in.h>
00031 #include <arpa/inet.h>
00032 #include <unistd.h>
00033
00034 #include "lwes_types.h"
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00047 struct lwes_net_connection
00048 {
00050 int socketfd;
00051
00053 struct sockaddr_in mcast_addr;
00054
00056 struct ip_mreq mreq;
00057
00059 struct sockaddr_in sender_ip_addr;
00060
00062 socklen_t sender_ip_socket_size;
00063
00066 int hasJoined;
00067 };
00068
00079 int
00080 lwes_net_open
00081 (struct lwes_net_connection *conn,
00082 const char *address,
00083 const char *iface,
00084 int port);
00085
00093 int
00094 lwes_net_close
00095 (struct lwes_net_connection *conn);
00096
00103 int
00104 lwes_net_get_ttl
00105 (struct lwes_net_connection *conn);
00106
00114 int
00115 lwes_net_set_ttl
00116 (struct lwes_net_connection *conn, int new_ttl);
00117
00124 int
00125 lwes_net_get_sock_fd
00126 (struct lwes_net_connection *conn);
00127
00136 int
00137 lwes_net_send_bytes
00138 (struct lwes_net_connection *conn,
00139 LWES_BYTE_P bytes,
00140 size_t len);
00141
00159 int
00160 lwes_net_sendto_bytes
00161 (struct lwes_net_connection *conn,
00162 char *address,
00163 char *iface,
00164 int port,
00165 LWES_BYTE_P bytes,
00166 size_t len);
00167
00177 int
00178 lwes_net_recv_bind
00179 (struct lwes_net_connection *conn);
00180
00192 int
00193 lwes_net_recv_bytes
00194 (struct lwes_net_connection *conn,
00195 LWES_BYTE_P bytes,
00196 size_t len);
00197
00210 int
00211 lwes_net_recv_bytes_by
00212 (struct lwes_net_connection *conn,
00213 LWES_BYTE_P bytes,
00214 size_t len,
00215 unsigned int timeout_ms);
00216
00217 #ifdef __cplusplus
00218 }
00219 #endif
00220
00221 #endif