DVBCore
1.0
Open source DVB engine
|
00001 /******************************************************************************* 00002 * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org) 00003 * Copyright © 2009 Ocean Blue Software Ltd 00004 * 00005 * This file is part of a DTVKit Software Component 00006 * You are permitted to copy, modify or distribute this file subject to the terms 00007 * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org 00008 * 00009 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 00010 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 00011 * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. 00012 * 00013 * If you or your organisation is not a member of DTVKit then you have access 00014 * to this source code outside of the terms of the licence agreement 00015 * and you are expected to delete this and any associated files immediately. 00016 * Further information on DTVKit, membership and terms can be found at www.dtvkit.org 00017 *******************************************************************************/ 00025 /* pre-processor mechanism so multiple inclusions don't cause compilation error*/ 00026 #ifndef _STBHWNET_H 00027 #define _STBHWNET_H 00028 00029 00030 /*---Constant and macro definitions for public use-----------------------------*/ 00031 /* the maximum size address string that the API will return */ 00032 #ifndef MAX_ADDR_STRING_LEN 00033 #define MAX_ADDR_STRING_LEN 255 00034 #endif 00035 00036 #ifndef SOCK_SETSIZE 00037 #define SOCK_SETSIZE 64 00038 #endif 00039 00040 /* removes socket "sock" from set "set" */ 00041 #define SOCK_CLR(sock, set) STB_NWSockClear((sock), (set)); 00042 00043 /* adds socket "sock" to set "set" */ 00044 #define SOCK_SET(sock, set) STB_NWSockSet((sock), (set)); 00045 00046 /* empties set "set" */ 00047 #define SOCK_ZERO(set) STB_NWSockZero((set)) 00048 00049 /* true if socket "sock" is a member of "set" */ 00050 #define SOCK_ISSET(sock, set) STB_NWSockIsSet((sock), (set)) 00051 00052 #ifndef INVALID_SOCKET 00053 #define INVALID_SOCKET 0 00054 #endif 00055 00056 /*---Enumerations for public use-----------------------------------------------*/ 00057 typedef enum 00058 { 00059 NW_WIRED, 00060 NW_WIRELESS 00061 } E_NW_INTERFACE; 00062 00063 typedef enum 00064 { 00065 NW_AF_INET, 00066 NW_AF_INET6 00067 } E_NW_AF; 00068 00069 typedef enum 00070 { 00071 NW_SOCK_STREAM, 00072 NW_SOCK_DGRAM 00073 } E_NW_TYPE; 00074 00075 typedef enum 00076 { 00077 NW_PROTOCOL_TCP, 00078 NW_PROTOCOL_UDP 00079 } E_NW_PROTOCOL; 00080 00081 typedef enum 00082 { 00083 NW_LINK_ACTIVE, 00084 NW_LINK_INACTIVE, 00085 NW_LINK_DISABLED 00086 } E_NW_LINK_STATUS; 00087 00088 typedef enum 00089 { 00090 NW_OK, 00091 NW_ERROR, 00092 NW_BAD_PARAM, 00093 NW_PENDING 00094 } E_NW_ERROR; 00095 00096 typedef void (*NW_eth_callback)(void); 00097 typedef void *NW_handle; 00098 00099 /*---Global type defs for public use-------------------------------------------*/ 00100 typedef struct 00101 { 00102 U16BIT sock_count; 00103 void *sock_array[SOCK_SETSIZE]; 00104 } S_NW_SOCKSET; 00105 00106 typedef struct 00107 { 00108 E_NW_AF af; 00109 E_NW_TYPE type; 00110 E_NW_PROTOCOL protocol; 00111 U8BIT addr[48]; 00112 } S_NW_ADDR_INFO; 00113 00114 typedef struct 00115 { 00116 U8BIT *essid; 00117 U8BIT quality; 00118 BOOLEAN encrypted; 00119 BOOLEAN connected; 00120 } S_NW_ACCESS_POINT; 00121 00122 /*---Global Function prototypes for public use---------------------------------*/ 00127 BOOLEAN STB_NWInitialise(void); 00128 00134 BOOLEAN STB_NWSelectInterface(E_NW_INTERFACE iface); 00135 00142 E_NW_LINK_STATUS STB_NWGetLinkStatus(void); 00143 00149 NW_handle STB_NWStartEthernetMonitor( NW_eth_callback func ); 00150 00154 void STB_NWStopEthernetMonitor( NW_handle hdl ); 00155 00163 BOOLEAN STB_NWGetMACAddress(E_NW_INTERFACE iface, U8BIT *mac_addr); 00164 00172 U16BIT STB_NWLookupAddress(U8BIT *name, S_NW_ADDR_INFO **nw_addrs); 00173 00181 void* STB_NWOpenSocket(E_NW_AF af, E_NW_TYPE type, E_NW_PROTOCOL protocol, BOOLEAN nonblock); 00182 00188 BOOLEAN STB_NWCloseSocket(void *socket); 00189 00197 BOOLEAN STB_NWBind(void *socket, U8BIT *address, U32BIT port); 00198 00206 BOOLEAN STB_NWSetReuseaddr(void *socket, BOOLEAN state); 00207 00215 BOOLEAN STB_NWGetReuseaddr(void *socket, BOOLEAN *state); 00216 00223 BOOLEAN STB_NWAddMembership(void *socket, U8BIT *group_address); 00224 00231 BOOLEAN STB_NWDropMembership(void *socket, U8BIT *group_address); 00232 00241 BOOLEAN STB_NWGetSocketName(void *socket, E_NW_AF *af, U8BIT *address, U32BIT *port); 00242 00250 E_NW_ERROR STB_NWConnect(void *socket, U8BIT *address, U32BIT port); 00251 00258 BOOLEAN STB_NWListen(void *socket, S32BIT backlog); 00259 00268 void* STB_NWAccept(void *socket, U8BIT *address, U32BIT *port); 00269 00279 S32BIT STB_NWSend(void *socket, U8BIT *buf, U32BIT num_bytes); 00280 00290 S32BIT STB_NWReceive(void *socket, U8BIT *buf, U32BIT max_bytes); 00291 00303 S32BIT STB_NWReceiveFrom(void *socket, U8BIT *buf, U32BIT max_bytes, U8BIT *address, U32BIT *port); 00304 00315 S32BIT STB_NWSendTo(void *socket, U8BIT *buf, U32BIT num_bytes, 00316 U8BIT *address, U32BIT port); 00317 00325 BOOLEAN STB_NWSockIsSet(void *socket, S_NW_SOCKSET *socks); 00326 00331 void STB_NWSockZero(S_NW_SOCKSET *socks); 00332 00338 void STB_NWSockClear(void *socket, S_NW_SOCKSET *socks); 00339 00345 void STB_NWSockSet(void *socket, S_NW_SOCKSET *socks); 00346 00359 S32BIT STB_NWSelect(S_NW_SOCKSET *read_sockets, S_NW_SOCKSET *write_sockets, 00360 S_NW_SOCKSET *except_sockets, S32BIT timeout_ms); 00361 00362 00369 U16BIT STB_NWGetWirelessAccessPoints(S_NW_ACCESS_POINT **access_points); 00370 00376 void STB_NWFreeWirelessAccessPoints(S_NW_ACCESS_POINT *access_points, U16BIT num_aps); 00377 00386 BOOLEAN STB_NWConnectToAccessPoint(U8BIT *essid, U8BIT *password); 00387 00388 00389 #endif /* _STBHWNET_H */