Skip to content

Commit

Permalink
Split of MySQL_Protocol.cpp into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Apr 21, 2024
1 parent e7aa5ff commit dad6f0f
Show file tree
Hide file tree
Showing 7 changed files with 840 additions and 760 deletions.
25 changes: 25 additions & 0 deletions include/MySQL_Prepared_Stmt_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef CLASS_MySQL_Prepared_Stmt_info_H
#define CLASS_MySQL_Prepared_Stmt_info_H
class MySQL_Prepared_Stmt_info {
public:
uint32_t statement_id;
uint16_t num_columns;
uint16_t num_params;
uint16_t warning_count;
uint16_t pending_num_columns;
uint16_t pending_num_params;
MySQL_Prepared_Stmt_info(unsigned char *pkt, unsigned int length) {
pkt += 5;
statement_id = CPY4(pkt);
pkt += sizeof(uint32_t);
num_columns = CPY2(pkt);
pkt += sizeof(uint16_t);
num_params = CPY2(pkt);
pkt += sizeof(uint16_t);
pkt++; // reserved_1
warning_count = CPY2(pkt);
pending_num_columns=num_columns;
pending_num_params=num_params;
}
};
#endif // CLASS_MySQL_Prepared_Stmt_info_H
11 changes: 1 addition & 10 deletions include/MySQL_Protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "proxysql.h"
#include "cpp.h"
#include "MySQL_Variables.h"
#include "MySQL_Prepared_Stmt_info.h"

#define RESULTSET_BUFLEN 16300

Expand Down Expand Up @@ -70,16 +71,6 @@ class MySQL_ResultSet {
unsigned long long current_size();
};

class MySQL_Prepared_Stmt_info {
public:
uint32_t statement_id;
uint16_t num_columns;
uint16_t num_params;
uint16_t warning_count;
uint16_t pending_num_columns;
uint16_t pending_num_params;
MySQL_Prepared_Stmt_info(unsigned char *, unsigned int);
};

uint8_t mysql_decode_length(unsigned char *ptr, uint64_t *len);

Expand Down
22 changes: 22 additions & 0 deletions include/MySQL_encode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CLASS_MySQL_encode_H
#define CLASS_MySQL_encode_H
#ifdef DEBUG
void __dump_pkt(const char *func, unsigned char *_ptr, unsigned int len);
#endif // DEBUG
char *sha1_pass_hex(char *sha1_pass);
double proxy_my_rnd(struct rand_struct *rand_st);
void proxy_create_random_string(char *_to, uint length, struct rand_struct *rand_st);
int write_encoded_length(unsigned char *p, uint64_t val, uint8_t len, char prefix);
int write_encoded_length_and_string(unsigned char *p, uint64_t val, uint8_t len, char prefix, char *string);
void proxy_compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1, const char *buf2, int len2);
void proxy_compute_sha1_hash(uint8_t *digest, const char *buf, int len);
void proxy_compute_two_stage_sha1_hash(const char *password, size_t pass_len, uint8_t *hash_stage1, uint8_t *hash_stage2);
void proxy_my_crypt(char *to, const uint8_t *s1, const uint8_t *s2, uint len);
unsigned char decode_char(char x);
void unhex_pass(uint8_t *out, const char *in);
void proxy_scramble(char *to, const char *message, const char *password);
bool proxy_scramble_sha1(char *pass_reply, const char *message, const char *sha1_sha1_pass, char *sha1_pass);
unsigned int CPY3(unsigned char *ptr);
uint64_t CPY8(unsigned char *ptr);
uint8_t mysql_encode_length(uint64_t len, char *hd);
#endif // CLASS_MySQL_encode_H
1 change: 1 addition & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ _OBJ_CXX := ProxySQL_GloVars.oo network.oo debug.oo configfile.oo Query_Cache.oo
sha256crypt.oo \
QP_rule_text.oo QP_query_digest_stats.oo \
GTID_Server_Data.oo MyHGC.oo MySrvConnList.oo MySrvList.oo MySrvC.oo \
MySQL_encode.oo MySQL_ResultSet.oo \
proxysql_find_charset.oo ProxySQL_Poll.oo
OBJ_CXX := $(patsubst %,$(ODIR)/%,$(_OBJ_CXX))
HEADERS := ../include/*.h ../include/*.hpp
Expand Down
Loading

0 comments on commit dad6f0f

Please sign in to comment.