cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBObject/CBMessage/CBNetworkAddress/CBNetworkAddress.h File Reference

Contains IP, time, port and services information for a peer as well as data and code for managing individual peers. Used to advertise peers. "bytesTransferred/timeUsed" can be used to rank peers for the most efficient ones which can be useful when selecting prefered peers for download. Inherits CBObject. More...

#include "CBMessage.h"
#include "CBDependencies.h"
#include "CBNetworkFunctions.h"

Go to the source code of this file.

Data Structures

struct  CBNetworkAddress
 Structure for CBNetworkAddress objects. More...

Functions

CBNetworkAddressCBNewNetworkAddress (uint32_t score, CBByteArray *ip, uint16_t port, CBVersionServices services, void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBNetworkAddress object.
CBNetworkAddressCBNewNetworkAddressFromData (CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBNetworkAddress object from serialised data.
CBNetworkAddressCBGetNetworkAddress (void *self)
 Gets a CBNetworkAddress from another object. Use this to avoid casts.
bool CBInitNetworkAddress (CBNetworkAddress *self, uint32_t score, CBByteArray *ip, uint16_t port, CBVersionServices services, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBNetworkAddress object.
bool CBInitNetworkAddressFromData (CBNetworkAddress *self, CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBNetworkAddress object from serialised data.
void CBFreeNetworkAddress (void *self)
 Frees a CBNetworkAddress object.
uint8_t CBNetworkAddressDeserialise (CBNetworkAddress *self, bool score)
 Deserialises a CBNetworkAddress so that it can be used as an object.
bool CBNetworkAddressEquals (CBNetworkAddress *self, CBNetworkAddress *addr)
 Compares two network addresses.
uint8_t CBNetworkAddressSerialise (CBNetworkAddress *self, bool score)
 Serialises a CBNetworkAddress to the byte data.

Detailed Description

Contains IP, time, port and services information for a peer as well as data and code for managing individual peers. Used to advertise peers. "bytesTransferred/timeUsed" can be used to rank peers for the most efficient ones which can be useful when selecting prefered peers for download. Inherits CBObject.


Function Documentation

void CBFreeNetworkAddress ( void *  self)

Frees a CBNetworkAddress object.

Parameters:
selfThe CBNetworkAddress object to free.

Gets a CBNetworkAddress from another object. Use this to avoid casts.

Parameters:
selfThe object to obtain the CBNetworkAddress from.
Returns:
The CBNetworkAddress object.
bool CBInitNetworkAddress ( CBNetworkAddress self,
uint32_t  score,
CBByteArray ip,
uint16_t  port,
CBVersionServices  services,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBNetworkAddress object.

Parameters:
selfThe CBNetworkAddress object to initialise
Returns:
true on success, false on failure.
bool CBInitNetworkAddressFromData ( CBNetworkAddress self,
CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBNetworkAddress object from serialised data.

Parameters:
selfThe CBNetworkAddress object to initialise
Returns:
true on success, false on failure.
uint8_t CBNetworkAddressDeserialise ( CBNetworkAddress self,
bool  score 
)

Deserialises a CBNetworkAddress so that it can be used as an object.

Parameters:
selfThe CBNetworkAddress object
timeIf true a timestamp is expected, else it is not. If a timestamp is not expected then "time" will not be set and will be the previous value.
Returns:
The length read on success, 0 on failure.

Compares two network addresses.

Parameters:
selfThe CBNetworkAddress object
addrThe CBNetworkAddress for comparison
Returns:
true if the IP and port match and the IP is not NULL. False otherwise.
uint8_t CBNetworkAddressSerialise ( CBNetworkAddress self,
bool  score 
)

Serialises a CBNetworkAddress to the byte data.

Parameters:
selfThe CBNetworkAddress object
timeIf true the time will be included, else it will not.
Returns:
The length written on success, 0 on failure.
CBNetworkAddress* CBNewNetworkAddress ( uint32_t  score,
CBByteArray ip,
uint16_t  port,
CBVersionServices  services,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Creates a new CBNetworkAddress object.

Parameters:
ipThe IP address in a 16 byte IPv6 format. If NULL, the IP will be a 16 byte CBByteArray set will all zero.
Returns:
A new CBNetworkAddress object.
CBNetworkAddress* CBNewNetworkAddressFromData ( CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Creates a new CBNetworkAddress object from serialised data.

Returns:
A new CBNetworkAddress object.