~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/drizzle_protocol/drizzle_protocol.h

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2010 Brian Aker
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
9
10
 *
10
11
 *  This program is distributed in the hope that it will be useful,
11
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19
 */
19
20
 
 
21
 
20
22
#ifndef PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
21
23
#define PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H
22
24
 
23
25
#include <drizzled/plugin/listen_tcp.h>
24
26
#include <drizzled/plugin/client.h>
25
 
 
26
 
#include "net_serv.h"
27
 
 
 
27
#include <drizzled/atomics.h>
 
28
#include "drizzled/plugin/table_function.h"
 
29
 
 
30
#include "plugin/mysql_protocol/mysql_protocol.h"
 
31
 
 
32
namespace drizzle_plugin
 
33
{
28
34
namespace drizzle_protocol
29
35
{
30
36
 
31
 
class ListenDrizzleProtocol: public drizzled::plugin::ListenTcp
 
37
class ListenDrizzleProtocol: public ListenMySQLProtocol
32
38
{
33
 
private:
34
 
  bool using_mysql41_protocol;
35
 
 
36
39
public:
37
 
  ListenDrizzleProtocol(std::string name_arg, bool using_mysql41_protocol_arg):
38
 
   drizzled::plugin::ListenTcp(name_arg),
39
 
   using_mysql41_protocol(using_mysql41_protocol_arg)
 
40
  ListenDrizzleProtocol(std::string name, 
 
41
                        const std::string &bind_address,
 
42
                        bool using_mysql41_protocol):
 
43
    ListenMySQLProtocol(name, bind_address, using_mysql41_protocol)
40
44
  { }
41
 
  virtual const char* getHost(void) const;
42
 
  virtual in_port_t getPort(void) const;
43
 
  virtual drizzled::plugin::Client *getClient(int fd);
 
45
 
 
46
  ~ListenDrizzleProtocol();
 
47
  in_port_t getPort(void) const;
 
48
  static ProtocolCounters *drizzle_counters;
 
49
  virtual ProtocolCounters *getCounters(void) const { return drizzle_counters; }
 
50
  drizzled::plugin::Client *getClient(int fd);
44
51
};
45
52
 
46
 
class ClientDrizzleProtocol: public drizzled::plugin::Client
 
53
class ClientDrizzleProtocol: public ClientMySQLProtocol
47
54
{
48
 
private:
49
 
  NET net;
50
 
  drizzled::String packet;
51
 
  uint32_t client_capabilities;
52
 
  bool using_mysql41_protocol;
53
 
 
54
 
  bool checkConnection(void);
55
 
  bool netStoreData(const unsigned char *from, size_t length);
56
 
  void writeEOFPacket(uint32_t server_status, uint32_t total_warn_count);
57
 
 
58
55
public:
59
 
  ClientDrizzleProtocol(int fd, bool using_mysql41_protocol_arg);
60
 
  virtual ~ClientDrizzleProtocol();
61
 
 
62
 
  virtual int getFileDescriptor(void);
63
 
  virtual bool isConnected();
64
 
  virtual bool isReading(void);
65
 
  virtual bool isWriting(void);
66
 
  virtual bool flush(void);
67
 
  virtual void close(void);
68
 
 
69
 
  virtual bool authenticate(void);
70
 
  virtual bool readCommand(char **packet, uint32_t *packet_length);
71
 
 
72
 
  virtual void sendOK(void);
73
 
  virtual void sendEOF(void);
74
 
  virtual void sendError(uint32_t sql_errno, const char *err);
75
 
 
76
 
  virtual bool sendFields(drizzled::List<drizzled::Item> *list);
77
 
 
78
 
  using Client::store;
79
 
  virtual bool store(drizzled::Field *from);
80
 
  virtual bool store(void);
81
 
  virtual bool store(int32_t from);
82
 
  virtual bool store(uint32_t from);
83
 
  virtual bool store(int64_t from);
84
 
  virtual bool store(uint64_t from);
85
 
  virtual bool store(double from, uint32_t decimals, drizzled::String *buffer);
86
 
  virtual bool store(const char *from, size_t length);
87
 
 
88
 
  virtual bool haveError(void);
89
 
  virtual bool haveMoreData(void);
90
 
  virtual bool wasAborted(void);
 
56
  ClientDrizzleProtocol(int fd, ProtocolCounters *set_counters): ClientMySQLProtocol(fd, true, set_counters) {}
 
57
 
 
58
  static std::vector<std::string> drizzle_admin_ip_addresses;
 
59
  static void drizzle_compose_ip_addresses(std::vector<std::string> options);
 
60
  bool isAdminAllowed(void);
91
61
};
92
62
 
93
63
} /* namespace drizzle_protocol */
94
 
 
 
64
} /* namespace drizzle_plugin */
 
65
 
95
66
#endif /* PLUGIN_DRIZZLE_PROTOCOL_DRIZZLE_PROTOCOL_H */