20
20
#include "config.h"
21
21
#include <drizzled/gettext.h>
22
22
#include <drizzled/error.h>
23
#include "drizzled/my_error.h"
23
24
#include <drizzled/query_id.h>
24
25
#include <drizzled/sql_state.h>
25
26
#include <drizzled/session.h>
31
32
#include "errmsg.h"
32
#include "drizzle_protocol.h"
33
#include "oldlibdrizzle.h"
33
34
#include "options.h"
37
using namespace drizzled;
35
39
#define PROTOCOL_VERSION 10
39
41
extern uint32_t global_thread_id;
42
using namespace drizzled;
45
namespace drizzle_protocol
49
43
static const uint32_t DRIZZLE_TCP_PORT= 4427;
50
44
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
581
575
return netStoreData((unsigned char*) buff,
582
(size_t) (internal::int10_to_str(from, buff, -10) - buff));
576
(size_t) (int10_to_str(from, buff, -10) - buff));
585
579
bool ClientDrizzleProtocol::store(uint32_t from)
588
582
return netStoreData((unsigned char*) buff,
589
(size_t) (internal::int10_to_str(from, buff, 10) - buff));
583
(size_t) (int10_to_str(from, buff, 10) - buff));
592
586
bool ClientDrizzleProtocol::store(int64_t from)
595
589
return netStoreData((unsigned char*) buff,
596
(size_t) (internal::int64_t10_to_str(from, buff, -10) - buff));
590
(size_t) (int64_t10_to_str(from, buff, -10) - buff));
599
593
bool ClientDrizzleProtocol::store(uint64_t from)
602
596
return netStoreData((unsigned char*) buff,
603
(size_t) (internal::int64_t10_to_str(from, buff, 10) - buff));
597
(size_t) (int64_t10_to_str(from, buff, 10) - buff));
606
600
bool ClientDrizzleProtocol::store(double from, uint32_t decimals, String *buffer)
642
636
if (drizzleclient_net_peer_addr(&net, ip, &peer_port, NI_MAXHOST))
644
my_error(ER_BAD_HOST_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
638
my_error(ER_BAD_HOST_ERROR, MYF(0), session->security_ctx.ip.c_str());
648
session->getSecurityContext().setIp(ip);
642
session->security_ctx.ip.assign(ip);
650
644
drizzleclient_net_keepalive(&net, true);
700
694
|| (pkt_len= drizzleclient_net_read(&net)) == packet_error
701
695
|| pkt_len < MIN_HANDSHAKE_SIZE)
703
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
697
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
723
717
if (end >= (char*) net.read_pos + pkt_len + 2)
725
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
719
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
753
747
if (passwd + passwd_len + db_len > (char *) net.read_pos + pkt_len)
755
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->getSecurityContext().getIp().c_str());
749
my_error(ER_HANDSHAKE_ERROR, MYF(0), session->security_ctx.ip.c_str());
815
809
static ListenDrizzleProtocol *listen_obj= NULL;
817
static int init(plugin::Context &context)
811
static int init(drizzled::plugin::Registry ®istry)
819
813
listen_obj= new ListenDrizzleProtocol("drizzle_protocol", false);
820
context.add(listen_obj);
814
registry.add(listen_obj);
818
static int deinit(drizzled::plugin::Registry ®istry)
820
registry.remove(listen_obj);
842
843
static DRIZZLE_SYSVAR_STR(bind_address, bind_address, PLUGIN_VAR_READONLY,
843
844
N_("Address to bind to."), NULL, NULL, NULL);
845
static drizzle_sys_var* sys_variables[]= {
846
static drizzle_sys_var* system_variables[]= {
846
847
DRIZZLE_SYSVAR(port),
847
848
DRIZZLE_SYSVAR(connect_timeout),
848
849
DRIZZLE_SYSVAR(read_timeout),
856
} /* namespace drizzle_protocol */
858
DRIZZLE_PLUGIN(drizzle_protocol::init, drizzle_protocol::sys_variables);
857
DRIZZLE_DECLARE_PLUGIN
863
"Drizzle Protocol Module",
865
init, /* Plugin Init */
866
deinit, /* Plugin Deinit */
867
NULL, /* status variables */
868
system_variables, /* system variables */
869
NULL /* config options */
871
DRIZZLE_DECLARE_PLUGIN_END;