Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
renecannao committed Aug 10, 2021
1 parent c17d65b commit 22f2204
Showing 1 changed file with 0 additions and 95 deletions.
95 changes: 0 additions & 95 deletions lib/MySQL_Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,101 +260,6 @@ static uint8_t mysql_encode_length(uint64_t len, char *hd) {
return 9;
}


enum MySQL_response_type mysql_response(unsigned char *pkt, unsigned int length) {
unsigned char c=*pkt;
switch (c) {
case 0:
// proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet OK_Packet\n");
return OK_Packet;
case 0xff:
// proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet ERR_Packet\n");
return ERR_Packet;
case 0xfe:
if (length < 9) {
//proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet EOF_Packet\n");
return EOF_Packet;
}
default:
//proxy_debug(PROXY_DEBUG_MYSQL_COM, 6, "Packet UNKNOWN_Packet\n");
return UNKNOWN_Packet;
}
}

int pkt_com_query(unsigned char *pkt, unsigned int length) {
unsigned char buf[length];
memcpy(buf,pkt+1, length-1);
buf[length-1]='\0';
proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"Query: %s\n", buf);
return PKT_PARSED;
}

int pkt_ok(unsigned char *pkt, unsigned int length, MySQL_Protocol *mp) {
if (length < 7) return PKT_ERROR;

uint64_t affected_rows;
uint64_t insert_id;
#ifdef DEBUG
uint16_t warns;
#endif /* DEBUG */
unsigned char msg[length];

unsigned int p=0;
int rc;

pkt++; p++;
rc=mysql_decode_length(pkt,&affected_rows);
pkt += rc; p+=rc;
rc=mysql_decode_length(pkt,&insert_id);
pkt += rc; p+=rc;
mp->prot_status=CPY2(pkt);
pkt+=sizeof(uint16_t);
p+=sizeof(uint16_t);
#ifdef DEBUG
warns=CPY2(pkt);
#endif /* DEBUG */
pkt+=sizeof(uint16_t);
p+=sizeof(uint16_t);
pkt++;
p++;
if (length>p) {
memcpy(msg,pkt,length-p);
msg[length-p]=0;
} else {
msg[0]=0;
}

proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"OK Packet <affected_rows:%u insert_id:%u status:%u warns:%u msg:%s>\n", (uint32_t)affected_rows, (uint32_t)insert_id, (uint16_t)mp->prot_status, (uint16_t)warns, msg);

return PKT_PARSED;
}



int pkt_end(unsigned char *pkt, unsigned int length, MySQL_Protocol *mp)
{
if(*pkt != 0xFE || length > 5) return PKT_ERROR;
#ifdef DEBUG
uint16_t warns = 0;
#endif /* DEBUG */

if(length > 1) { // 4.1+
pkt++;
#ifdef DEBUG
warns = CPY2(pkt);
#endif /* DEBUG */
pkt += 2;
mp->prot_status = CPY2(pkt);
}
proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"End Packet <status:%u warns:%u>\n", mp->prot_status, warns);

// if(status & SERVER_MORE_RESULTS_EXISTS) {
// proxy_debug(PROXY_DEBUG_MYSQL_PROTOCOL,1,"End Packet <status:%u warns:%u>\n");
// }

return PKT_PARSED;
}

#ifdef DEBUG
void debug_spiffe_id(const unsigned char *user, const char *attributes, int __line, const char *__func) {
if (strlen(attributes)) {
Expand Down

0 comments on commit 22f2204

Please sign in to comment.