2009-09-11 17:58:37 +02:00
|
|
|
/*
|
2010-01-05 08:29:35 +01:00
|
|
|
Copyright (c) 2007-2010 iMatix Corporation
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
This file is part of 0MQ.
|
|
|
|
|
|
|
|
0MQ is free software; you can redistribute it and/or modify it under
|
2010-10-30 15:08:28 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by
|
2009-09-11 17:58:37 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
0MQ is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-10-30 15:08:28 +02:00
|
|
|
GNU Lesser General Public License for more details.
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2010-10-30 15:08:28 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2009-09-11 17:58:37 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PGM_SOCKET_HPP_INCLUDED__
|
|
|
|
#define __PGM_SOCKET_HPP_INCLUDED__
|
|
|
|
|
|
|
|
#include "platform.hpp"
|
|
|
|
|
2009-09-24 16:23:49 +02:00
|
|
|
#if defined ZMQ_HAVE_OPENPGM
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2009-10-06 12:57:24 +02:00
|
|
|
#ifdef ZMQ_HAVE_WINDOWS
|
|
|
|
#include "windows.hpp"
|
2009-09-11 17:58:37 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-23 14:35:02 +02:00
|
|
|
#define __PGM_WININT_H__
|
2009-10-06 12:57:24 +02:00
|
|
|
#include <pgm/pgm.h>
|
|
|
|
|
2011-02-18 17:57:59 +01:00
|
|
|
// TODO: OpenPGM redefines bool -- remove this once OpenPGM is fixed.
|
|
|
|
#if defined bool
|
|
|
|
#undef bool
|
|
|
|
#endif
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
#include "options.hpp"
|
|
|
|
|
|
|
|
namespace zmq
|
|
|
|
{
|
|
|
|
// Encapsulates PGM socket.
|
|
|
|
class pgm_socket_t
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2010-10-30 16:17:08 +02:00
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// If receiver_ is true PGM transport is not generating SPM packets.
|
|
|
|
pgm_socket_t (bool receiver_, const options_t &options_);
|
|
|
|
|
|
|
|
// Closes the transport.
|
|
|
|
~pgm_socket_t ();
|
|
|
|
|
|
|
|
// Initialize PGM network structures (GSI, GSRs).
|
2009-09-16 15:36:38 +02:00
|
|
|
int init (bool udp_encapsulation_, const char *network_);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Get receiver fds and store them into user allocated memory.
|
2009-12-13 11:27:43 +01:00
|
|
|
void get_receiver_fds (int *receive_fd_, int *waiting_pipe_fd_);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Get sender and receiver fds and store it to user allocated
|
|
|
|
// memory. Receive fd is used to process NAKs from peers.
|
2009-12-13 11:27:43 +01:00
|
|
|
void get_sender_fds (int *send_fd_, int *receive_fd_,
|
2010-01-05 11:22:14 +01:00
|
|
|
int *rdata_notify_fd_, int *pending_notify_fd_);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Send data as one APDU, transmit window owned memory.
|
|
|
|
size_t send (unsigned char *data_, size_t data_len_);
|
|
|
|
|
2009-12-28 11:51:06 +01:00
|
|
|
// Returns max tsdu size without fragmentation.
|
|
|
|
size_t get_max_tsdu_size ();
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// Receive data from pgm socket.
|
2009-09-22 15:12:51 +02:00
|
|
|
ssize_t receive (void **data_, const pgm_tsi_t **tsi_);
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2010-09-28 22:46:56 +02:00
|
|
|
long get_rx_timeout ();
|
|
|
|
long get_tx_timeout ();
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// POLLIN on sender side should mean NAK or SPMR receiving.
|
|
|
|
// process_upstream function is used to handle such a situation.
|
2009-12-13 11:27:43 +01:00
|
|
|
void process_upstream ();
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2009-12-13 11:27:43 +01:00
|
|
|
private:
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2010-10-30 16:17:08 +02:00
|
|
|
// OpenPGM transport.
|
2010-09-28 16:35:29 +02:00
|
|
|
pgm_sock_t* sock;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
2010-09-28 22:46:56 +02:00
|
|
|
int last_rx_status, last_tx_status;
|
|
|
|
|
2009-09-22 15:12:51 +02:00
|
|
|
// Associated socket options.
|
|
|
|
options_t options;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// true when pgm_socket should create receiving side.
|
|
|
|
bool receiver;
|
|
|
|
|
2009-12-28 11:51:06 +01:00
|
|
|
// Array of pgm_msgv_t structures to store received data
|
2009-09-11 17:58:37 +02:00
|
|
|
// from the socket (pgm_transport_recvmsgv).
|
|
|
|
pgm_msgv_t *pgm_msgv;
|
|
|
|
|
2009-12-28 11:51:06 +01:00
|
|
|
// Size of pgm_msgv array.
|
|
|
|
size_t pgm_msgv_len;
|
|
|
|
|
2009-09-11 17:58:37 +02:00
|
|
|
// How many bytes were read from pgm socket.
|
2009-09-25 17:50:12 +02:00
|
|
|
size_t nbytes_rec;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// How many bytes were processed from last pgm socket read.
|
2009-09-25 17:50:12 +02:00
|
|
|
size_t nbytes_processed;
|
2009-09-11 17:58:37 +02:00
|
|
|
|
|
|
|
// How many messages from pgm_msgv were already sent up.
|
2009-09-25 17:50:12 +02:00
|
|
|
size_t pgm_msgv_processed;
|
2009-09-11 17:58:37 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2009-10-06 12:57:24 +02:00
|
|
|
|