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.
int sock_aton (const char *string, struct sockaddr *sa)
 Parse socket address.

Detailed Description

Sockets.

Definition in file socket.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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.

References sockaddr_converter::family, for_each_table_entry, sockaddr_converter::ntoa, NULL, 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().

                                               {
        struct sockaddr_converter *converter;

        for_each_table_entry ( converter, SOCKADDR_CONVERTERS ) {
                if ( converter->family == sa->sa_family )
                        return converter->ntoa ( sa );
        }
        return NULL;
}
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.

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

Referenced by numeric_resolv(), and x509_check_ipaddress().

                                                          {
        struct sockaddr_converter *converter;

        for_each_table_entry ( converter, SOCKADDR_CONVERTERS ) {
                if ( converter->aton ( string, sa ) == 0 ) {
                        sa->sa_family = converter->family;
                        return 0;
                }
        }
        return -EINVAL;
}