Subnet Header ============= This header contains the C functions needed for Protocol object in the p2p.today project. It automatically includes :doc:`BaseConverter.h <./BaseConverter>` Using this requires a compiled copy of the sha2 hashes, provided in ``c_src/sha/sha2.c`` .. c:type:: typedef struct SubnetStruct .. c:member:: char *subnet The name of the desired subnet .. c:member:: size_t subnetSize The length of the desired subnet .. c:member:: char *encryption The desired transport method .. c:member:: size_t encryptionSize The length of the transport method .. c:member:: char *_id Private field which contains the hash ID of this network Use :c:func:`subnetID` to safely obtain this value. It is is allocated and calculated on demand only. .. c:member:: size_t *_id The length of this network's hash ID .. c:function:: 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. :param subnet: The item to place in :c:member:`SubnetStruct.subnet` :param subnetSize: The length of the above :param encryption: The item to place in :c:member:`SubnetStruct.encryption` :param encryptionSize: The length of the above :returns: A pointer to the resulting :c:type:`SubnetStruct` .. warning:: You must use :c:func:`destroySubnet` on the resulting object, or you will develop a memory leak .. c:function:: static void destroySubnet(SubnetStruct *des) :c:func:`free` an :c:type:`SubnetStruct` and its members :param des: A pointer to the SubnetStruct you wish to destroy .. c:function:: static char *subnetID(SubnetStruct *sub) Ensures that a :c:type:`SubnetStruct` has an ID, and returns this ID. :returns: The given :c:type:`SubnetStruct`'s ID