DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
stbhwnet.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2009 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 /* pre-processor mechanism so multiple inclusions don't cause compilation error*/
26 #ifndef _STBHWNET_H
27 #define _STBHWNET_H
28 
29 #include "techtype.h"
30 
31 
32 /*---Constant and macro definitions for public use-----------------------------*/
33 /* the maximum size address string that the API will return */
34 #ifndef MAX_ADDR_STRING_LEN
35 #define MAX_ADDR_STRING_LEN 255
36 #endif
37 
38 #ifndef SOCK_SETSIZE
39 #define SOCK_SETSIZE 64
40 #endif
41 
42 /* removes socket "sock" from set "set" */
43 #define SOCK_CLR(sock, set) STB_NWSockClear((sock), (set));
44 
45 /* adds socket "sock" to set "set" */
46 #define SOCK_SET(sock, set) STB_NWSockSet((sock), (set));
47 
48 /* empties set "set" */
49 #define SOCK_ZERO(set) STB_NWSockZero((set))
50 
51 /* true if socket "sock" is a member of "set" */
52 #define SOCK_ISSET(sock, set) STB_NWSockIsSet((sock), (set))
53 
54 #ifndef INVALID_SOCKET
55 #define INVALID_SOCKET 0
56 #endif
57 
58 /*---Enumerations for public use-----------------------------------------------*/
59 typedef enum
60 {
61  NW_WIRED,
62  NW_WIRELESS
63 } E_NW_INTERFACE;
64 
65 typedef enum
66 {
67  NW_AF_INET,
68  NW_AF_INET6
69 } E_NW_AF;
70 
71 typedef enum
72 {
73  NW_SOCK_STREAM,
74  NW_SOCK_DGRAM
75 } E_NW_TYPE;
76 
77 typedef enum
78 {
79  NW_PROTOCOL_TCP,
80  NW_PROTOCOL_UDP
81 } E_NW_PROTOCOL;
82 
83 typedef enum
84 {
85  NW_LINK_ACTIVE,
86  NW_LINK_INACTIVE,
87  NW_LINK_DISABLED
88 } E_NW_LINK_STATUS;
89 
90 typedef enum
91 {
92  NW_OK,
93  NW_ERROR,
94  NW_BAD_PARAM,
95  NW_PENDING
96 } E_NW_ERROR;
97 
98 typedef void (*NW_eth_callback)(E_NW_INTERFACE iface, E_NW_LINK_STATUS iface_status);
99 typedef void *NW_handle;
100 
101 /*---Global type defs for public use-------------------------------------------*/
102 typedef struct
103 {
104  U16BIT sock_count;
105  void *sock_array[SOCK_SETSIZE];
106 } S_NW_SOCKSET;
107 
108 typedef struct
109 {
110  E_NW_AF af;
111  E_NW_TYPE type;
112  E_NW_PROTOCOL protocol;
113  U8BIT addr[48];
115 
116 typedef struct
117 {
118  U8BIT *essid;
119  U8BIT quality;
120  BOOLEAN encrypted;
121  BOOLEAN connected;
123 
124 /*---Global Function prototypes for public use---------------------------------*/
129 BOOLEAN STB_NWInitialise(void);
130 
136 BOOLEAN STB_NWSelectInterface(E_NW_INTERFACE iface);
137 
142 E_NW_INTERFACE STB_NWGetSelectedInterface(void);
143 
150 E_NW_LINK_STATUS STB_NWGetLinkStatus(void);
151 
157 NW_handle STB_NWStartEthernetMonitor( NW_eth_callback func );
158 
162 void STB_NWStopEthernetMonitor( NW_handle hdl );
163 
171 BOOLEAN STB_NWGetMACAddress(E_NW_INTERFACE iface, U8BIT *mac_addr);
172 
180 U16BIT STB_NWLookupAddress(U8BIT *name, S_NW_ADDR_INFO **nw_addrs);
181 
189 void* STB_NWOpenSocket(E_NW_AF af, E_NW_TYPE type, E_NW_PROTOCOL protocol, BOOLEAN nonblock);
190 
196 BOOLEAN STB_NWCloseSocket(void *socket);
197 
205 BOOLEAN STB_NWBind(void *socket, U8BIT *address, U32BIT port);
206 
214 BOOLEAN STB_NWSetReuseaddr(void *socket, BOOLEAN state);
215 
223 BOOLEAN STB_NWGetReuseaddr(void *socket, BOOLEAN *state);
224 
231 BOOLEAN STB_NWAddMembership(void *socket, U8BIT *group_address);
232 
239 BOOLEAN STB_NWDropMembership(void *socket, U8BIT *group_address);
240 
249 BOOLEAN STB_NWGetSocketName(void *socket, E_NW_AF *af, U8BIT *address, U32BIT *port);
250 
258 E_NW_ERROR STB_NWConnect(void *socket, U8BIT *address, U32BIT port);
259 
266 BOOLEAN STB_NWListen(void *socket, S32BIT backlog);
267 
276 void* STB_NWAccept(void *socket, U8BIT *address, U32BIT *port);
277 
287 S32BIT STB_NWSend(void *socket, U8BIT *buf, U32BIT num_bytes);
288 
298 S32BIT STB_NWReceive(void *socket, U8BIT *buf, U32BIT max_bytes);
299 
311 S32BIT STB_NWReceiveFrom(void *socket, U8BIT *buf, U32BIT max_bytes, U8BIT *address, U32BIT *port);
312 
323 S32BIT STB_NWSendTo(void *socket, U8BIT *buf, U32BIT num_bytes,
324  U8BIT *address, U32BIT port);
325 
333 BOOLEAN STB_NWSockIsSet(void *socket, S_NW_SOCKSET *socks);
334 
339 void STB_NWSockZero(S_NW_SOCKSET *socks);
340 
346 void STB_NWSockClear(void *socket, S_NW_SOCKSET *socks);
347 
353 void STB_NWSockSet(void *socket, S_NW_SOCKSET *socks);
354 
367 S32BIT STB_NWSelect(S_NW_SOCKSET *read_sockets, S_NW_SOCKSET *write_sockets,
368  S_NW_SOCKSET *except_sockets, S32BIT timeout_ms);
369 
370 
377 U16BIT STB_NWGetWirelessAccessPoints(S_NW_ACCESS_POINT **access_points);
378 
384 void STB_NWFreeWirelessAccessPoints(S_NW_ACCESS_POINT *access_points, U16BIT num_aps);
385 
394 BOOLEAN STB_NWConnectToAccessPoint(U8BIT *essid, U8BIT *password);
395 
396 
397 #endif /* _STBHWNET_H */
BOOLEAN STB_NWCloseSocket(void *socket)
Closes (destroys) a socket instance.
U16BIT STB_NWLookupAddress(U8BIT *name, S_NW_ADDR_INFO **nw_addrs)
Performs a lookup to find the IP address(es) of the given host name.
NW_handle STB_NWStartEthernetMonitor(NW_eth_callback func)
Start monitoring the ethernet status.
BOOLEAN STB_NWDropMembership(void *socket, U8BIT *group_address)
Sets the ip option IP_DROP_MEMBERSHIP.
void * STB_NWOpenSocket(E_NW_AF af, E_NW_TYPE type, E_NW_PROTOCOL protocol, BOOLEAN nonblock)
Opens (creates) a new socket for subsequent use.
BOOLEAN STB_NWGetSocketName(void *socket, E_NW_AF *af, U8BIT *address, U32BIT *port)
Gets the socket's "name" (family, address and port)
BOOLEAN STB_NWSelectInterface(E_NW_INTERFACE iface)
Sets the network interface that will be used for all network or IP operations.
S32BIT STB_NWReceiveFrom(void *socket, U8BIT *buf, U32BIT max_bytes, U8BIT *address, U32BIT *port)
Receives a datagram and returns the data and its source address.
void STB_NWFreeWirelessAccessPoints(S_NW_ACCESS_POINT *access_points, U16BIT num_aps)
Frees the array of access points returned by STB_NWGetWirelessAccessPoints.
E_NW_ERROR STB_NWConnect(void *socket, U8BIT *address, U32BIT port)
Connects the socket to a remote host.
E_NW_LINK_STATUS STB_NWGetLinkStatus(void)
Get the selected interface link status.
void * STB_NWAccept(void *socket, U8BIT *address, U32BIT *port)
Accepts an incoming connection attempt on a socket.
BOOLEAN STB_NWSockIsSet(void *socket, S_NW_SOCKSET *socks)
Returns whether a specified socket is a member of a specified set.
U16BIT STB_NWGetWirelessAccessPoints(S_NW_ACCESS_POINT **access_points)
Scans and returns all access points visible on the wireless network.
E_NW_INTERFACE STB_NWGetSelectedInterface(void)
Returns the selected interface.
Definition: stbhwnet.h:116
BOOLEAN STB_NWAddMembership(void *socket, U8BIT *group_address)
Sets the ip option IP_ADD_MEMBERSHIP.
BOOLEAN STB_NWGetReuseaddr(void *socket, BOOLEAN *state)
Gets the socket option SO_REUSEADDR.
void STB_NWSockClear(void *socket, S_NW_SOCKSET *socks)
Clears the specified socket from the specified set.
void STB_NWStopEthernetMonitor(NW_handle hdl)
Stop monitoring the ethernet status.
BOOLEAN STB_NWSetReuseaddr(void *socket, BOOLEAN state)
Sets the socket option SO_REUSEADDR.
S32BIT STB_NWSelect(S_NW_SOCKSET *read_sockets, S_NW_SOCKSET *write_sockets, S_NW_SOCKSET *except_sockets, S32BIT timeout_ms)
Determines the status of one or more sockets, blocking if necessary.
BOOLEAN STB_NWInitialise(void)
Initialises the socket API, must be called once before using API.
BOOLEAN STB_NWGetMACAddress(E_NW_INTERFACE iface, U8BIT *mac_addr)
Gets the MAC address of the default ethernet connection.
S32BIT STB_NWReceive(void *socket, U8BIT *buf, U32BIT max_bytes)
Receives data from a connected socket.
System Wide Global Technical Data Type Definitions.
S32BIT STB_NWSend(void *socket, U8BIT *buf, U32BIT num_bytes)
Sends data on a connected socket.
S32BIT STB_NWSendTo(void *socket, U8BIT *buf, U32BIT num_bytes, U8BIT *address, U32BIT port)
Sends data to a specific destination.
Definition: stbhwnet.h:102
void STB_NWSockSet(void *socket, S_NW_SOCKSET *socks)
Sets a specificed socket in a specified set.
void STB_NWSockZero(S_NW_SOCKSET *socks)
Clears the socket set.
Definition: stbhwnet.h:108
BOOLEAN STB_NWListen(void *socket, S32BIT backlog)
Put socket into state of waiting for incoming connection.
BOOLEAN STB_NWConnectToAccessPoint(U8BIT *essid, U8BIT *password)
Attempts to connect to the wireless network with the given SSID. If the network is open then 'passwor...
BOOLEAN STB_NWBind(void *socket, U8BIT *address, U32BIT port)
Binds (names) a socket in the local address space.