|
|
|
|
@ -433,6 +433,16 @@ bool PgSQL_Protocol::generate_pkt_initial_handshake(bool send, void** _ptr, unsi
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief Reads and converts a big endian 32-bit unsigned integer from the provided packet buffer into the destination pointer.
|
|
|
|
|
*
|
|
|
|
|
* This function is used to extract the big endian 32-bit unsigned integer value at the specified position in a given
|
|
|
|
|
* packet buffer, and stores it in the destination pointer passed as an argument.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] pkt A pointer to the start of the input packet buffer from which to read the 32-bit integer.
|
|
|
|
|
*
|
|
|
|
|
* @param[out] dst_p A pointer where the extracted big endian 32-bit unsigned integer value will be stored.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool get_uint32be(unsigned char* pkt, uint32_t* dst_p)
|
|
|
|
|
{
|
|
|
|
|
int read_pos = 0;
|
|
|
|
|
@ -447,13 +457,31 @@ static inline bool get_uint32be(unsigned char* pkt, uint32_t* dst_p)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Extracts a 16-bit unsigned integer from a packet and stores it in the provided destination pointer.
|
|
|
|
|
*
|
|
|
|
|
* This function reads two bytes from the packet `pkt` starting from the beginning, interprets them as a big-endian unsigned 16-bit integer,
|
|
|
|
|
* and stores the result into the memory location pointed to by `dst_p`. It consistently returns true to indicate successful execution.
|
|
|
|
|
*
|
|
|
|
|
* @param pkt Pointer to the packet data (array of unsigned chars) from which the 16-bit integer will be extracted.
|
|
|
|
|
* The caller must ensure this pointer is valid and points to at least two bytes of data.
|
|
|
|
|
* @param dst_p Pointer to a uint16_t variable where the extracted integer will be stored. The caller must ensure that
|
|
|
|
|
* this pointer is valid and points to a uint16_t variable.
|
|
|
|
|
*
|
|
|
|
|
* @return Always returns true to indicate success.
|
|
|
|
|
*
|
|
|
|
|
* @note This function uses big-endian byte order (network byte order) for interpreting the packet data.
|
|
|
|
|
* It is assumed that the packet buffer `pkt` contains at least two bytes (the size of a uint16_t).
|
|
|
|
|
* The function uses post-increment to move the reading position after extracting each byte.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool get_uint16be(unsigned char* pkt, uint16_t* dst_p)
|
|
|
|
|
{
|
|
|
|
|
int read_pos = 0;
|
|
|
|
|
int read_pos = 0; ///< Current read position in the buffer.
|
|
|
|
|
unsigned a, b;
|
|
|
|
|
|
|
|
|
|
a = pkt[read_pos++];
|
|
|
|
|
b = pkt[read_pos++];
|
|
|
|
|
// Read the two bytes from the buffer
|
|
|
|
|
a = pkt[read_pos++]; ///< First byte read from the buffer.
|
|
|
|
|
b = pkt[read_pos++]; ///< Second byte read from the buffer.
|
|
|
|
|
*dst_p = (a << 8) | b;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@ -1187,4 +1215,4 @@ bool PgSQL_Protocol::generate_ok_packet(bool send, bool ready, const char* msg,
|
|
|
|
|
|
|
|
|
|
free(tag);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|