OldSchool Library 1.5.1
Loading...
Searching...
No Matches
net.h File Reference

Network functions in OSLib. More...

#include <sys/select.h>
#include <pspnet_apctl.h>

Data Structures

struct  oslNetConfig
 Structure for network configuration. More...
 

Macros

#define OSL_MAX_NET_CONFIGS   20
 Maximum number of network configurations.
 
#define OSL_RESOLVER_RETRY   4
 Number of retry attempts for resolving an address.
 
APCTL States

APCTL states returned by oslGetAPState().

#define OSL_APCTL_STATE_DISCONNECTED   PSP_NET_APCTL_STATE_DISCONNECTED
 Disconnected state.
 
#define OSL_APCTL_STATE_SCANNING   PSP_NET_APCTL_STATE_SCANNING
 Scanning for access points.
 
#define OSL_APCTL_STATE_JOINING   PSP_NET_APCTL_STATE_JOINING
 Joining access point.
 
#define OSL_APCTL_STATE_GETTING_IP   PSP_NET_APCTL_STATE_GETTING_IP
 Getting IP address.
 
#define OSL_APCTL_STATE_GOT_IP   PSP_NET_APCTL_STATE_GOT_IP
 Successfully got IP address.
 
#define OSL_APCTL_STATE_EAP_AUTH   PSP_NET_APCTL_STATE_EAP_AUTH
 EAP authentication in progress.
 
#define OSL_APCTL_STATE_KEY_EXCHANGE   PSP_NET_APCTL_STATE_KEY_EXCHANGE
 Key exchange in progress.
 
Error Codes

Error codes returned by network functions.

#define OSL_NET_ERROR_NET   -1
 Generic network error.
 
#define OSL_NET_ERROR_INET   -2
 Internet error.
 
#define OSL_NET_ERROR_RESOLVER   -3
 Resolver error.
 
#define OSL_NET_ERROR_APCTL   -4
 APCTL error.
 
#define OSL_NET_ERROR_SSL   -5
 SSL error.
 
#define OSL_NET_ERROR_HTTP   -6
 HTTP error.
 
#define OSL_NET_ERROR_HTTPS   -7
 HTTPS error.
 
#define OSL_NET_ERROR_CERT   -8
 Certificate error.
 
#define OSL_NET_ERROR_COOKIE   -9
 Cookie error.
 
#define OSL_ERR_APCTL_GETINFO   -10
 Error getting APCTL info.
 
#define OSL_ERR_APCTL_CONNECT   -11
 Error connecting to APCTL.
 
#define OSL_ERR_APCTL_TIMEOUT   -12
 APCTL connection timeout.
 
#define OSL_ERR_APCTL_GETSTATE   -13
 Error getting APCTL state.
 
#define OSL_ERR_RESOLVER_CREATE   -14
 Error creating resolver.
 
#define OSL_ERR_RESOLVER_RESOLVING   -15
 Error resolving address.
 
#define OSL_ERR_WLAN_OFF   -16
 WLAN is turned off.
 
#define OSL_USER_ABORTED   -17
 Operation was aborted by the user.
 
#define OSL_ERR_HTTP_INIT   -18
 Error initializing HTTP.
 
#define OSL_ERR_HTTP_TEMPLATE   -19
 Error with HTTP template.
 
#define OSL_ERR_HTTP_TIMEOUT   -20
 HTTP connection timeout.
 
#define OSL_ERR_HTTP_CONNECT   -21
 Error connecting via HTTP.
 
#define OSL_ERR_HTTP_REQUEST   -22
 Error making HTTP request.
 
#define OSL_ERR_HTTP_GENERIC   -23
 Generic HTTP error.
 

Functions

int oslIsWlanPowerOn ()
 Checks if the WLAN switch is powered on.
 
int oslIsWlanConnected ()
 Checks if the WLAN is connected to an Access Point.
 
int oslGetNetConfigs (struct oslNetConfig *result)
 Gets the network configurations.
 
int oslIsNetActive ()
 Returns whether the network is initialized.
 
int oslNetInit ()
 Initializes the network.
 
int oslNetTerm ()
 Terminates the network.
 
int oslGetIPaddress (char *IPaddress)
 Gets the current IP address when connected to an Access Point.
 
int oslConnectToAP (int config, int timeout, int(*apctlCallback)(int state))
 Tries to connect to an Access Point using the given configuration.
 
int oslDisconnectFromAP ()
 Disconnects from the Access Point.
 
int oslGetAPState ()
 Gets the current Access Point state.
 
int oslResolveAddress (char *address, char *resolvedIP)
 Resolves an address to its IP address.
 
int oslNetGetFile (const char *url, const char *filepath)
 Gets a file from the web and saves it to the specified filepath.
 
int oslNetPostForm (const char *url, char *data, char *response, unsigned int responsesize)
 Posts a web form.
 
int oslNetSocketCreate (void)
 Creates a network socket.
 
int oslNetSocketAccept (int socket)
 Accepts a connection on a socket.
 
int oslNetSocketBind (int socket, unsigned short port)
 Binds a socket to a port.
 
int oslNetSocketListen (int socket, unsigned int maxconn)
 Listens for incoming connections on a socket.
 
int oslNetSocketConnect (int socket, char *ip, unsigned short port)
 Connects a socket to a remote host.
 
int oslNetSocketSend (int socket, const void *data, int length)
 Sends data over a socket.
 
int oslNetSocketReceive (int socket, void *data, int length)
 Receives data from a socket.
 
void oslNetSocketClose (int socket)
 Closes a socket.
 
void oslNetSocketSetClear (fd_set *set)
 Clears a socket set.
 
void oslNetSocketSetAdd (int socket, fd_set *set)
 Adds a socket to a socket set.
 
void oslNetSocketSetRemove (int socket, fd_set *set)
 Removes a socket from a socket set.
 
int oslNetSocketSetIsMember (int socket, fd_set *set)
 Checks if a socket is a member of a socket set.
 
int oslNetSocketSetSelect (unsigned int maxsockets, fd_set *set)
 Selects the ready sockets from a set of sockets.
 

Detailed Description

Network functions in OSLib.

This file provides the networking API: WLAN handling, access point connection and socket operations on the PSP.