Subnet Header

This header contains the C functions needed for Protocol object in the project.

It automatically includes BaseConverter.h

Using this requires a compiled copy of the sha2 hashes, provided in c_src/sha/sha2.c

typedef struct SubnetStruct
char *subnet

The name of the desired subnet

size_t subnetSize

The length of the desired subnet

char *encryption

The desired transport method

size_t encryptionSize

The length of the transport method

char *_id

Private field which contains the hash ID of this network

Use subnetID() to safely obtain this value. It is is allocated and calculated on demand only.

size_t *_id

The length of this network’s hash ID

static SubnetStruct *getSubnet(const char *subnet, size_t subnetSize, const char *encryption, size_t encryptionSize)

Constructs an SubnetStruct. This copies all given data into a struct, then returns this struct’s pointer.


A pointer to the resulting SubnetStruct


You must use destroySubnet() on the resulting object, or you will develop a memory leak

static void destroySubnet(SubnetStruct *des)

free() an SubnetStruct and its members

  • des – A pointer to the SubnetStruct you wish to destroy
static char *subnetID(SubnetStruct *sub)

Ensures that a SubnetStruct has an ID, and returns this ID.

Returns:The given SubnetStruct‘s ID