renamed struct maddr to MultiAddress

This commit is contained in:
John Jones 2017-02-13 13:30:22 -05:00
parent d57e026fbf
commit 78ce39b067
3 changed files with 15 additions and 15 deletions

View file

@ -7,7 +7,7 @@
#include "protocols.h" #include "protocols.h"
#include "protoutils.h" #include "protoutils.h"
struct maddr struct MultiAddress
{ {
char string[800]; char string[800];
uint8_t bytes[400]; uint8_t bytes[400];
@ -17,14 +17,14 @@ struct maddr
int strpos(char *haystack, char *needle); int strpos(char *haystack, char *needle);
struct maddr* new_maddr_fb(uint8_t * byteaddress,int size); //Construct new address from bytes struct MultiAddress* new_maddr_fb(uint8_t * byteaddress,int size); //Construct new address from bytes
struct maddr* new_maddr_fs(char * straddress); //Construct new address from string struct MultiAddress* new_maddr_fs(char * straddress); //Construct new address from string
void maddr_free(struct maddr* in); void maddr_free(struct MultiAddress* in);
int m_encapsulate(struct maddr * result, char * string); int m_encapsulate(struct MultiAddress * result, char * string);
int m_decapsulate(struct maddr * result, char * srci); int m_decapsulate(struct MultiAddress * result, char * srci);
#endif #endif

View file

@ -18,9 +18,9 @@ int strpos(char *haystack, char *needle)
} }
} }
struct maddr* new_maddr_fb(uint8_t* byteaddress,int size)//Construct new address from bytes struct MultiAddress* new_maddr_fb(uint8_t* byteaddress,int size)//Construct new address from bytes
{ {
struct maddr* anewaddr2 = (struct maddr*)malloc(sizeof(struct maddr)); struct MultiAddress* anewaddr2 = (struct MultiAddress*)malloc(sizeof(struct MultiAddress));
if (anewaddr2 != NULL) { if (anewaddr2 != NULL) {
if(byteaddress!=NULL) if(byteaddress!=NULL)
{ {
@ -33,9 +33,9 @@ struct maddr* new_maddr_fb(uint8_t* byteaddress,int size)//Construct new address
} }
return anewaddr2; return anewaddr2;
} }
struct maddr* new_maddr_fs(char * straddress)//Construct new address from string struct MultiAddress* new_maddr_fs(char * straddress)//Construct new address from string
{ {
struct maddr* anewaddr = (struct maddr*)malloc(sizeof(struct maddr)); struct MultiAddress* anewaddr = (struct MultiAddress*)malloc(sizeof(struct MultiAddress));
if (anewaddr != NULL) { if (anewaddr != NULL) {
bzero(anewaddr->string, 800); bzero(anewaddr->string, 800);
strcpy(anewaddr->string, straddress); strcpy(anewaddr->string, straddress);
@ -54,11 +54,11 @@ struct maddr* new_maddr_fs(char * straddress)//Construct new address from string
return anewaddr; return anewaddr;
} }
void maddr_free(struct maddr* in) { void maddr_free(struct MultiAddress* in) {
free(in); free(in);
} }
int m_encapsulate(struct maddr * result, char * string) int m_encapsulate(struct MultiAddress * result, char * string)
{ {
if(result!=NULL&&string!=NULL) if(result!=NULL&&string!=NULL)
{ {
@ -82,7 +82,7 @@ int m_encapsulate(struct maddr * result, char * string)
return 0; return 0;
} }
} }
int m_decapsulate(struct maddr * result, char * srci) int m_decapsulate(struct MultiAddress * result, char * srci)
{ {
if(result!=NULL && srci!=NULL) if(result!=NULL && srci!=NULL)
{ {

View file

@ -7,7 +7,7 @@ int main()
bzero(addrstr,100); bzero(addrstr,100);
strcat(addrstr,"/ip4/192.168.1.1/tcp/8080/"); strcat(addrstr,"/ip4/192.168.1.1/tcp/8080/");
printf("INITIAL: %s\n",addrstr); printf("INITIAL: %s\n",addrstr);
struct maddr* a; struct MultiAddress* a;
a=new_maddr_fs(addrstr); a=new_maddr_fs(addrstr);
printf("TEST BYTES: %s\n",Var_To_Hex(a->bsize[0], a->bytes)); printf("TEST BYTES: %s\n",Var_To_Hex(a->bsize[0], a->bytes));
@ -23,7 +23,7 @@ int main()
m_encapsulate(a,"/tcp/8080"); m_encapsulate(a,"/tcp/8080");
printf("A STRING ENCAPSULATED TCP:%s\n",a->string); printf("A STRING ENCAPSULATED TCP:%s\n",a->string);
struct maddr* beta; struct MultiAddress* beta;
beta=new_maddr_fb(a->bytes,a->bsize[0]); beta=new_maddr_fb(a->bytes,a->bsize[0]);
printf("B STRING: %s\n",beta->string); printf("B STRING: %s\n",beta->string);