libfluid
The ONF OpenFlow driver
BaseOFServer.hh
1 
2 #ifndef __BASEOFSERVER_HH__
3 #define __BASEOFSERVER_HH__
4 
5 #include <pthread.h>
6 #include <string>
7 
8 #include "EventLoop.hh"
9 #include "BaseOFConnection.hh"
10 
11 #include <stdio.h>
12 
13 namespace fluid_base {
14 
20 class BaseOFServer : public BaseOFHandler {
21 public:
35  BaseOFServer(const char* address,
36  const int port,
37  const int nevloops = 1,
38  const bool secure = false);
39  virtual ~BaseOFServer();
40 
48  virtual bool start(bool block = false);
49 
56  virtual void stop();
57 
58  // BaseOFHandler methods
59  virtual void base_connection_callback(BaseOFConnection* conn,
60  BaseOFConnection::Event event_type);
62  void* data,
63  size_t len) { printf("Calling fake msgcb\n"); };
64  virtual void free_data(void* data);
65 
66 private:
67  // TODO: hide part of this in LibEventBaseOFServer
68  char* address;
69  char port[6];
70 
71  EventLoop** eventloops;
72  EventLoop* main;
73  pthread_t* threads;
74  bool blocking;
75  bool secure;
76 
77  int eventloop;
78  int nthreads;
79  int nconn;
80 
81  bool listen(EventLoop* w);
82  EventLoop* choose_eventloop();
83 
84  class LibEventBaseOFServer;
85  friend class LibEventBaseOFServer;
86  LibEventBaseOFServer* m_implementation;
87 };
88 
89 }
90 
91 #endif