52 printf(
"Usage: agent_forward [{ipaddresses1} {ipaddress2} {ipaddress3} ...]\n");
74 for (uint16_t
i=1;
i<argc; ++
i)
86 for (uint16_t i=0; i<
sendchan.size(); ++
i)
91 printf(
"Could not open incoming socket for forwarding: %d\n", iretn);
96 thread thread_forwarding;
99 thread thread_opening;
109 iretn =
agent->
readring(mess, Agent::AgentMessage::ALL, 1., Agent::Where::TAIL);
113 vector <uint8_t> post;
114 post.resize(mess.
jdata.length() + 3 + (mess.
meta.
type < Agent::AgentMessage::BINARY ? mess.
adata.size() : mess.
bdata.size()));
115 post[0] = static_cast <uint8_t>(mess.
meta.
type);
116 post[1] = static_cast <uint8_t>(mess.
jdata.length() % 256);
117 post[2] = static_cast <uint8_t>(mess.
jdata.length() / 256);
118 std::copy(mess.
jdata.begin(), mess.
jdata.end(), post.begin() + 3);
122 if (mess.
meta.
type < Agent::AgentMessage::BINARY)
124 if (mess.
adata.size())
126 std::copy(mess.
adata.begin(), mess.
adata.end(), post.begin() + mess.
jdata.length() + 3);
131 if (mess.
bdata.size())
133 std::copy(mess.
bdata.begin(), mess.
bdata.end(), post.begin() + mess.
jdata.length() + 3);
139 for (uint16_t i=0; i<
sendchan.size(); ++
i)
160 thread_forwarding.join();
161 thread_opening.join();
162 for (uint16_t i=0; i<
sendchan.size(); ++
i)
uint16_t debug_level
Flag for level of debugging, keep it public so that it can be controlled from the outside...
Definition: agentclass.h:362
FILE * get_debug_fd(double mjd=0.)
Definition: agentclass.cpp:2645
static socket_channel rcvchan
Definition: agent_forward.cpp:38
Agent socket using Unicast UDP.
vector< uint8_t > bdata
Definition: agentclass.h:275
int i
Definition: rw_test.cpp:37
string getNode()
Listen for heartbeat.
Definition: agentclass.cpp:2607
int32_t request_add_forward(string &req, string &, Agent *)
Definition: agent_forward.cpp:227
int iretn
Definition: rw_test.cpp:37
int32_t wait(State state=State::RUN, double waitsec=10.)
Definition: agentclass.cpp:398
int32_t socket_sendto(socket_channel &channel, const string buffer, int flags)
Definition: socketlib.cpp:737
string adata
Definition: agentclass.h:276
#define SOCKET_TALK
Talk followed by optional listen (sendto address)
Definition: socketlib.h:82
string cosmos_error_string(int32_t cosmos_errno)
Definition: cosmos-errno.cpp:45
uint16_t running()
Check if we're supposed to be running.
Definition: agentclass.cpp:391
#define AGENTRECVPORT
Default RECV port.
Definition: agentclass.h:200
string getAgent()
Definition: agentclass.cpp:2609
int32_t add_request(string token, external_request_function function, string synopsis="", string description="")
Add internal request to Agent request list with description and synopsis.
Definition: agentclass.cpp:312
Definition: agentclass.h:139
Definition: socketlib.h:115
#define SOCKET_BLOCKING
Blocking Agent.
Definition: socketlib.h:78
int32_t shutdown()
Shutdown agent gracefully.
Definition: agentclass.cpp:366
#define AGENTRCVTIMEO
Default AGENT socket RCVTIMEO (100 msec)
Definition: agentclass.h:208
Storage for messages.
Definition: agentclass.h:272
double data_ctime(string path)
Definition: datalib.cpp:1910
void opening_loop()
Definition: agent_forward.cpp:169
void forwarding_loop()
Definition: agent_forward.cpp:188
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65
pollstruc meta
Definition: agentclass.h:274
string jdata
Definition: agentclass.h:277
string utc2iso8601(double utc)
ISO 8601 version of time.
Definition: timelib.cpp:1286
AgentMessage type
Definition: agentclass.h:266
#define SOCKET_LISTEN
Listen followed by optional talk (recvfrom INADDRANY)
Definition: socketlib.h:84
#define AGENTMAXBUFFER
Maximum AGENT transfer buffer size.
Definition: jsondef.h:438
static Agent * agent
Definition: agent_forward.cpp:37
int32_t socket_open(socket_channel *channel, NetworkType ntype, const char *address, uint16_t port, uint16_t role, bool blocking, uint32_t usectimeo, uint32_t rcvbuf, uint32_t sndbuf)
Open UDP socket.
Definition: socketlib.cpp:51
string mjd2iso8601(double mjd)
Definition: timelib.cpp:1316
int32_t readring(messstruc &message, AgentMessage type=Agent::AgentMessage::ALL, float waitsec=1., Where where=Where::TAIL, string proc="", string node="")
Check Ring for message.
Definition: agentclass.cpp:2395
static vector< socket_channel > sendchan
Definition: agent_forward.cpp:39