iPXE
Functions
socket.c File Reference

Sockets. More...

#include <stddef.h>
#include <errno.h>
#include <ipxe/socket.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
const char * sock_ntoa (struct sockaddr *sa)
 Transcribe socket address. More...
 
int sock_aton (const char *string, struct sockaddr *sa)
 Parse socket address. More...
 

Detailed Description

Sockets.

Definition in file socket.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ sock_ntoa()

const char* sock_ntoa ( struct sockaddr sa)

Transcribe socket address.

Parameters
saSocket address
Return values
stringSocket address string

Definition at line 42 of file socket.c.

42  {
43  struct sockaddr_converter *converter;
44 
46  if ( converter->family == sa->sa_family )
47  return converter->ntoa ( sa );
48  }
49  return NULL;
50 }
struct sockaddr sa
Definition: dns.c:68
sa_family_t sa_family
Socket address family.
Definition: socket.h:101
#define SOCKADDR_CONVERTERS
Socket address converter table.
Definition: socket.h:137
Socket address converter.
Definition: socket.h:115
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
sa_family_t family
Socket address family.
Definition: socket.h:120
const char *(* ntoa)(struct sockaddr *sa)
Transcribe socket address.
Definition: socket.h:126
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References sockaddr_converter::family, for_each_table_entry, sockaddr_converter::ntoa, NULL, sa, sockaddr::sa_family, and SOCKADDR_CONVERTERS.

Referenced by apply_dns_settings(), apply_syslog_settings(), dns_resolved(), ping_callback(), pxe_tftp_open(), tcp_open(), tftp_uri(), and x509_check_ipaddress().

◆ sock_aton()

int sock_aton ( const char *  string,
struct sockaddr sa 
)

Parse socket address.

Parameters
stringSocket address string
saSocket address to fill in
Return values
rcReturn status code

Definition at line 59 of file socket.c.

59  {
60  struct sockaddr_converter *converter;
61 
63  if ( converter->aton ( string, sa ) == 0 ) {
64  sa->sa_family = converter->family;
65  return 0;
66  }
67  }
68  return -EINVAL;
69 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct sockaddr sa
Definition: dns.c:68
sa_family_t sa_family
Socket address family.
Definition: socket.h:101
#define SOCKADDR_CONVERTERS
Socket address converter table.
Definition: socket.h:137
Socket address converter.
Definition: socket.h:115
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
sa_family_t family
Socket address family.
Definition: socket.h:120
int(* aton)(const char *string, struct sockaddr *sa)
Parse socket address.
Definition: socket.h:133

References sockaddr_converter::aton, EINVAL, sockaddr_converter::family, for_each_table_entry, sa, sockaddr::sa_family, and SOCKADDR_CONVERTERS.

Referenced by numeric_resolv(), slam_parse_multicast_address(), and x509_check_ipaddress().