IBR-DTNSuite  0.10
DatagramService.h
Go to the documentation of this file.
1 /*
2  * DatagramService.h
3  *
4  * Created on: 09.11.2012
5  * Author: morgenro
6  */
7 
8 #ifndef DATAGRAMSERVICE_H_
9 #define DATAGRAMSERVICE_H_
10 
11 #include "core/Node.h"
13 #include <string>
14 
15 namespace dtn
16 {
17  namespace net
18  {
20  {
21  public:
22  DatagramException(const std::string &what) : ibrcommon::Exception(what)
23  {};
24 
25  virtual ~DatagramException() throw() {};
26  };
27 
29  {
30  public:
31  WrongSeqNoException(size_t exp_seqno)
32  : DatagramException("Wrong sequence number received"), expected_seqno(exp_seqno)
33  {};
34 
35  virtual ~WrongSeqNoException() throw() {};
36 
37  const size_t expected_seqno;
38  };
39 
41  {
42  public:
44  {
45  FLOW_NONE = 0,
47  };
48 
50  {
51  SEGMENT_FIRST = 0x02,
52  SEGMENT_LAST = 0x01,
54  };
55 
56  class Parameter
57  {
58  public:
60  unsigned int max_seq_numbers;
63  bool seq_check;
64  };
65 
66  virtual ~DatagramService() = 0;
67 
72  virtual void bind() throw (DatagramException) = 0;
73 
77  virtual void shutdown() = 0;
78 
86  virtual void send(const char &type, const char &flags, const unsigned int &seqno, const std::string &address, const char *buf, size_t length) throw (DatagramException) = 0;
87 
94  virtual void send(const char &type, const char &flags, const unsigned int &seqno, const char *buf, size_t length) throw (DatagramException) = 0;
95 
104  virtual size_t recvfrom(char *buf, size_t length, char &type, char &flags, unsigned int &seqno, std::string &address) throw (DatagramException) = 0;
105 
110  virtual const std::string getServiceTag() const = 0;
111 
117  virtual const std::string getServiceDescription() const = 0;
118 
123  virtual const ibrcommon::vinterface& getInterface() const = 0;
124 
129  virtual dtn::core::Node::Protocol getProtocol() const = 0;
130 
135  virtual const Parameter& getParameter() const = 0;
136  };
137  }
138 }
139 
140 #endif /* DATAGRAMSERVICE_H_ */