ObjFW
Classes | Enumerations | Functions
socket.h File Reference
#include "objfw-defs.h"
#include <stdbool.h>
#import "OFString.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/sctp.h>
#include <netipx/ipx.h>
#include "platform.h"
#import "macros.h"
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  of_socket_address_t
 A struct which represents a host / port pair for a socket. More...
 

Enumerations

enum  of_socket_address_family_t {
  OF_SOCKET_ADDRESS_FAMILY_UNKNOWN , OF_SOCKET_ADDRESS_FAMILY_IPV4 , OF_SOCKET_ADDRESS_FAMILY_IPV6 , OF_SOCKET_ADDRESS_FAMILY_IPX ,
  OF_SOCKET_ADDRESS_FAMILY_ANY = 255
}
 A socket address family. More...
 

Functions

of_socket_address_t of_socket_address_parse_ip (OFString *IP, uint16_t port)
 Parses the specified IP and port into an of_socket_address_t. More...
 
of_socket_address_t of_socket_address_parse_ipv4 (OFString *IP, uint16_t port)
 Parses the specified IPv4 and port into an of_socket_address_t. More...
 
of_socket_address_t of_socket_address_parse_ipv6 (OFString *IP, uint16_t port)
 Parses the specified IPv6 and port into an of_socket_address_t. More...
 
of_socket_address_t of_socket_address_ipx (const unsigned char node[_Nonnull IPX_NODE_LEN], uint32_t network, uint16_t port)
 Creates an IPX address for the specified network, node and port. More...
 
bool of_socket_address_equal (const of_socket_address_t *_Nonnull address1, const of_socket_address_t *_Nonnull address2)
 Compares two of_socket_address_t for equality. More...
 
unsigned long of_socket_address_hash (const of_socket_address_t *_Nonnull address)
 Returns the hash for the specified of_socket_address_t. More...
 
OFString *_Nonnull of_socket_address_ip_string (const of_socket_address_t *_Nonnull address, uint16_t *_Nullable port)
 Converts the specified of_socket_address_t to an IP string and port. More...
 
void of_socket_address_set_port (of_socket_address_t *_Nonnull address, uint16_t port)
 Sets the port of the specified of_socket_address_t, independent of the address family used. More...
 
uint16_t of_socket_address_get_port (const of_socket_address_t *_Nonnull address)
 Returns the port of the specified of_socket_address_t, independent of the address family used. More...
 
void of_socket_address_set_ipx_network (of_socket_address_t *_Nonnull address, uint32_t network)
 Sets the IPX network of the specified of_socket_address_t. More...
 
uint32_t of_socket_address_get_ipx_network (const of_socket_address_t *_Nonnull address)
 Returns the IPX network of the specified of_socket_address_t. More...
 
void of_socket_address_set_ipx_node (of_socket_address_t *_Nonnull address, const unsigned char node[_Nonnull IPX_NODE_LEN])
 Sets the IPX node of the specified of_socket_address_t. More...
 
void of_socket_address_get_ipx_node (const of_socket_address_t *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN])
 Gets the IPX node of the specified of_socket_address_t. More...
 

Enumeration Type Documentation

◆ of_socket_address_family_t

A socket address family.

Enumerator
OF_SOCKET_ADDRESS_FAMILY_UNKNOWN 

An unknown address family.

OF_SOCKET_ADDRESS_FAMILY_IPV4 

IPv4

OF_SOCKET_ADDRESS_FAMILY_IPV6 

IPv6

OF_SOCKET_ADDRESS_FAMILY_IPX 

IPX

OF_SOCKET_ADDRESS_FAMILY_ANY 

Any address family

Function Documentation

◆ of_socket_address_equal()

bool of_socket_address_equal ( const of_socket_address_t *_Nonnull  address1,
const of_socket_address_t *_Nonnull  address2 
)

Compares two of_socket_address_t for equality.

Parameters
address1The address to compare with the second address
address2The second address
Returns
Whether the two addresses are equal

