2 Copyright (C) 1998-2010 Paul Barton-Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __libmidi_ipmidi_port_h__
20 #define __libmidi_ipmidi_port_h__
24 #if defined(PLATFORM_WINDOWS)
26 #elif defined(__FreeBSD__) || defined(__OpenBSD__)
27 #include <netinet/in.h>
28 #include <sys/socket.h>
29 #if defined(__FreeBSD__)
30 #include <sys/_sockaddr_storage.h>
32 #include <arpa/inet.h>
33 #include <netinet/ip_carp.h>
34 #include <sys/types.h>
36 #include <sys/socket.h>
38 #include <net/route.h>
40 #include <arpa/inet.h>
44 #include <glibmm/threads.h>
46 #include "pbd/xml++.h"
47 #include "pbd/crossthread.h"
48 #include "pbd/signals.h"
49 #include "pbd/ringbuffer.h"
51 #include "midi++/libmidi_visibility.h"
52 #include "midi++/types.h"
53 #include "midi++/parser.h"
54 #include "midi++/port.h"
58 class LIBMIDIPP_API IPMIDIPort : public Port {
60 IPMIDIPort (int base_port = lowest_ipmidi_port_default, const std::string& ifname = std::string());
61 IPMIDIPort (const XMLNode&);
64 XMLNode& get_state () const;
65 void set_state (const XMLNode&);
67 int write (const byte *msg, size_t msglen, timestamp_t timestamp);
68 int read (byte *buf, size_t bufsize);
69 void parse (framecnt_t timestamp);
70 int selectable () const;
72 static const int lowest_ipmidi_port_default = 21928;
77 struct sockaddr_in addrout;
78 Glib::Threads::Mutex write_lock;
80 bool open_sockets (int base_port, const std::string& ifname);
81 void close_sockets ();
83 void init (std::string const &, Flags);
88 #endif // __libmidi_ipmidi_port_h__