@@ -97,17 +97,17 @@ typedef struct
9797 tlv_array_t * tlv_array ;
9898} pp_info_t ;
9999
100- /* Returns a descriptive error message.
100+ /* Returns a descriptive error message
101101 *
102- * error int32_t value from other API functions.
103- * return Pointer to the descriptive message if error value is recognized else NULL.
102+ * error int32_t value from other API functions
103+ * return Pointer to the descriptive message if error value is recognized else NULL
104104 */
105105const char * pp_strerror (int32_t error );
106106
107- /* Searches for the specified TLV and returns its value.
107+ /* Searches for the specified TLV and returns its value
108108 *
109- * pp_info Pointer to a pp_info_t structure used in pp_parse().
110- * length Pointer to a uint16_t where the TLV's value length will be set.
109+ * pp_info Pointer to a pp_info_t structure used in pp_parse()
110+ * length Pointer to a uint16_t where the TLV's value length will be set
111111 * return Pointer to a buffer holding the TLV's value if found else NULL.
112112 * In case of US-ASCII value the buffer is NULL terminated
113113 */
@@ -123,28 +123,34 @@ const uint8_t *pp_info_get_ssl_key_alg(const pp_info_t *pp_info, uint16_t *lengt
123123const uint8_t * pp_info_get_ssl_netns (const pp_info_t * pp_info , uint16_t * length );
124124const uint8_t * pp_info_get_aws_vpce_id (const pp_info_t * pp_info , uint16_t * length );
125125const uint8_t * pp_info_get_azure_linkid (const pp_info_t * pp_info , uint16_t * length );
126- void pp_info_clear (pp_info_t * pp_info );
127126
128- /* Inpects the buffer for a PROXY protocol header and extracts all the information if any.
127+ /* Clears the pp_info_t structure and frees any allocated memory associated with it. Shall always be called after a call to pp_parse_hdr()
128+ *
129+ * pp_info Pointer to a filled pp_info_t structure which has been used to a previous call to pp_parse_hdr()
130+ */
131+ void pp_info_clear (pp_info_t * pp_info );
132+
133+ /* Creates a PROXY protocol header considering the information inside the pp_info.
129134 *
130135 * version: 0 Create a v1 PROXY protocol header
131136 * 1 Create a v2 PROXY protocol header
132- * pp_info Pointer to a filled pp_info_t structure whose information will be used for the creation of the PROXY protocol header.
133- * pp_hdr_len Pointer to a uint16_t where the length of the create PROXY protocol header will be set.
134- * error Pointer to a uint32_t where the error value will be set.
137+ * pp_info Pointer to a filled pp_info_t structure whose information will be used for the creation of the PROXY protocol header
138+ * pp_hdr_len Pointer to a uint16_t where the length of the create PROXY protocol header will be set
139+ * error Pointer to a uint32_t where the error value will be set
135140 * ERR_NULL No error occurred
136141 * < 0 Error
142+ * return Pointer to a heap allocated buffer containing the PROXY protocol header. Must be freed with free()
137143 */
138- uint8_t * pp_create_hdr (uint8_t version , const pp_info_t * pp_info , uint16_t * pp_hdr_len , uint32_t * error );
144+ uint8_t * pp_create_hdr (uint8_t version , const pp_info_t * pp_info , uint16_t * pp_hdr_len , int32_t * error );
139145
140- /* Inpects the buffer for a PROXY protocol header and extracts all the information if any.
146+ /* Inpects the buffer for a PROXY protocol header and extracts all the information if any
141147 *
142- * buffer Buffer to be inspected and parsed. Typically the buffer given for a read operation
143- * length Buffer's length. Typically the bytes read from the read operation
144- * pp_info Pointer to a pp_info_t structure which will get filled with all the extracted information.
145- * return > 0 Length of the PROXY protocol header.
146- * == 0 No PROXY protocol header found.
147- * < 0 Error occurred. pp_strerror() with that value can be used to get a descriptive message
148+ * buffer Buffer to be inspected and parsed. Typically the buffer given for a read operation
149+ * buffer_length Buffer's length. Typically the bytes read from the read operation
150+ * pp_info Pointer to a pp_info_t structure which will get filled with all the extracted information
151+ * return > 0 Length of the PROXY protocol header
152+ * == 0 No PROXY protocol header found
153+ * < 0 Error occurred. pp_strerror() with that value can be used to get a descriptive message
148154 */
149155int32_t pp_parse_hdr (uint8_t * buffer , uint32_t buffer_length , pp_info_t * pp_info );
150156
0 commit comments