Fawkes API  Fawkes Development Version
ProtobufPeerInterface.h
1 
2 /***************************************************************************
3  * ProtobufPeerInterface.h - Fawkes BlackBoard Interface - ProtobufPeerInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2017 Victor MatarĂ©
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _INTERFACES_PROTOBUFPEERINTERFACE_H_
25 #define _INTERFACES_PROTOBUFPEERINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(ProtobufPeerInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  private:
42  /** Internal data storage, do NOT modify! */
43  typedef struct {
44  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
45  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
46  int64_t peers[16]; /**< Currently active peers */
47  } ProtobufPeerInterface_data_t;
48 
49  ProtobufPeerInterface_data_t *data;
50 
51  public:
52  /* messages */
53  class CreatePeerMessage : public Message
54  {
55  private:
56  /** Internal data storage, do NOT modify! */
57  typedef struct {
58  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
59  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
60  char address[255]; /**< IP address or host name */
61  int32_t port; /**< Port to send to/receive on */
62  } CreatePeerMessage_data_t;
63 
64  CreatePeerMessage_data_t *data;
65 
66  public:
67  CreatePeerMessage(const char * ini_address, const int32_t ini_port);
70 
71  explicit CreatePeerMessage(const CreatePeerMessage *m);
72  /* Methods */
73  char * address() const;
74  void set_address(const char * new_address);
75  size_t maxlenof_address() const;
76  int32_t port() const;
77  void set_port(const int32_t new_port);
78  size_t maxlenof_port() const;
79  virtual Message * clone() const;
80  };
81 
83  {
84  private:
85  /** Internal data storage, do NOT modify! */
86  typedef struct {
87  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
88  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
89  char address[255]; /**< IP address or host name */
90  int32_t send_to_port; /**< Port to send to */
91  int32_t recv_on_port; /**< Port to receive on */
92  } CreatePeerLocalMessage_data_t;
93 
94  CreatePeerLocalMessage_data_t *data;
95 
96  public:
97  CreatePeerLocalMessage(const char * ini_address, const int32_t ini_send_to_port, const int32_t ini_recv_on_port);
100 
102  /* Methods */
103  char * address() const;
104  void set_address(const char * new_address);
105  size_t maxlenof_address() const;
106  int32_t send_to_port() const;
107  void set_send_to_port(const int32_t new_send_to_port);
108  size_t maxlenof_send_to_port() const;
109  int32_t recv_on_port() const;
110  void set_recv_on_port(const int32_t new_recv_on_port);
111  size_t maxlenof_recv_on_port() const;
112  virtual Message * clone() const;
113  };
114 
116  {
117  private:
118  /** Internal data storage, do NOT modify! */
119  typedef struct {
120  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
121  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
122  char address[255]; /**< IP address or host name */
123  int32_t port; /**< Port to send to/receive on */
124  char crypto_key[1024]; /**< Crypto key */
125  char cipher[255]; /**< Cipher name */
126  } CreatePeerCryptoMessage_data_t;
127 
128  CreatePeerCryptoMessage_data_t *data;
129 
130  public:
131  CreatePeerCryptoMessage(const char * ini_address, const int32_t ini_port, const char * ini_crypto_key, const char * ini_cipher);
134 
136  /* Methods */
137  char * address() const;
138  void set_address(const char * new_address);
139  size_t maxlenof_address() const;
140  int32_t port() const;
141  void set_port(const int32_t new_port);
142  size_t maxlenof_port() const;
143  char * crypto_key() const;
144  void set_crypto_key(const char * new_crypto_key);
145  size_t maxlenof_crypto_key() const;
146  char * cipher() const;
147  void set_cipher(const char * new_cipher);
148  size_t maxlenof_cipher() const;
149  virtual Message * clone() const;
150  };
151 
153  {
154  private:
155  /** Internal data storage, do NOT modify! */
156  typedef struct {
157  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
158  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
159  char address[255]; /**< IP address or host name */
160  int32_t send_to_port; /**< Port to send to */
161  int32_t recv_on_port; /**< Port to receive on */
162  char crypto_key[1024]; /**< Crypto key */
163  char cipher[255]; /**< Cipher name */
164  } CreatePeerLocalCryptoMessage_data_t;
165 
166  CreatePeerLocalCryptoMessage_data_t *data;
167 
168  public:
169  CreatePeerLocalCryptoMessage(const char * ini_address, const int32_t ini_send_to_port, const int32_t ini_recv_on_port, const char * ini_crypto_key, const char * ini_cipher);
172 
174  /* Methods */
175  char * address() const;
176  void set_address(const char * new_address);
177  size_t maxlenof_address() const;
178  int32_t send_to_port() const;
179  void set_send_to_port(const int32_t new_send_to_port);
180  size_t maxlenof_send_to_port() const;
181  int32_t recv_on_port() const;
182  void set_recv_on_port(const int32_t new_recv_on_port);
183  size_t maxlenof_recv_on_port() const;
184  char * crypto_key() const;
185  void set_crypto_key(const char * new_crypto_key);
186  size_t maxlenof_crypto_key() const;
187  char * cipher() const;
188  void set_cipher(const char * new_cipher);
189  size_t maxlenof_cipher() const;
190  virtual Message * clone() const;
191  };
192 
193  virtual bool message_valid(const Message *message) const;
194  private:
197 
198  public:
199  /* Methods */
200  int64_t * peers() const;
201  int64_t peers(unsigned int index) const;
202  void set_peers(unsigned int index, const int64_t new_peers);
203  void set_peers(const int64_t * new_peers);
204  size_t maxlenof_peers() const;
205  virtual Message * create_message(const char *type) const;
206 
207  virtual void copy_values(const Interface *other);
208  virtual const char * enum_tostring(const char *enumtype, int val) const;
209 
210 };
211 
212 } // end namespace fawkes
213 
214 #endif
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
CreatePeerCryptoMessage Fawkes BlackBoard Interface Message.
void set_cipher(const char *new_cipher)
Set cipher value.
virtual Message * clone() const
Clone this message.
void set_address(const char *new_address)
Set address value.
size_t maxlenof_cipher() const
Get maximum length of cipher value.
void set_port(const int32_t new_port)
Set port value.
size_t maxlenof_crypto_key() const
Get maximum length of crypto_key value.
size_t maxlenof_port() const
Get maximum length of port value.
void set_crypto_key(const char *new_crypto_key)
Set crypto_key value.
size_t maxlenof_address() const
Get maximum length of address value.
CreatePeerLocalCryptoMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_send_to_port() const
Get maximum length of send_to_port value.
size_t maxlenof_recv_on_port() const
Get maximum length of recv_on_port value.
void set_send_to_port(const int32_t new_send_to_port)
Set send_to_port value.
void set_crypto_key(const char *new_crypto_key)
Set crypto_key value.
size_t maxlenof_cipher() const
Get maximum length of cipher value.
void set_address(const char *new_address)
Set address value.
void set_recv_on_port(const int32_t new_recv_on_port)
Set recv_on_port value.
size_t maxlenof_crypto_key() const
Get maximum length of crypto_key value.
void set_cipher(const char *new_cipher)
Set cipher value.
size_t maxlenof_address() const
Get maximum length of address value.
CreatePeerLocalMessage Fawkes BlackBoard Interface Message.
void set_send_to_port(const int32_t new_send_to_port)
Set send_to_port value.
void set_recv_on_port(const int32_t new_recv_on_port)
Set recv_on_port value.
size_t maxlenof_send_to_port() const
Get maximum length of send_to_port value.
void set_address(const char *new_address)
Set address value.
size_t maxlenof_address() const
Get maximum length of address value.
size_t maxlenof_recv_on_port() const
Get maximum length of recv_on_port value.
virtual Message * clone() const
Clone this message.
CreatePeerMessage Fawkes BlackBoard Interface Message.
size_t maxlenof_port() const
Get maximum length of port value.
virtual Message * clone() const
Clone this message.
size_t maxlenof_address() const
Get maximum length of address value.
void set_address(const char *new_address)
Set address value.
void set_port(const int32_t new_port)
Set port value.
ProtobufPeerInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
virtual Message * create_message(const char *type) const
Create message based on type name.
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
size_t maxlenof_peers() const
Get maximum length of peers value.
int64_t * peers() const
Get peers value.
void set_peers(unsigned int index, const int64_t new_peers)
Set peers value at given index.
virtual void copy_values(const Interface *other)
Copy values from other interface.
Fawkes library namespace.