cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBObject/CBMessage/CBNetworkAddress/CBNetworkAddress.h
Go to the documentation of this file.
00001 //
00002 //  CBNetworkAddress.h
00003 //  cbitcoin
00004 //
00005 //  Created by Matthew Mitchell on 02/07/2012.
00006 //  Copyright (c) 2012 Matthew Mitchell
00007 //  
00008 //  This file is part of cbitcoin.
00009 //
00010 //  cbitcoin is free software: you can redistribute it and/or modify
00011 //  it under the terms of the GNU General Public License as published by
00012 //  the Free Software Foundation, either version 3 of the License, or
00013 //  (at your option) any later version.
00014 //  
00015 //  cbitcoin is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //  
00020 //  You should have received a copy of the GNU General Public License
00021 //  along with cbitcoin.  If not, see <http://www.gnu.org/licenses/>.
00022 
00028 #ifndef CBNETWORKADDRESSH
00029 #define CBNETWORKADDRESSH
00030 
00031 //  Includes
00032 
00033 #include "CBMessage.h"
00034 #include "CBDependencies.h"
00035 #include "CBNetworkFunctions.h"
00036 
00040 typedef struct{
00041         CBMessage base; 
00042         uint32_t score; 
00043         CBVersionServices services; 
00044         CBByteArray * ip; 
00045         CBIPType type; 
00046         uint16_t port; 
00047         int32_t version; 
00048         bool public; 
00049 } CBNetworkAddress;
00050 
00056 CBNetworkAddress * CBNewNetworkAddress(uint32_t score,CBByteArray * ip,uint16_t port,CBVersionServices services,void (*onErrorReceived)(CBError error,char *,...));
00061 CBNetworkAddress * CBNewNetworkAddressFromData(CBByteArray * data,void (*onErrorReceived)(CBError error,char *,...));
00062 
00068 CBNetworkAddress * CBGetNetworkAddress(void * self);
00069 
00075 bool CBInitNetworkAddress(CBNetworkAddress * self,uint32_t score,CBByteArray * ip,uint16_t port,CBVersionServices services,void (*onErrorReceived)(CBError error,char *,...));
00081 bool CBInitNetworkAddressFromData(CBNetworkAddress * self,CBByteArray * data,void (*onErrorReceived)(CBError error,char *,...));
00082 
00087 void CBFreeNetworkAddress(void * self);
00088  
00089 //  Functions
00090 
00097 uint8_t CBNetworkAddressDeserialise(CBNetworkAddress * self,bool score);
00104 bool CBNetworkAddressEquals(CBNetworkAddress * self,CBNetworkAddress * addr);
00111 uint8_t CBNetworkAddressSerialise(CBNetworkAddress * self,bool score);
00112 
00113 #endif