http_porting.c File Reference


Detailed Description

LiMo HTTP Porting functions.

#include "http_internal.h"
#include <netdb.h>


Functions

int NetHttpResolveHost (const char *destname, int destport, const char *device, struct sockaddr **dest, int *dest_len)
 Creates destination information from an IP address or by DNS query from host name.

Function Documentation

int NetHttpResolveHost ( const char *  destname,
int  destport,
const char *  device,
struct sockaddr **  dest,
int *  dest_len 
)

Creates destination information from an IP address or by DNS query from host name.

Parameters:
[in] destname Destination name.
[in] destport Destination port number.
[in] device Device name.
[out] dest Destination information.
[out] dest_len Structure size of the destination information.
Return values:
NET_HTTP_RC_SUCCESS Success.
negative-value Error. Reason code returned.
NET_HTTP_RC_ERR_PARAM Abnormal termination.
NET_HTTP_RC_ERR_DNS Abnormal termination.
NET_HTTP_RC_ERR_GENERAL Abnormal termination.
NET_HTTP_RC_ERR_PORTING An OEM specific error code between NET_HTTP_RC_ERR_PORTING and NET_HTTP_RC_ERR_PORTING - 99.
Note:
This return value will be set as the error code of NET_HTTP_EV_TRANSACTION_ABORT or NET_HTTP_EV_SSL_CLOSE

If NET_HTTP_RC_SUCCESS is returned, the memory for dest will be freed by the caller.

Description:
This function should be implemented by OEM so that it performs the following operations.
1. The destname can be a host name such as "www.yahoo.co.uk" or IP address in string notation such as "217.12.3.11." You have to cope with both of the formats. If it is a host name, obtain an IP address for the host name using DNS query.
2. Allocate memory for "struct sockaddr" structure that is passed to socket function. Set the IP address obtained by DNS query and parameters to this function to that structure.
The sample source uses gethostbyname for the DNS query. The OEM of HTTPLib must customize this function if needed to change the behaviour.

Important Notes:
destname contains the destination IP address or destination host name and must be terminated by NULL.
The destport is the destination port number. The destination here means a proxy if you use a proxy or server if you don't use any proxy.

The "device" is the name of a device to which the socket is bound to (eg. "pdp0"). If the passed device is NULL, handle it as if the OS default device is passed in.

**dest is a structure passed to socket's connect function. *dest_len is the size of the structure.
This function should allocate the memory using http lib porting function MALLOC(). The caller of this function will free the memory. If this function returns an error, the memory should be released with FREE() in this function before returning.

The struct sockaddr type is an abstract type. You have to pass a structure of a specific structure defined for each address family by casting it to (struct sockaddr*). For example use struct sockaddr_in for IPv4.
See Linux man page for details of these address-family specific structures. For example, see ip(7) for IPv4


Generated on Mon Mar 31 01:01:00 2008 by  doxygen 1.5.4