static enum proto_parse_status tns_parse_close_statement(struct cursor *cursor) { SLOG(LOG_DEBUG, "Parsing a close statement"); // Subcode DROP_FIX(cursor, 1); // Sequence DROP_FIX(cursor, 1); // Pointer DROP_FIX(cursor, 1); // We seek the next query uint8_t marker[2] = {0x03, 0x5e}; if (cursor_drop_until(cursor, marker, sizeof(marker), cursor->cap_len) < 0) return PROTO_PARSE_ERR; SLOG(LOG_DEBUG, "Found a possible query ttc, exiting close statement"); return PROTO_OK; }
static enum proto_parse_status tns_parse_login_property(struct sql_proto_info *info, struct cursor *cursor) { SLOG(LOG_DEBUG, "Parsing tns login property"); // We are only interested in response if (info->is_query) return PROTO_OK; if (info->msg_type != SQL_UNKNOWN && info->msg_type != SQL_STARTUP) return PROTO_PARSE_ERR; // Drop Server version DROP_FIX(cursor, 3); // Drop Server version text uint8_t marker = 0x00; enum proto_parse_status status = cursor_drop_until(cursor, &marker, sizeof(marker)); if (status != PROTO_OK) return status; // Drop Null byte DROP_FIX(cursor, 1); CHECK(2); uint16_t charset = cursor_read_u16le(cursor); SLOG(LOG_DEBUG, "Found a charset of 0x%02x", charset); switch (charset) { case 0x01: case 0x02: case 0x1f: case 0xb2: sql_set_encoding(info, SQL_ENCODING_LATIN1); break; case 0x366: case 0x367: case 0x369: sql_set_encoding(info, SQL_ENCODING_UTF8); break; default: SLOG(LOG_DEBUG, "Unknown charset"); break; } // We don't care of the rest... cursor_drop(cursor, cursor->cap_len); return PROTO_OK; }