◆ of_socket_address_get_ipx_network()

uint32_t of_socket_address_get_ipx_network ( const of_socket_address_t *_Nonnull  address)

Returns the IPX network of the specified of_socket_address_t.

Parameters
addressThe address on which to get the IPX network
Returns
The IPX network of the address

◆ of_socket_address_get_ipx_node()

void of_socket_address_get_ipx_node ( const of_socket_address_t *_Nonnull  address,
unsigned char  node[_Nonnull IPX_NODE_LEN] 
)

Gets the IPX node of the specified of_socket_address_t.

Parameters
addressThe address on which to get the IPX node
nodeA byte array to store the IPX node of the address

◆ of_socket_address_get_port()

uint16_t of_socket_address_get_port ( const of_socket_address_t *_Nonnull  address)

Returns the port of the specified of_socket_address_t, independent of the address family used.

Parameters
addressThe address on which to get the port
Returns
The port of the address

◆ of_socket_address_hash()

unsigned long of_socket_address_hash ( const of_socket_address_t *_Nonnull  address)

Returns the hash for the specified of_socket_address_t.

Parameters
addressThe address to hash
Returns
The hash for the specified of_socket_address_t

◆ of_socket_address_ip_string()

OFString* _Nonnull of_socket_address_ip_string ( const of_socket_address_t *_Nonnull  address,
uint16_t *_Nullable  port 
)

Converts the specified of_socket_address_t to an IP string and port.

Parameters
addressThe address to convert to a string
portA pointer to an uint16_t which should be set to the port of the address or NULL if the port is not needed
Returns
The address as an IP string

◆ of_socket_address_ipx()

of_socket_address_t of_socket_address_ipx ( const unsigned char  node[_Nonnull IPX_NODE_LEN],
uint32_t  network,
uint16_t  port 
)

Creates an IPX address for the specified network, node and port.

Parameters
nodeThe node in the IPX network
networkThe IPX network
portThe IPX port (sometimes called socket number) on the node

◆ of_socket_address_parse_ip()

of_socket_address_t of_socket_address_parse_ip ( OFString IP,
uint16_t  port 
)

Parses the specified IP and port into an of_socket_address_t.

Parameters
IPThe IP to parse
portThe port to use
Returns
The parsed IP and port as an of_socket_address_t

◆ of_socket_address_parse_ipv4()

of_socket_address_t of_socket_address_parse_ipv4 ( OFString IP,
uint16_t  port 
)

Parses the specified IPv4 and port into an of_socket_address_t.

Parameters
IPThe IPv4 to parse
portThe port to use
Returns
The parsed IPv4 and port as an of_socket_address_t

◆ of_socket_address_parse_ipv6()

of_socket_address_t of_socket_address_parse_ipv6 ( OFString IP,
uint16_t  port 
)

Parses the specified IPv6 and port into an of_socket_address_t.

Parameters
IPThe IPv6 to parse
portThe port to use
Returns
The parsed IPv6 and port as an of_socket_address_t

◆ of_socket_address_set_ipx_network()

void of_socket_address_set_ipx_network ( of_socket_address_t *_Nonnull  address,
uint32_t  network 
)

Sets the IPX network of the specified of_socket_address_t.

Parameters
addressThe address on which to set the IPX network
networkThe IPX network to set on the address

◆ of_socket_address_set_ipx_node()

void of_socket_address_set_ipx_node ( of_socket_address_t *_Nonnull  address,
const unsigned char  node[_Nonnull IPX_NODE_LEN] 
)

Sets the IPX node of the specified of_socket_address_t.

Parameters
addressThe address on which to set the IPX node
nodeThe IPX node to set on the address

◆ of_socket_address_set_port()

void of_socket_address_set_port ( of_socket_address_t *_Nonnull  address,
uint16_t  port 
)

Sets the port of the specified of_socket_address_t, independent of the address family used.

Parameters
addressThe address on which to set the port
portThe port to set on the address