BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
|
#include "ip.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <resolv.h>
#include "utils.h"
Go to the source code of this file.
Functions | |
void | get_local_ip_address (char *ip_addr) |
Get the local IP address of the machine (e.g. | |
void | get_remote_ip_address (char *ip_addr) |
Get the remote IP address of the machine (e.g. | |
int | lookup_address (const char *lookup_addr, char *ip_addr) |
Perform lookup of given IP address by the domain address (e.g. | |
int | is_in_private_network (const char *ip_addr) |
Check if the IP address is in the private prefix (e.g. | |
int | is_numeric_address (const char *ip_addr) |
Check if the IP address is a numeric address (e.g. | |
int | is_valid_domain_address (const char *domain_addr) |
Check if the IP address is a valid domain address (e.g. | |
void get_local_ip_address | ( | char * | ip_addr | ) |
Get the local IP address of the machine (e.g.
192.168.1.10).
ip_addr | The buffer to store the IP address. |
Definition at line 11 of file ip.c.
References BUFFER_SIZE, pclose(), and popen().
Referenced by cli_whoami().
void get_remote_ip_address | ( | char * | ip_addr | ) |
Get the remote IP address of the machine (e.g.
1.1.1.1).
ip_addr | The buffer to store the IP address. |
Definition at line 33 of file ip.c.
References BUFFER_SIZE, pclose(), and popen().
Referenced by cli_get_ip(), and cli_whoami().
int is_in_private_network | ( | const char * | ip_addr | ) |
Check if the IP address is in the private prefix (e.g.
192.168.1.10 is, 1.1.1.1 is not).
ip_addr | The IP address to check. |
Definition at line 98 of file ip.c.
References BITLAB_LOG, BUFFER_SIZE, is_in_private_network(), is_numeric_address(), log_message(), LOG_WARN, and lookup_address().
Referenced by is_in_private_network(), and send_getaddr_and_wait().
int is_numeric_address | ( | const char * | ip_addr | ) |
Check if the IP address is a numeric address (e.g.
1.1.1.1 is, example.com is not).
ip_addr | The IP address to check. |
Definition at line 119 of file ip.c.
Referenced by cli_connect(), is_in_private_network(), and is_valid_domain_address().
int is_valid_domain_address | ( | const char * | domain_addr | ) |
Check if the IP address is a valid domain address (e.g.
example.com is, example or 1.1.1.1 is not).
domain_addr | The domain address to check. |
Definition at line 136 of file ip.c.
References BITLAB_LOG, BUFFER_SIZE, is_numeric_address(), log_message(), LOG_WARN, and lookup_address().
Referenced by cli_get_ip().
int lookup_address | ( | const char * | lookup_addr, |
char * | ip_addr | ||
) |
Perform lookup of given IP address by the domain address (e.g.
google.com).
lookup_addr | The current address to lookup. |
ip_addr | The buffer to store the IP address. |
Definition at line 55 of file ip.c.
References addrinfo::ai_addr, addrinfo::ai_family, addrinfo::ai_next, addrinfo::ai_socktype, BITLAB_LOG, freeaddrinfo(), gai_strerror(), getaddrinfo(), log_message(), LOG_WARN, and MAX_IP_ADDR_LEN.
Referenced by cli_get_ip(), handle_peer_discovery(), is_in_private_network(), and is_valid_domain_address().