Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
crofdpt.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef CROFDPT_H
6 #define CROFDPT_H 1
7 
8 #include <map>
9 #include <set>
10 #include <algorithm>
11 #include <inttypes.h>
12 #include <stdio.h>
13 #include <strings.h>
14 #include <bitset>
15 
16 #include "rofl/common/ciosrv.h"
17 #include "rofl/common/cmemory.h"
18 #include "rofl/common/logging.h"
19 #include "rofl/common/crofchan.h"
20 #include "rofl/common/ctransactions.h"
21 #include "rofl/common/croflexception.h"
22 #include "rofl/common/csocket.h"
23 #include "rofl/common/cmemory.h"
24 #include "rofl/common/cdptid.h"
25 #include "rofl/common/cauxid.h"
26 #include "rofl/common/cdpid.h"
27 #include "rofl/common/crofqueue.h"
28 
29 #include "rofl/common/openflow/cofports.h"
30 #include "rofl/common/openflow/coftables.h"
31 #include "rofl/common/openflow/openflow.h"
32 #include "rofl/common/openflow/messages/cofmsg.h"
33 #include "rofl/common/openflow/cofflowmod.h"
34 #include "rofl/common/openflow/cofgroupmod.h"
35 #include "rofl/common/openflow/cofhelloelemversionbitmap.h"
36 #include "rofl/common/openflow/cofasyncconfig.h"
37 #include "rofl/common/openflow/cofrole.h"
38 #include "rofl/common/openflow/cofmeterstats.h"
39 #include "rofl/common/openflow/cofmeterconfig.h"
40 #include "rofl/common/openflow/cofmeterfeatures.h"
41 #include "rofl/common/openflow/cofpacketqueue.h"
42 #include "rofl/common/openflow/cofmeterbands.h"
43 
44 namespace rofl {
45 
46 /* error classes */
47 class eRofDptBase : public RoflException {
48 public:
49  eRofDptBase(const std::string& __arg) : RoflException(__arg) {};
50 };
51 class eRofDptNotFound : public eRofDptBase {
52 public:
53  eRofDptNotFound(const std::string& __arg) : eRofDptBase(__arg) {};
54 };
55 
56 class crofdpt;
57 
75 class crofdpt_env {
76  friend class crofdpt;
77  static std::set<crofdpt_env*> rofdpt_envs;
78 public:
79 
84  { crofdpt_env::rofdpt_envs.insert(this); };
85 
89  virtual
91  { crofdpt_env::rofdpt_envs.erase(this); };
92 
93 protected:
94 
109  virtual void
111  rofl::crofdpt& dpt)
112  {};
113 
123  virtual void
125  rofl::crofdpt& dpt)
126  {};
127 
134  virtual void
136  rofl::crofdpt& dpt,
137  const rofl::cauxid& auxid)
138  {};
139 
146  virtual void
148  rofl::crofdpt& dpt,
149  const rofl::cauxid& auxid)
150  {};
151 
162  virtual void
164  rofl::crofdpt& dpt,
165  const rofl::cauxid& auxid)
166  {};
167 
178  virtual void
180  rofl::crofdpt& dpt,
181  const rofl::cauxid& auxid)
182  {};
183 
200  virtual void
202  rofl::crofdpt& dpt,
203  const rofl::cauxid& auxid)
204  {};
205 
208 protected:
209 
229  virtual void
231  rofl::crofdpt& dpt,
232  const rofl::cauxid& auxid,
234  {};
235 
245  virtual void
247  rofl::crofdpt& dpt,
248  uint32_t xid)
249  {};
250 
258  virtual void
260  rofl::crofdpt& dpt,
261  const rofl::cauxid& auxid,
263  {};
264 
274  virtual void
276  rofl::crofdpt& dpt,
277  uint32_t xid)
278  {};
279 
287  virtual void
289  rofl::crofdpt& dpt,
290  const rofl::cauxid& auxid,
292  {};
293 
304  virtual void
306  rofl::crofdpt& dpt,
307  uint32_t xid,
308  uint8_t stats_type)
309  {};
310 
318  virtual void
320  rofl::crofdpt& dpt,
321  const rofl::cauxid& auxid,
323  {};
324 
334  virtual void
336  rofl::crofdpt& dpt,
337  uint32_t xid)
338  {};
339 
347  virtual void
349  rofl::crofdpt& dpt,
350  const rofl::cauxid& auxid,
352  {};
353 
363  virtual void
365  rofl::crofdpt& dpt,
366  uint32_t xid)
367  {};
368 
376  virtual void
378  rofl::crofdpt& dpt,
379  const rofl::cauxid& auxid,
381  {};
382 
392  virtual void
394  rofl::crofdpt& dpt,
395  uint32_t xid)
396  {};
397 
405  virtual void
407  rofl::crofdpt& dpt,
408  const rofl::cauxid& auxid,
410  {};
411 
421  virtual void
423  rofl::crofdpt& dpt,
424  uint32_t xid)
425  {};
426 
434  virtual void
436  rofl::crofdpt& dpt,
437  const rofl::cauxid& auxid,
439  {};
440 
450  virtual void
452  rofl::crofdpt& dpt,
453  uint32_t xid)
454  {};
455 
463  virtual void
465  rofl::crofdpt& dpt,
466  const rofl::cauxid& auxid,
468  {};
469 
479  virtual void
481  rofl::crofdpt& dpt,
482  uint32_t xid)
483  {};
484 
492  virtual void
494  rofl::crofdpt& dpt,
495  const rofl::cauxid& auxid,
497  {};
498 
508  virtual void
510  rofl::crofdpt& dpt,
511  uint32_t xid)
512  {};
513 
521  virtual void
523  rofl::crofdpt& dpt,
524  const rofl::cauxid& auxid,
526  {};
527 
537  virtual void
539  rofl::crofdpt& dpt,
540  uint32_t xid)
541  {};
542 
550  virtual void
552  rofl::crofdpt& dpt,
553  const rofl::cauxid& auxid,
555  {};
556 
566  virtual void
568  rofl::crofdpt& dpt,
569  uint32_t xid)
570  {};
571 
579  virtual void
581  rofl::crofdpt& dpt,
582  const rofl::cauxid& auxid,
584  {};
585 
595  virtual void
597  rofl::crofdpt& dpt,
598  uint32_t xid)
599  {};
600 
608  virtual void
610  rofl::crofdpt& dpt,
611  const rofl::cauxid& auxid,
613  {};
614 
624  virtual void
626  rofl::crofdpt& dpt,
627  uint32_t xid)
628  {};
629 
637  virtual void
639  rofl::crofdpt& dpt,
640  const rofl::cauxid& auxid,
642  {};
643 
653  virtual void
655  rofl::crofdpt& dpt,
656  uint32_t xid)
657  {};
658 
666  virtual void
668  rofl::crofdpt& dpt,
669  const rofl::cauxid& auxid,
671  {};
672 
682  virtual void
684  rofl::crofdpt& dpt,
685  uint32_t xid)
686  {};
687 
695  virtual void
697  rofl::crofdpt& dpt,
698  const rofl::cauxid& auxid,
700  {};
701 
711  virtual void
713  rofl::crofdpt& dpt,
714  uint32_t xid)
715  {};
716 
724  virtual void
726  rofl::crofdpt& dpt,
727  const rofl::cauxid& auxid,
729  {};
730 
740  virtual void
742  rofl::crofdpt& dpt,
743  uint32_t xid)
744  {};
745 
753  virtual void
755  rofl::crofdpt& dpt,
756  const rofl::cauxid& auxid,
758  {};
759 
767  virtual void
769  rofl::crofdpt& dpt,
770  const rofl::cauxid& auxid,
772  {};
773 
783  virtual void
785  rofl::crofdpt& dpt,
786  uint32_t xid)
787  {};
788 
796  virtual void
798  rofl::crofdpt& dpt,
799  const rofl::cauxid& auxid,
801  {};
802 
810  virtual void
812  rofl::crofdpt& dpt,
813  const rofl::cauxid& auxid,
815  {};
816 
824  virtual void
826  rofl::crofdpt& dpt,
827  const rofl::cauxid& auxid,
829  {};
830 
840  virtual void
842  rofl::crofdpt& dpt,
843  uint32_t xid)
844  {};
845 
853  virtual void
855  rofl::crofdpt& dpt,
856  const rofl::cauxid& auxid,
858  {};
859 
867  virtual void
869  rofl::crofdpt& dpt,
870  const rofl::cauxid& auxid,
872  {};
873 
883  virtual void
885  rofl::crofdpt& dpt,
886  uint32_t xid)
887  {};
888 
896  virtual void
898  rofl::crofdpt& dpt,
899  const rofl::cauxid& auxid,
901  {};
902 
912  virtual void
914  rofl::crofdpt& dpt,
915  uint32_t xid)
916  {};
917 
925  virtual void
927  rofl::crofdpt& dpt,
928  const rofl::cauxid& auxid,
930  {};
931 
941  virtual void
943  rofl::crofdpt& dpt,
944  uint32_t xid)
945  {};
946 
948 };
949 
950 
973 class crofdpt :
974  public rofl::crofchan_env,
976  public ciosrv
977 {
978  enum crofdpt_timer_t {
979  TIMER_RUN_ENGINE = 0,
980  };
981 
982  enum crofdpt_state_t {
983  STATE_INIT = 0,
984  STATE_DISCONNECTED = 1,
985  STATE_CONNECTED = 2,
986  STATE_FEATURES_RCVD = 3,
987  STATE_GET_CONFIG_RCVD = 4,
988  STATE_TABLE_FEATURES_RCVD = 5,
989  STATE_ESTABLISHED = 6,
990  };
991 
992  enum crofdpt_event_t {
993  EVENT_NONE = 0,
994  EVENT_DISCONNECTED = 1,
995  EVENT_CONNECTED = 2,
996  EVENT_CONN_TERMINATED = 3,
997  EVENT_CONN_REFUSED = 4,
998  EVENT_CONN_FAILED = 5,
999  EVENT_FEATURES_REPLY_RCVD = 6,
1000  EVENT_FEATURES_REQUEST_EXPIRED = 7,
1001  EVENT_GET_CONFIG_REPLY_RCVD = 8,
1002  EVENT_GET_CONFIG_REQUEST_EXPIRED = 9,
1003  EVENT_TABLE_STATS_REPLY_RCVD = 10,
1004  EVENT_TABLE_STATS_REQUEST_EXPIRED = 11,
1005  EVENT_TABLE_FEATURES_STATS_REPLY_RCVD = 12,
1006  EVENT_TABLE_FEATURES_STATS_REQUEST_EXPIRED = 13,
1007  EVENT_PORT_DESC_STATS_REPLY_RCVD = 14,
1008  EVENT_PORT_DESC_STATS_REQUEST_EXPIRED = 15,
1009  };
1010 
1011  enum crofdpt_flag_t {
1012  FLAG_ENGINE_IS_RUNNING = (1 << 0),
1013  };
1014 
1015 public:
1016 
1024  static rofl::crofdpt&
1025  get_dpt(
1026  const rofl::cdptid& dptid);
1027 
1035  static rofl::crofdpt&
1036  get_dpt(
1037  const rofl::cdpid& dpid);
1038 
1049  rofl::crofdpt_env* env,
1050  const rofl::cdptid& dptid,
1051  bool remove_on_channel_close,
1052  const rofl::openflow::cofhello_elem_versionbitmap& versionbitmap,
1053  const rofl::cdpid& dpid = rofl::cdpid(0)) :
1054  env(env),
1055  dptid(dptid),
1056  rofchan(this, versionbitmap),
1057  transactions(this),
1058  remove_on_channel_close(remove_on_channel_close),
1059  dpid(dpid),
1060  hwaddr(cmacaddr("00:00:00:00:00:00")),
1061  n_buffers(0),
1062  n_tables(0),
1063  capabilities(0),
1064  config(0),
1065  miss_send_len(0),
1066  state(STATE_INIT) {
1067  crofdpt::rofdpts[dptid] = this;
1068  rofl::logging::debug << "[rofl-common][crofdpt] "
1069  << "instance created, dptid: " << dptid.str() << std::endl;
1070  };
1071 
1077  virtual
1079  rofl::logging::debug << "[rofl-common][crofdpt] "
1080  << "instance destroyed, dptid: " << dptid.str() << std::endl;
1081  crofdpt::rofdpts.erase(dptid);
1082  rofchan.close();
1083  transactions.clear();
1084  };
1085 
1091  const rofl::cdptid&
1092  get_dptid() const
1093  { return dptid; };
1094 
1095 public:
1096 
1117  std::list<rofl::cauxid>
1119  { return rofchan.get_conn_index(); };
1120 
1138  void
1140  const rofl::cauxid& auxid,
1141  enum rofl::csocket::socket_type_t socket_type,
1142  const rofl::cparams& socket_params) {
1143  if (rofl::cauxid(0) == auxid) {
1144  rofchan.close();
1145  transactions.clear();
1146  tables.clear();
1147  ports.clear();
1148  }
1149  rofchan.add_conn(auxid, socket_type, socket_params);
1150  };
1151 
1160  void
1162  rofl::cauxid auxid) { // make a copy here, rather than using a const-reference
1163  rofchan.drop_conn(auxid);
1164  call_env().handle_conn_terminated(*this, auxid);
1165  if (rofl::cauxid(0) == auxid) {
1166  call_env().handle_chan_terminated(*this);
1167  }
1168  };
1169 
1179  void
1181  crofconn* conn) {
1182  if (NULL == conn) {
1183  return;
1184  }
1185  if (rofl::cauxid(0) == conn->get_aux_id()) {
1186  dpid = rofl::cdpid(conn->get_dpid());
1187  }
1188  rofchan.add_conn(conn->get_aux_id(), conn);
1189  };
1190 
1193 public:
1194 
1204  bool
1206  { return rofchan.is_established(); };
1207 
1213  uint8_t
1215  { return rofchan.get_version(); };
1216 
1224  { return rofchan.get_versionbitmap(); };
1225 
1229  bool
1231  { return remove_on_channel_close; };
1232 
1240  const rofl::cauxid& auxid) const
1241  { return rofchan.get_conn(auxid).get_rofsocket().get_socket().get_raddr(); };
1242 
1245 public:
1246 
1258  const rofl::cdpid&
1259  get_dpid() const
1260  { return dpid; };
1261 
1267  const rofl::caddress_ll&
1268  get_hwaddr() const
1269  { return hwaddr; };
1270 
1276  uint32_t
1278  { return n_buffers; };
1279 
1285  uint8_t
1287  { return n_tables; };
1288 
1294  uint32_t
1296  { return capabilities; };
1297 
1303  uint16_t
1304  get_config() const
1305  { return config; };
1306 
1312  uint16_t
1314  { return miss_send_len; };
1315 
1327  get_ports() const
1328  { return ports; };
1329 
1341  get_tables() const
1342  { return tables; };
1343 
1346 public:
1347 
1367  uint32_t
1369  uint32_t group_id = 1;
1370  while (groupids.find(group_id) != groupids.end()) {
1371  group_id++;
1372  }
1373  groupids.insert(group_id);
1374  return group_id;
1375  };
1376 
1382  void
1383  release_group_id(uint32_t group_id)
1384  { groupids.erase(group_id); };
1385 
1389  void
1391  { groupids.clear(); };
1392 
1395 public:
1396 
1409  void
1410  flow_mod_reset();
1411 
1418  void
1419  group_mod_reset();
1420 
1431  void
1433  const rofl::cauxid& auxid,
1434  uint32_t buffer_id,
1435  uint32_t inport = rofl::openflow::OFPP_CONTROLLER) {
1437  send_packet_out_message(auxid, buffer_id, inport, actions, NULL, 0);
1438  };
1439 
1442 public:
1443 
1462  uint32_t
1464  const rofl::cauxid& auxid,
1465  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1466 
1476  uint32_t
1478  const rofl::cauxid& auxid,
1479  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1480 
1491  uint32_t
1493  const rofl::cauxid& auxid,
1494  uint16_t stats_flags,
1495  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1496 
1510  uint32_t
1512  const rofl::cauxid& auxid,
1513  uint16_t stats_type,
1514  uint16_t stats_flags,
1515  uint8_t *body = NULL,
1516  size_t bodylen = 0,
1517  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1518 
1529  uint32_t
1531  const rofl::cauxid& auxid,
1532  uint16_t stats_flags,
1533  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1534 
1545  uint32_t
1547  const rofl::cauxid& auxid,
1548  uint16_t stats_flags,
1549  const rofl::openflow::cofflow_stats_request& flow_stats_request,
1550  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1551 
1563  uint32_t
1565  const rofl::cauxid& auxid,
1566  uint16_t flags,
1567  const rofl::openflow::cofaggr_stats_request& aggr_stats_request,
1568  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1569 
1570 
1581  uint32_t
1583  const rofl::cauxid& auxid,
1584  uint16_t stats_flags = 0,
1585  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1586 
1598  uint32_t
1600  const rofl::cauxid& auxid,
1601  uint16_t stats_flags,
1602  const rofl::openflow::cofport_stats_request& port_stats_request,
1603  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1604 
1616  uint32_t
1618  const rofl::cauxid& auxid,
1619  uint16_t stats_flags,
1620  const rofl::openflow::cofqueue_stats_request& queue_stats_request,
1621  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1622 
1634  uint32_t
1636  const rofl::cauxid& auxid,
1637  uint16_t stats_flags,
1638  const rofl::openflow::cofgroup_stats_request& group_stats_request,
1639  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1640 
1651  uint32_t
1653  const rofl::cauxid& auxid,
1654  uint16_t stats_flags = 0,
1655  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1656 
1667  uint32_t
1669  const rofl::cauxid& auxid,
1670  uint16_t stats_flags,
1671  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1672 
1683  uint32_t
1685  const rofl::cauxid& auxid,
1686  uint16_t stats_flags,
1687  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1688 
1702  uint32_t
1704  const rofl::cauxid& auxid,
1705  uint16_t stats_flags,
1706  uint32_t exp_id,
1707  uint32_t exp_type,
1708  const cmemory& body,
1709  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1710 
1722  uint32_t
1724  const rofl::cauxid& auxid,
1725  uint16_t stats_flags,
1726  const rofl::openflow::cofmeter_stats_request& meter_stats_request,
1727  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1728 
1740  uint32_t
1742  const rofl::cauxid& auxid,
1743  uint16_t stats_flags,
1744  const rofl::openflow::cofmeter_config_request& meter_config_stats_request,
1745  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1746 
1757  uint32_t
1759  const rofl::cauxid& auxid,
1760  uint16_t stats_flags,
1761  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1762 
1776  uint32_t
1778  const rofl::cauxid& auxid,
1779  uint32_t buffer_id,
1780  uint32_t in_port,
1781  const rofl::openflow::cofactions& actions,
1782  uint8_t *data = NULL,
1783  size_t datalen = 0);
1784 
1794  uint32_t
1796  const rofl::cauxid& auxid,
1797  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1798 
1809  uint32_t
1811  const rofl::cauxid& auxid,
1812  const rofl::openflow::cofrole& role,
1813  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1814 
1824  uint32_t
1826  const rofl::cauxid& auxid,
1827  const rofl::openflow::cofflowmod& flowmod);
1828 
1838  uint32_t
1840  const rofl::cauxid& auxid,
1841  const rofl::openflow::cofgroupmod& groupmod);
1842 
1853  uint32_t
1855  const rofl::cauxid& auxid,
1856  uint8_t table_id,
1857  uint32_t config);
1858 
1872  uint32_t
1874  const rofl::cauxid& auxid,
1875  uint32_t port_no,
1876  const rofl::caddress_ll& hwaddr,
1877  uint32_t config,
1878  uint32_t mask,
1879  uint32_t advertise);
1880 
1891  uint32_t
1893  const rofl::cauxid& auxid,
1894  uint16_t flags,
1895  uint16_t miss_send_len);
1896 
1907  uint32_t
1909  const rofl::cauxid& auxid,
1910  uint32_t port,
1911  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1912 
1922  uint32_t
1924  const rofl::cauxid& auxid,
1925  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
1926 
1936  uint32_t
1938  const rofl::cauxid& auxid,
1939  const rofl::openflow::cofasync_config& async_config);
1940 
1953  uint32_t
1955  const rofl::cauxid& auxid,
1956  uint16_t command,
1957  uint16_t flags,
1958  uint32_t meter_id,
1959  const rofl::openflow::cofmeter_bands& meter_bands);
1960 
1973  void
1975  const rofl::cauxid& auxid,
1976  uint32_t xid,
1977  uint16_t type,
1978  uint16_t code,
1979  uint8_t* data = NULL,
1980  size_t datalen = 0);
1981 
1995  uint32_t
1997  const rofl::cauxid& auxid,
1998  uint32_t exp_id,
1999  uint32_t exp_type,
2000  uint8_t *body = NULL,
2001  size_t bodylen = 0,
2002  const rofl::cclock& timeout = rofl::cclock(/*seconds=*/DEFAULT_REQUEST_TIMEOUT));
2003 
2006 public:
2007 
2012  cdptid dptid;
2013  public:
2014  crofdpt_find_by_dptid(const rofl::cdptid& dptid) : dptid(dptid) {};
2015  bool operator() (const crofdpt* rofdpt) {
2016  return (rofdpt->get_dptid() == dptid);
2017  };
2018  };
2019 
2024  uint64_t dpid;
2025  public:
2026  crofdpt_find_by_dpid(uint64_t dpid) : dpid(dpid) {};
2027  bool operator() (const std::pair<cdptid, crofdpt*>& p) {
2028  return (p.second->get_dpid().get_uint64_t() == dpid);
2029  };
2030  };
2031 
2032 public:
2033 
2034  friend std::ostream&
2035  operator<< (std::ostream& os, const crofdpt& dpt) {
2036  os << indent(0) << "<crofdpt >";
2037  { rofl::indent i(2); os << dpt.get_dptid(); }
2038  { rofl::indent i(2); os << dpt.rofchan; }
2039  switch (dpt.state) {
2040  case STATE_INIT: {
2041  os << indent(2) << "<state: -INIT- >" << std::endl;
2042  } break;
2043  case STATE_CONNECTED: {
2044  os << indent(2) << "<state: -CONNECTED- >" << std::endl;
2045  } break;
2046  case STATE_DISCONNECTED: {
2047  os << indent(2) << "<state: -DISCONNECTED- >" << std::endl;
2048  } break;
2049  case STATE_ESTABLISHED: {
2050  os << indent(2) << "<state: -ESTABLISHED- >" << std::endl;
2051  } break;
2052  case STATE_FEATURES_RCVD: {
2053  os << indent(2) << "<state: -FEATURES-RCVD- >" << std::endl;
2054  } break;
2055  case STATE_GET_CONFIG_RCVD: {
2056  os << indent(2) << "<state: -GET-CONFIG-RCVD- >" << std::endl;
2057  } break;
2058  case STATE_TABLE_FEATURES_RCVD: {
2059  os << indent(2) << "<state: -TABLE-FEATURES-RCVD- >" << std::endl;
2060  } break;
2061  default: {
2062  os << indent(2) << "<state: -UNKNOWN- >" << std::endl;
2063  } break;
2064  }
2065  os << indent(2) << "<hwaddr: " << dpt.hwaddr.str() << " >" << std::endl;
2066  os << indent(2) << "<#buffers: " << (int)dpt.n_buffers << " >" << std::endl;
2067  os << indent(2) << "<#tables: " << (int)dpt.n_tables << " >" << std::endl;
2068  os << indent(2) << "<capabilities: " << std::hex << (int)dpt.capabilities << std::dec << " >" << std::endl;
2069  os << indent(2) << "<config: " << std::hex << (int)dpt.config << std::dec << " >" << std::endl;
2070  os << indent(2) << "<miss-send-len: " << (int)dpt.miss_send_len << " >" << std::endl;
2071  rofl::indent j(2);
2072  os << dpt.tables;
2073  os << dpt.ports;
2074  os << dpt.transactions;
2075  return os;
2076  };
2077 
2081  std::string
2082  str() const {
2083  std::stringstream ss;
2084  ss << "dpid: " << get_dpid().str() << " ";
2085  switch (state) {
2086  case STATE_INIT: {
2087  ss << "state: -init- ";
2088  } break;
2089  case STATE_CONNECTED: {
2090  ss << "state: -connected- ";
2091  } break;
2092  case STATE_DISCONNECTED: {
2093  ss << "state: -disconnected- ";
2094  } break;
2095  case STATE_ESTABLISHED: {
2096  ss << "state: -established- ";
2097  } break;
2098  case STATE_FEATURES_RCVD: {
2099  ss << "state: -features-rcvd- ";
2100  } break;
2101  case STATE_GET_CONFIG_RCVD: {
2102  ss << "state: -get-config-rcvd- ";
2103  } break;
2104  case STATE_TABLE_FEATURES_RCVD: {
2105  ss << "state: -table-features-rcvd- ";
2106  } break;
2107  default: {
2108  ss << "state: -unknown- ";
2109  } break;
2110  }
2111  return ss.str();
2112  };
2113 
2114 private:
2115 
2116  crofdpt_env&
2117  call_env() {
2118  if (crofdpt_env::rofdpt_envs.find(env) == crofdpt_env::rofdpt_envs.end()) {
2119  throw eRofDptNotFound("rofl::crofdpt::call_env() environment not found");
2120  }
2121  return *env;
2122  };
2123 
2124  virtual void
2125  handle_conn_established(
2126  crofchan& chan,
2127  const rofl::cauxid& auxid) {
2128  rofl::logging::info << "[rofl-common][crofdpt] dptid: " << dptid.str()
2129  << " control connection established, auxid: " << auxid.str() << std::endl;
2130 
2131  call_env().handle_conn_established(*this, auxid);
2132 
2133  if (auxid == rofl::cauxid(0)) {
2134  rofl::logging::info << "[rofl-common][crofdpt] dpid: " << std::hex << get_dpid().str() << std::dec
2135  << " OFP control channel established, " << chan.str() << std::endl;
2136  push_on_eventqueue(EVENT_CONNECTED);
2137  }
2138  };
2139 
2140  virtual void
2141  handle_conn_terminated(
2142  crofchan& chan,
2143  const rofl::cauxid& auxid) {
2144  rofl::logging::info << "[rofl-common][crofdpt] dptid: " << dptid.str()
2145  << " control connection terminated, auxid: " << auxid.str() << std::endl;
2146 
2147  rofl::RwLock rwlock(conns_terminated_rwlock, rofl::RwLock::RWLOCK_WRITE);
2148  conns_terminated.push_back(auxid);
2149  push_on_eventqueue(EVENT_CONN_TERMINATED);
2150 
2151  if (auxid == rofl::cauxid(0)) {
2152  rofl::logging::info << "[rofl-common][crofdpt] dptid: " << dptid.str()
2153  << " OFP control channel terminated, " << chan.str() << std::endl;
2154  transactions.clear();
2155  push_on_eventqueue(EVENT_DISCONNECTED);
2156  }
2157  };
2158 
2159  virtual void
2160  handle_conn_refused(
2161  crofchan& chan,
2162  const rofl::cauxid& auxid) {
2163  rofl::RwLock rwlock(conns_refused_rwlock, rofl::RwLock::RWLOCK_WRITE);
2164  conns_refused.push_back(auxid);
2165  push_on_eventqueue(EVENT_CONN_REFUSED);
2166  };
2167 
2168  virtual void
2169  handle_conn_failed(
2170  crofchan& chan,
2171  const rofl::cauxid& auxid) {
2172  rofl::RwLock rwlock(conns_failed_rwlock, rofl::RwLock::RWLOCK_WRITE);
2173  conns_failed.push_back(auxid);
2174  push_on_eventqueue(EVENT_CONN_FAILED);
2175  };
2176 
2177  virtual void
2178  handle_write(crofchan& chan, const rofl::cauxid& auxid)
2179  { call_env().handle_conn_writable(*this, auxid); };
2180 
2181  virtual void
2182  recv_message(crofchan& chan, const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2183 
2184  virtual uint32_t
2185  get_async_xid(crofchan& chan)
2186  { return transactions.get_async_xid(); };
2187 
2188  virtual uint32_t
2189  get_sync_xid(crofchan& chan, uint8_t msg_type = 0, uint16_t msg_sub_type = 0)
2190  { return transactions.add_ta(cclock(/*secs=*/5), msg_type, msg_sub_type); };
2191 
2192  virtual void
2193  release_sync_xid(crofchan& chan, uint32_t xid)
2194  { return transactions.drop_ta(xid); };
2195 
2196 private:
2197 
2198  virtual void
2199  ta_expired(rofl::ctransactions& tas, rofl::ctransaction& ta);
2200 
2201 private:
2202 
2203  virtual void
2204  handle_timeout(
2205  int opaque, void *data = (void*)0);
2206 
2207 private:
2208 
2209  void
2210  push_on_eventqueue(
2211  enum crofdpt_event_t event = EVENT_NONE) {
2212  if (EVENT_NONE != event) {
2213  events.push_back(event);
2214  }
2215  if (not flags.test(FLAG_ENGINE_IS_RUNNING)) {
2216  register_timer(TIMER_RUN_ENGINE, rofl::ctimespec(0));
2217  }
2218  };
2219 
2220  void
2221  work_on_eventqueue();
2222 
2223  void
2224  event_disconnected();
2225 
2226  void
2227  event_connected();
2228 
2229  void
2230  event_conn_terminated();
2231 
2232  void
2233  event_conn_refused();
2234 
2235  void
2236  event_conn_failed();
2237 
2238  void
2239  event_features_reply_rcvd();
2240 
2241  void
2242  event_features_request_expired(
2243  uint32_t xid = 0);
2244 
2245  void
2246  event_get_config_reply_rcvd();
2247 
2248  void
2249  event_get_config_request_expired(
2250  uint32_t xid = 0);
2251 
2252  void
2253  event_table_stats_reply_rcvd();
2254 
2255  void
2256  event_table_stats_request_expired(
2257  uint32_t xid = 0);
2258 
2259  void
2260  event_table_features_stats_reply_rcvd();
2261 
2262  void
2263  event_table_features_stats_request_expired(
2264  uint32_t xid = 0);
2265 
2266  void
2267  event_port_desc_reply_rcvd();
2268 
2269  void
2270  event_port_desc_request_expired(
2271  uint32_t xid = 0);
2272 
2273 private:
2274 
2275  void
2276  experimenter_rcvd(
2277  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2278 
2279  void
2280  error_rcvd(
2281  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2282 
2283  void
2284  features_reply_rcvd(
2285  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2286 
2287  void
2288  get_config_reply_rcvd(
2289  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2290 
2291  void
2292  multipart_reply_rcvd(
2293  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2294 
2295  void
2296  desc_stats_reply_rcvd(
2297  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2298 
2299  void
2300  table_stats_reply_rcvd(
2301  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2302 
2303  void
2304  port_stats_reply_rcvd(
2305  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2306 
2307  void
2308  flow_stats_reply_rcvd(
2309  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2310 
2311  void
2312  aggregate_stats_reply_rcvd(
2313  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2314 
2315  void
2316  queue_stats_reply_rcvd(
2317  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2318 
2319  void
2320  group_stats_reply_rcvd(
2321  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2322 
2323  void
2324  group_desc_stats_reply_rcvd(
2325  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2326 
2327  void
2328  group_features_stats_reply_rcvd(
2329  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2330 
2331  void
2332  meter_stats_reply_rcvd(
2333  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2334 
2335  void
2336  meter_config_stats_reply_rcvd(
2337  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2338 
2339  void
2340  meter_features_stats_reply_rcvd(
2341  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2342 
2343  void
2344  table_features_stats_reply_rcvd(
2345  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2346 
2347  void
2348  port_desc_stats_reply_rcvd(
2349  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2350 
2351  void
2352  experimenter_stats_reply_rcvd(
2353  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2354 
2355  void
2356  barrier_reply_rcvd(
2357  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2358 
2359  void
2360  port_mod_sent(
2361  rofl::openflow::cofmsg *pack);
2362 
2363  void
2364  packet_in_rcvd(
2365  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2366 
2367  void
2368  flow_removed_rcvd(
2369  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2370 
2371  void
2372  port_status_rcvd(
2373  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2374 
2375  void
2376  role_reply_rcvd(
2377  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2378 
2379  void
2380  queue_get_config_reply_rcvd(
2381  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2382 
2383  void
2384  get_async_config_reply_rcvd(
2385  const rofl::cauxid& auxid, rofl::openflow::cofmsg *msg);
2386 
2387 private:
2388 
2389  static std::map<rofl::cdptid, crofdpt*> rofdpts;
2390 
2391  // environment
2392  rofl::crofdpt_env* env;
2393  // handle for this crofdpt instance
2394  rofl::cdptid dptid;
2395  // OFP control channel
2396  rofl::crofchan rofchan;
2397  // pending OFP transactions
2398  rofl::ctransactions transactions;
2399 
2400  bool remove_on_channel_close;
2401  // allocated groupids on datapath
2402  std::set<uint32_t> groupids;
2403 
2404  // datapath identifier
2405  rofl::cdpid dpid;
2406  // datapath hardware address
2407  rofl::caddress_ll hwaddr;
2408  // number of buffer lines
2409  uint32_t n_buffers;
2410  // number of tables
2411  uint8_t n_tables;
2412  // capabilities field
2413  uint32_t capabilities;
2414  // list of tables
2416  // list of ports
2418  uint16_t config;
2419  uint16_t miss_send_len;
2420 
2421  unsigned int state;
2422  std::deque<enum crofdpt_event_t>
2423  events;
2424 
2425  PthreadRwLock conns_terminated_rwlock;
2426  std::list<rofl::cauxid> conns_terminated;
2427  PthreadRwLock conns_refused_rwlock;
2428  std::list<rofl::cauxid> conns_refused;
2429  PthreadRwLock conns_failed_rwlock;
2430  std::list<rofl::cauxid> conns_failed;
2431 
2432  std::bitset<32> flags;
2433  // delay queue, used for storing asynchronous messages during connection setup
2434  rofl::crofqueue dlqueue;
2435 
2436  static const time_t DEFAULT_REQUEST_TIMEOUT = 5; // seconds
2437 };
2438 
2439 }; // end of namespace
2440 
2441 #endif
Definition: cofmsg_barrier.h:125
virtual void handle_port_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_port_stats_reply &msg)
OpenFlow Port-Stats-Reply message received.
Definition: crofdpt.h:377
Definition: cauxid.h:30
Definition: cclock.h:25
virtual void handle_table_features_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_table_features_stats_reply &msg)
OpenFlow Table-Features-Stats-Reply message received.
Definition: crofdpt.h:667
Definition: cofmsg_meter_stats.h:146
Definition: cofmsg_config.h:115
uint32_t send_queue_get_config_request(const rofl::cauxid &auxid, uint32_t port, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Queue-Get-Config-Request message to attached datapath element.
Definition: crofdpt.cc:1736
virtual void handle_group_features_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_group_features_stats_reply &msg)
OpenFlow Group-Features-Stats-Reply message received.
Definition: crofdpt.h:551
cauxid const & get_aux_id() const
Return auxialiary_id.
Definition: crofconn.h:334
const rofl::caddress_ll & get_hwaddr() const
Returns the datapath element's hardware address.
Definition: crofdpt.h:1268
virtual void handle_barrier_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Barrier-Reply message.
Definition: crofdpt.h:784
virtual void handle_aggregate_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Aggregate-Stats-Reply message.
Definition: crofdpt.h:451
Definition: cparams.h:20
virtual void handle_group_desc_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_group_desc_stats_reply &msg)
OpenFlow Group-Desc-Stats-Reply message received.
Definition: crofdpt.h:522
Definition: cofmsg_role.h:131
virtual void handle_error_message(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_error &msg)
OpenFlow Error message received.
Definition: crofdpt.h:854
virtual void handle_chan_terminated(rofl::crofdpt &dpt)
Called after termination of associated OpenFlow control channel.
Definition: crofdpt.h:124
Predicate for finding a rofl::crofdpt instance by its rofl::cdptid.
Definition: crofdpt.h:2011
Definition: caddress.h:152
virtual void handle_meter_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Meter-Stats-Reply message.
Definition: crofdpt.h:596
void flow_mod_reset()
Removes all flow-table entries from the attached datapath element.
Definition: crofdpt.cc:699
const rofl::openflow::cofports & get_ports() const
Returns const reference to the datapath element's port list.
Definition: crofdpt.h:1327
Definition: cofmsg_flow_stats.h:164
const rofl::cdptid & get_dptid() const
Returns rofl-common's internal rofl::cdptid identifier for this instance.
Definition: crofdpt.h:1092
Definition: cofgroupmod.h:24
Definition: cofmsg_experimenter.h:19
Definition: cofmsg_port_stats.h:156
uint32_t send_flow_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofflow_stats_request &flow_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Flow-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:892
virtual void handle_experimenter_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Experimenter message.
Definition: crofdpt.h:884
uint32_t get_next_idle_group_id()
Returns the next idle group table identifier.
Definition: crofdpt.h:1368
crofdpt(rofl::crofdpt_env *env, const rofl::cdptid &dptid, bool remove_on_channel_close, const rofl::openflow::cofhello_elem_versionbitmap &versionbitmap, const rofl::cdpid &dpid=rofl::cdpid(0))
crofdpt constructor
Definition: crofdpt.h:1048
uint16_t get_config() const
Returns the datapath element's configuration.
Definition: crofdpt.h:1304
virtual void handle_group_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Group-Stats-Reply message.
Definition: crofdpt.h:509
uint32_t send_experimenter_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, uint32_t exp_id, uint32_t exp_type, const cmemory &body, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Experimenter-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1273
rofl::caddress get_peer_addr(const rofl::cauxid &auxid) const
Returns caddress of connected remote entity for given connection identifier.
Definition: crofdpt.h:1239
Definition: cofmsg_stats.h:264
virtual void handle_queue_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Queue-Stats-Reply message.
Definition: crofdpt.h:480
virtual void handle_desc_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Desc-Stats-Reply message.
Definition: crofdpt.h:335
Definition: cdpid.h:20
Definition: crofdpt.h:51
void drop_buffer(const rofl::cauxid &auxid, uint32_t buffer_id, uint32_t inport=rofl::openflow::OFPP_CONTROLLER)
Drops packet identified by buffer-id from the attached datapath element.
Definition: crofdpt.h:1432
Definition: cofhelloelemversionbitmap.h:22
rofl-common's internal remote datapath handle.
Definition: cdptid.h:24
virtual void handle_experimenter_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_experimenter_stats_reply &msg)
OpenFlow Experimenter-Stats-Reply message received.
Definition: crofdpt.h:725
virtual void handle_experimenter_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Experimenter-Stats-Reply message.
Definition: crofdpt.h:741
Definition: caddress.h:30
virtual void handle_group_desc_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Group-Desc-Stats-Reply message.
Definition: crofdpt.h:538
uint32_t send_desc_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Desc-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:855
Definition: crofdpt.h:47
uint32_t send_meter_mod_message(const rofl::cauxid &auxid, uint16_t command, uint16_t flags, uint32_t meter_id, const rofl::openflow::cofmeter_bands &meter_bands)
Sends OpenFlow Meter-Mod message to attached datapath element.
Definition: crofdpt.cc:1843
const rofl::cdpid & get_dpid() const
Returns OpenFlow datapath identifier for this instance.
Definition: crofdpt.h:1259
Definition: cofmsg_desc_stats.h:121
virtual void handle_desc_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_desc_stats_reply &msg)
OpenFlow Desc-Stats-Reply message received.
Definition: crofdpt.h:319
uint32_t send_get_async_config_request(const rofl::cauxid &auxid, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Get-Async-Config-Request message to attached datapath element.
Definition: crofdpt.cc:1773
void group_mod_reset()
Removes all group-table entries from the attached datapath element.
Definition: crofdpt.cc:723
virtual void handle_flow_removed(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_flow_removed &msg)
OpenFlow Flow-Removed message received.
Definition: crofdpt.h:797
Definition: cofactions.h:22
virtual void handle_role_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_role_reply &msg)
OpenFlow Role-Reply message received.
Definition: crofdpt.h:897
Definition: cofmeterbands.h:24
void release_group_id(uint32_t group_id)
Releases a previously allocated group table identifier.
Definition: crofdpt.h:1383
virtual void handle_group_features_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Group-Features-Stats-Reply message.
Definition: crofdpt.h:567
uint32_t send_experimenter_message(const rofl::cauxid &auxid, uint32_t exp_id, uint32_t exp_type, uint8_t *body=NULL, size_t bodylen=0, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Experimenter message to attached datapath element.
Definition: crofdpt.cc:1921
uint32_t send_stats_request(const rofl::cauxid &auxid, uint16_t stats_type, uint16_t stats_flags, uint8_t *body=NULL, size_t bodylen=0, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Stats-Request message to attached datapath element.
Definition: crofdpt.cc:812
Definition: cofmsg_error.h:21
Environment expected by a rofl::crofchan instance.
Definition: crofchan.h:40
Definition: cofmsg_packet_in.h:21
std::string str() const
Returns a one-liner string with basic information about this instance.
Definition: crofdpt.h:2082
virtual void handle_flow_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Flow-Stats-Reply message.
Definition: crofdpt.h:422
virtual void handle_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_stats_reply &msg)
OpenFlow Stats-Reply message received.
Definition: crofdpt.h:288
virtual void handle_table_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_table_stats_reply &msg)
OpenFlow Table-Stats-Reply message received.
Definition: crofdpt.h:348
virtual void handle_features_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_features_reply &msg)
OpenFlow Features-Reply message received.
Definition: crofdpt.h:230
Definition: cofmsg_table_features_stats.h:161
Definition: cofmsg_queue_stats.h:144
Definition: cofasyncconfig.h:24
A single OpenFlow control connection.
Definition: crofconn.h:145
const rofl::openflow::cofhello_elem_versionbitmap & get_versions_available() const
Returns the defined OpenFlow version bitmap for this instance.
Definition: crofdpt.h:1223
virtual void handle_meter_config_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_meter_config_stats_reply &msg)
OpenFlow Meter-Config-Stats-Reply message received.
Definition: crofdpt.h:609
Definition: cofmsg_group_stats.h:152
uint32_t send_get_config_request(const rofl::cauxid &auxid, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Get-Config-Request message to attached datapath element.
Definition: crofdpt.cc:779
virtual void handle_queue_get_config_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Table-Stats-Reply message.
Definition: crofdpt.h:841
Definition: cofmsg_port_desc_stats.h:123
Definition: cofmsg_group_features_stats.h:120
Definition: cofmsg_port_status.h:20
uint32_t send_flow_mod_message(const rofl::cauxid &auxid, const rofl::openflow::cofflowmod &flowmod)
Sends OpenFlow Flow-Mod message to attached datapath element.
Definition: crofdpt.cc:1547
virtual void handle_queue_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_queue_stats_reply &msg)
OpenFlow Queue-Stats-Reply message received.
Definition: crofdpt.h:464
void connect(const rofl::cauxid &auxid, enum rofl::csocket::socket_type_t socket_type, const rofl::cparams &socket_params)
Establishes a new control connection to a remote datapath element with the given control connection i...
Definition: crofdpt.h:1139
uint32_t send_table_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags=0, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Table-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:970
virtual void handle_conn_failed(rofl::crofdpt &dpt, const rofl::cauxid &auxid)
Called when an attempt to establish a control connection has been failed.
Definition: crofdpt.h:179
Definition: cofmsg_aggr_stats.h:147
uint32_t send_table_features_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Table-Features-Stats-Request message to attached datapath element. ...
Definition: crofdpt.cc:1199
virtual void handle_get_async_config_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_get_async_config_reply &msg)
OpenFlow Get-Async-Config-Reply message received.
Definition: crofdpt.h:926
virtual void handle_port_status(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_port_status &msg)
OpenFlow Port-Status-Reply message received.
Definition: crofdpt.h:811
virtual void clear()
Definition: coftables.cc:74
virtual void handle_chan_established(rofl::crofdpt &dpt)
Called after establishing the associated OpenFlow control channel.
Definition: crofdpt.h:110
bool is_established() const
Returns true, when the control handshake (HELLO) has been completed.
Definition: crofdpt.h:1205
virtual void handle_port_desc_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Port-Desc-Stats-Reply message.
Definition: crofdpt.h:712
Definition: ctransaction.h:17
Definition: cofmsg_async_config.h:115
virtual void handle_role_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Role-Reply message.
Definition: crofdpt.h:913
Definition: cofmsg_queue_get_config.h:152
virtual void handle_barrier_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_barrier_reply &msg)
OpenFlow Barrier-Reply message received.
Definition: crofdpt.h:768
uint16_t get_miss_send_len() const
Returns the datapath element's current miss_send_len parameter.
Definition: crofdpt.h:1313
const rofl::ctimerid & register_timer(int opaque, const rofl::ctimespec &timespec)
Installs a new timer to fire in t seconds.
Definition: ciosrv.h:698
Definition: cofgroupstats.h:23
uint32_t send_group_mod_message(const rofl::cauxid &auxid, const rofl::openflow::cofgroupmod &groupmod)
Sends OpenFlow Group-Mod message to attached datapath element.
Definition: crofdpt.cc:1582
virtual void handle_packet_in(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_packet_in &msg)
OpenFlow Packet-In message received.
Definition: crofdpt.h:754
uint32_t send_port_desc_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Port-Desc-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1236
void clear_group_ids()
Resets the pool of all previously allocated group table identifiers.
Definition: crofdpt.h:1390
virtual void handle_conn_terminated(rofl::crofdpt &dpt, const rofl::cauxid &auxid)
Called when a control connection (main or auxiliary) has been terminated by the peer entity...
Definition: crofdpt.h:147
uint32_t send_group_desc_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags=0, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Group-Desc-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1124
Definition: cofports.h:22
Definition: cofrole.h:23
Definition: thread_helper.h:88
const rofl::openflow::coftables & get_tables() const
Returns const reference to the datapath element's tables list.
Definition: crofdpt.h:1341
void add_connection(crofconn *conn)
Add an existing rofl::crofconn instance created on heap to this object.
Definition: crofdpt.h:1180
virtual void handle_queue_get_config_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_queue_get_config_reply &msg)
OpenFlow Queue-Get-Config-Reply message received.
Definition: crofdpt.h:825
Definition: coftables.h:27
C++ abstraction for malloc'ed memory areas.
Definition: cmemory.h:44
Definition: cofmsg_features.h:118
uint32_t send_queue_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofqueue_stats_request &queue_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Queue-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1046
uint32_t get_n_buffers() const
Returns the datapath element's number of buffers for storing data packets.
Definition: crofdpt.h:1277
uint32_t send_group_features_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Group-Features-Stats-Request message to attached datapath element. ...
Definition: crofdpt.cc:1162
uint32_t send_port_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofport_stats_request &port_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Port-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1007
virtual void handle_get_async_config_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Get-Async-Config-Reply message.
Definition: crofdpt.h:942
Definition: cofportstats.h:24
virtual void handle_meter_features_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Meter-Features-Stats-Reply message.
Definition: crofdpt.h:654
virtual void handle_table_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Table-Stats-Reply message.
Definition: crofdpt.h:364
virtual void handle_meter_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_meter_stats_reply &msg)
OpenFlow Meter-Stats-Reply message received.
Definition: crofdpt.h:580
virtual void handle_meter_features_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_meter_features_stats_reply &msg)
OpenFlow Meter-Features-Stats-Reply message received.
Definition: crofdpt.h:638
std::list< rofl::cauxid > get_conn_index() const
Returns a list of connection identifiers of all existing control connections.
Definition: crofdpt.h:1118
uint32_t send_meter_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofmeter_stats_request &meter_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Meter-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1316
Predicate for finding a rofl::crofdpt instance by its rofl::cdpid.
Definition: crofdpt.h:2023
uint32_t send_meter_features_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Meter-Features-Stats-Request message to attached datapath element. ...
Definition: crofdpt.cc:1394
virtual void handle_group_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_group_stats_reply &msg)
OpenFlow Group-Stats-Reply message received.
Definition: crofdpt.h:493
crofdpt_env()
rofl::crofdpt_env constructor
Definition: crofdpt.h:83
virtual void handle_get_config_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Get-Config-Reply message.
Definition: crofdpt.h:275
uint32_t send_barrier_request(const rofl::cauxid &auxid, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Barrier-Request message to attached datapath element.
Definition: crofdpt.cc:1475
Definition: crofqueue.h:20
virtual void handle_aggregate_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_aggr_stats_reply &msg)
OpenFlow Aggregate-Stats-Reply message received.
Definition: crofdpt.h:435
Definition: cofmsg_meter_features_stats.h:88
Definition: cofflowmod.h:31
uint32_t send_features_request(const rofl::cauxid &auxid, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Features-Request message to attached datapath element.
Definition: crofdpt.cc:746
virtual void handle_experimenter_message(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_experimenter &msg)
OpenFlow Experimenter message received.
Definition: crofdpt.h:868
Base class for IO services.
Definition: ciosrv.h:491
Definition: logging.h:76
uint64_t get_dpid() const
Returns data path id assigned to this connection.
Definition: crofconn.h:327
Definition: cofmsg_group_desc_stats.h:123
void disconnect(rofl::cauxid auxid)
Terminates an existing control connection with given identifier.
Definition: crofdpt.h:1161
uint32_t send_aggr_stats_request(const rofl::cauxid &auxid, uint16_t flags, const rofl::openflow::cofaggr_stats_request &aggr_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Aggregate-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:931
Time specification used by class rofl::ctimer object.
Definition: ctimespec.h:25
uint32_t send_port_mod_message(const rofl::cauxid &auxid, uint32_t port_no, const rofl::caddress_ll &hwaddr, uint32_t config, uint32_t mask, uint32_t advertise)
Sends OpenFlow Port-Mod message to attached datapath element.
Definition: crofdpt.cc:1654
uint32_t send_packet_out_message(const rofl::cauxid &auxid, uint32_t buffer_id, uint32_t in_port, const rofl::openflow::cofactions &actions, uint8_t *data=NULL, size_t datalen=0)
Sends OpenFlow Packet-Out message to attached datapath element.
Definition: crofdpt.cc:1431
Definition: cofmsg_table_stats.h:132
uint8_t get_version_negotiated() const
Returns the OpenFlow protocol version used for this control connection.
Definition: crofdpt.h:1214
virtual ~crofdpt()
crofdpt destructor
Definition: crofdpt.h:1078
Definition: ctransactions.h:27
virtual void handle_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid, uint8_t stats_type)
Timer expired while waiting for OpenFlow Stats-Reply message.
Definition: crofdpt.h:305
Class representing a remote datapath element.
Definition: crofdpt.h:973
uint32_t send_meter_config_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofmeter_config_request &meter_config_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Meter-Config-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1355
Definition: cofmsg_flow_removed.h:20
uint8_t get_n_tables() const
Returns the datapath element's number of tables in the OpenFlow pipeline.
Definition: crofdpt.h:1286
Definition: cofaggrstats.h:21
uint32_t send_role_request(const rofl::cauxid &auxid, const rofl::openflow::cofrole &role, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Role-Request message to attached datapath element.
Definition: crofdpt.cc:1510
virtual void handle_features_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Features-Reply message.
Definition: crofdpt.h:246
Definition: cofmsg_meter_config_stats.h:147
virtual void handle_conn_writable(rofl::crofdpt &dpt, const rofl::cauxid &auxid)
Called when a congestion situation on the control connection has been solved.
Definition: crofdpt.h:201
virtual void handle_table_features_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Table-Features-Stats-Reply message.
Definition: crofdpt.h:683
bool remove_on_channel_termination() const
Returns true, when this instance should be destroyed when its crofchan has closed.
Definition: crofdpt.h:1230
uint32_t send_set_config_message(const rofl::cauxid &auxid, uint16_t flags, uint16_t miss_send_len)
Sends OpenFlow Set-Config message to attached datapath element.
Definition: crofdpt.cc:1699
Environment expected by a rofl::crofdpt instance.
Definition: crofdpt.h:75
uint32_t send_group_stats_request(const rofl::cauxid &auxid, uint16_t stats_flags, const rofl::openflow::cofgroup_stats_request &group_stats_request, const rofl::cclock &timeout=rofl::cclock(DEFAULT_REQUEST_TIMEOUT))
Sends OpenFlow Group-Stats-Request message to attached datapath element.
Definition: crofdpt.cc:1085
void send_error_message(const rofl::cauxid &auxid, uint32_t xid, uint16_t type, uint16_t code, uint8_t *data=NULL, size_t datalen=0)
Sends OpenFlow Error message to attached datapath element.
Definition: crofdpt.cc:1884
virtual void handle_flow_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_flow_stats_reply &msg)
OpenFlow Flow-Stats-Reply message received.
Definition: crofdpt.h:406
virtual void handle_conn_established(rofl::crofdpt &dpt, const rofl::cauxid &auxid)
Called when a control connection (main or auxiliary) has been established.
Definition: crofdpt.h:135
virtual ~crofdpt_env()
rofl::crofdpt_env destructor
Definition: crofdpt.h:90
virtual void handle_meter_config_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Meter-Config-Stats-Reply message.
Definition: crofdpt.h:625
uint32_t send_set_async_config_message(const rofl::cauxid &auxid, const rofl::openflow::cofasync_config &async_config)
Sends OpenFlow Set-Async-Config message to attached datapath element.
Definition: crofdpt.cc:1808
An OpenFlow control channel grouping multiple control connections.
Definition: crofchan.h:154
Definition: cofqueuestats.h:22
static rofl::crofdpt & get_dpt(const rofl::cdptid &dptid)
Returns reference to rofl::crofdpt instance identified by rofl-common's internal identifier.
Definition: crofdpt.cc:17
crofconn & add_conn(const cauxid &aux_id, enum rofl::csocket::socket_type_t socket_type, cparams const &socket_params)
Add a new connection while creating a new crofconn instance and do a socket connect.
Definition: crofchan.cc:69
virtual void handle_port_desc_stats_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_port_desc_stats_reply &msg)
OpenFlow Port-Desc-Stats-Reply message received.
Definition: crofdpt.h:696
Definition: cofmeterconfig.h:23
virtual void handle_conn_refused(rofl::crofdpt &dpt, const rofl::cauxid &auxid)
Called when an attempt to establish a control connection has been refused.
Definition: crofdpt.h:163
uint32_t get_capabilities() const
Returns the datapath element's capabilities.
Definition: crofdpt.h:1295
virtual void handle_port_stats_reply_timeout(rofl::crofdpt &dpt, uint32_t xid)
Timer expired while waiting for OpenFlow Port-Stats-Reply message.
Definition: crofdpt.h:393
Definition: ctransactions.h:35
uint32_t send_table_mod_message(const rofl::cauxid &auxid, uint8_t table_id, uint32_t config)
Sends OpenFlow Table-Mod message to attached datapath element.
Definition: crofdpt.cc:1617
Definition: croflexception.h:27
Definition: cofflowstats.h:26
Definition: cofmsg_experimenter_stats.h:184
Definition: cofmeterstats.h:23
virtual void handle_get_config_reply(rofl::crofdpt &dpt, const rofl::cauxid &auxid, rofl::openflow::cofmsg_get_config_reply &msg)
OpenFlow Get-Config-Reply message received.
Definition: crofdpt.h:259
Definition: cofmsg.h:62