- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# network.h

Go to the documentation of this file.

    00001 /*********************************************************************************
    00002
    00003  Copyright 2006-2008 MakingThings
    00004
    00005  Licensed under the Apache License,
    00006  Version 2.0 (the "License"); you may not use this file except in compliance
    00007  with the License. You may obtain a copy of the License at
    00008
    00009  http://www.apache.org/licenses/LICENSE-2.0
    00010
    00011  Unless required by applicable law or agreed to in writing, software distributed
    00012  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    00013  CONDITIONS OF ANY KIND, either express or implied. See the License for
    00014  the specific language governing permissions and limitations under the License.
    00015
    00016 *********************************************************************************/
    00017
    00018 /**
    00019   @file
    00020   Network system defines.
    00021 */
    00022
    00023 #ifndef NETWORK_H
    00024 #define NETWORK_H
    00025
    00026 /**
    00027   \def IP_ADDRESS( a, b, c, d )
    00028   Generate an address appropriate for Socket functions from 4 integers.
    00029   \b Example
    00030   \code
    00031   void* sock = Socket( IP_ADDRESS( 192, 168, 0, 200 ), 80 );
    00032   \endcode
    00033   \ingroup Sockets
    00034 */
    00035 // lwIP socket addresses are formatted this way...
    00036 #define IP_ADDRESS( a, b, c, d ) ( ( (int)a << 24 ) + ( (int)b << 16 ) + ( (int)c << 8 ) + (int)d )
    00037 #define IP_ADDRESS_A( address )  ( ( (int)address >> 24 ) & 0xFF )
    00038 #define IP_ADDRESS_B( address )  ( ( (int)address >> 16 ) & 0xFF )
    00039 #define IP_ADDRESS_C( address )  ( ( (int)address >>  8 ) & 0xFF )
    00040 #define IP_ADDRESS_D( address )  ( ( (int)address       ) & 0xFF )
    00041 // the lwIP netif structure formats the address the other way round...weird.
    00042 #define NETIF_IP_ADDRESS( a, b, c, d ) ( ( (int)d << 24 ) + ( (int)c << 16 ) + ( (int)b << 8 ) + (int)a )
    00043 #define NETIF_IP_ADDRESS_D( address )  ( ( (int)address >> 24 ) & 0xFF )
    00044 #define NETIF_IP_ADDRESS_C( address )  ( ( (int)address >> 16 ) & 0xFF )
    00045 #define NETIF_IP_ADDRESS_B( address )  ( ( (int)address >>  8 ) & 0xFF )
    00046 #define NETIF_IP_ADDRESS_A( address )  ( ( (int)address       ) & 0xFF )
    00047
    00048
    00049 // Network API stuff
    00050 int Network_SetActive( int active );
    00051 int Network_GetActive( void );
    00052 int Network_Init( void );
    00053
    00054 int Network_SetAddress( int a0, int a1, int a2, int a3 );
    00055 int Network_SetMask( int a0, int a1, int a2, int a3 );
    00056 int Network_SetGateway( int a0, int a1, int a2, int a3 );
    00057 int Network_SetValid( int v );
    00058
    00059 int Network_GetAddress( int* a0, int* a1, int* a2, int* a3 );
    00060 int Network_GetMask( int* a0, int* a1, int* a2, int* a3 );
    00061 int Network_GetGateway( int* a0, int* a1, int* a2, int* a3 );
    00062 int Network_GetValid( void );
    00063
    00064 // TCP stuff
    00065 void* Socket( int address, int port );
    00066 int SocketBytesAvailable( void* socket );
    00067 int SocketRead( void* socket, char* data, int length );
    00068 int SocketReadLine( void* socket, char* data, int length );
    00069 int SocketWrite( void* socket, char* data, int length );
    00070 void SocketClose( void* socket );
    00071
    00072 void* ServerSocket( int port );
    00073 void* ServerSocketAccept( void* serverSocket );
    00074 int ServerSocketClose( void* serverSocket );
    00075
    00076 int SocketSendDecimal( void *socket, int d );
    00077
    00078 // UDP stuff
    00079 void* DatagramSocket( int port );
    00080 int DatagramSocketSend( void* datagramSocket, int address, int port, void* data, int length );
    00081 int DatagramSocketReceive( void* datagramSocket, int receivingPort, int* address, int* port, void* data, int length );
    00082 void DatagramSocketClose( void* socket );
    00083
    00084 // DHCP stuff
    00085 void Network_SetDhcpEnabled( int enabled );
    00086 int Network_GetDhcpEnabled( void );
    00087
    00088 // DNS stuff
    00089 int Network_DnsGetHostByName( const char *name );
    00090
    00091 // WebServer Stuff
    00092 void Network_SetWebServerEnabled( int enabled );
    00093 int Network_GetWebServerEnabled( void );
    00094 void Network_StartWebServer( void );
    00095 void Network_StopWebServer( void );
    00096
    00097 // NetworkOsc Interface
    00098 const char* NetworkOsc_GetName( void );
    00099 int NetworkOsc_ReceiveMessage( int channel, char* message, int length );
    00100 int NetworkOsc_Poll( void );
    00101 void NetworkOsc_SetUdpListenPort( int port );
    00102 int NetworkOsc_GetUdpListenPort( void );
    00103 void NetworkOsc_SetUdpSendPort( int port );
    00104 int NetworkOsc_GetUdpSendPort( void );
    00105 void NetworkOsc_SetTcpOutAddress( int a0, int a1, int a2, int a3 );
    00106 int NetworkOsc_GetTcpOutAddress( void );
    00107 int NetworkOsc_GetTcpOutPort( void );
    00108 void NetworkOsc_SetTcpOutPort( int port );
    00109 void NetworkOsc_SetTcpAutoConnect( int yesorno );
    00110 int NetworkOsc_GetTcpAutoConnect( void );
    00111 int NetworkOsc_GetTcpRequested( void );
    00112
    00113 #endif

The Make Controller Kit is an open source project maintained by MakingThings.
MakingThings code is released under the Apache 2.0 license.
Bug tracker, development wiki and status can be found at http://dev.makingthings.com.
This document was last updated on 18 May 2009.