ModSelectWin32.cc \
TcpAcceptor.cc \
TcpAcceptor.h \
+ UdpOpenDialer.h \
Write.cc \
Write.h \
\
--- /dev/null
+#ifndef SQUID_COMM_UDPOPENDIALER_H
+#define SQUID_COMM_UDPOPENDIALER_H
+
+#include "ipc/StartListening.h"
+
+namespace Comm
+{
+
+/// dials a UDP port-opened call
+class UdpOpenDialer: public CallDialer,
+ public Ipc::StartListeningCb
+{
+public:
+ typedef void (*Handler)((const Comm::ConnectionPointer &conn, int errNo);
+ UdpOpenDialer(Handler aHandler): handler(aHandler) {}
+
+ virtual void print(std::ostream &os) const { startPrint(os) << ')'; }
+ virtual bool canDial(AsyncCall &) const { return true; }
+ virtual void dial(AsyncCall &) { (handler)(conn, errNo); }
+
+public:
+ Handler handler;
+};
+
+} // namespace Comm
+
+#endif /* SQUID_COMM_UDPOPENDIALER_H */
#include "acl/Acl.h"
#include "comm.h"
#include "comm/Loops.h"
+#include "comm/UdpOpenDialer.h"
#include "htcp.h"
#include "http.h"
#include "HttpRequest.h"
#include "icmp/net_db.h"
-#include "ipc/StartListening.h"
#include "ip/tools.h"
#include "MemBuf.h"
#include "SquidTime.h"
#include "StoreClient.h"
#include "compat/xalloc.h"
-/// dials htcpIncomingConnectionOpened call
-class HtcpListeningStartedDialer: public CallDialer,
- public Ipc::StartListeningCb
-{
-public:
- typedef void (*Handler)(int errNo);
- HtcpListeningStartedDialer(Handler aHandler): handler(aHandler) {}
-
- virtual void print(std::ostream &os) const { startPrint(os) << ')'; }
- virtual bool canDial(AsyncCall &) const { return true; }
- virtual void dial(AsyncCall &) { (handler)(errNo); }
-
-public:
- Handler handler;
-};
-
typedef struct _Countstr Countstr;
typedef struct _htcpHeader htcpHeader;
RR_RESPONSE
};
-static void htcpIncomingConnectionOpened(int errNo);
+static void htcpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo);
static uint32_t msg_id_counter = 0;
static Comm::ConnectionPointer htcpOutgoingConn = NULL;
AsyncCall::Pointer call = asyncCall(31, 2,
"htcpIncomingConnectionOpened",
- HtcpListeningStartedDialer(&htcpIncomingConnectionOpened));
+ Comm::UdpOpenDialer(&htcpIncomingConnectionOpened));
Ipc::StartListening(SOCK_DGRAM,
IPPROTO_UDP,
}
static void
-htcpIncomingConnectionOpened(int)
+htcpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int)
{
- if (!Comm::IsConnOpen(htcpIncomingConn))
+ if (!Comm::IsConnOpen(conn))
fatal("Cannot open HTCP Socket");
- Comm::SetSelect(htcpIncomingConn->fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
+ Comm::SetSelect(conn->fd, COMM_SELECT_READ, htcpRecv, NULL, 0);
- debugs(31, DBG_CRITICAL, "Accepting HTCP messages on " << htcpIncomingConn->local);
+ debugs(31, DBG_CRITICAL, "Accepting HTCP messages on " << conn->local);
if (Config.Addrs.udp_outgoing.IsNoAddr()) {
- htcpOutgoingConn = htcpIncomingConn;
+ htcpOutgoingConn = conn;
debugs(31, DBG_IMPORTANT, "Sending HTCP messages from " << htcpOutgoingConn->local);
}
}
#include "squid-old.h"
#include "Store.h"
#include "comm.h"
+#include "comm/Connection.h"
#include "comm/Loops.h"
+#include "comm/UdpOpenDialer.h"
#include "ICP.h"
-#include "comm/Connection.h"
#include "HttpRequest.h"
#include "acl/FilledChecklist.h"
#include "acl/Acl.h"
#include "icmp/net_db.h"
#include "ip/Address.h"
#include "ip/tools.h"
-#include "ipc/StartListening.h"
#include "ipcache.h"
#include "rfc1738.h"
-/// dials icpIncomingConnectionOpened call
-class IcpListeningStartedDialer: public CallDialer,
- public Ipc::StartListeningCb
-{
-public:
- typedef void (*Handler)(int errNo);
- IcpListeningStartedDialer(Handler aHandler):
- handler(aHandler) {}
-
- virtual void print(std::ostream &os) const { startPrint(os) << ')'; }
- virtual bool canDial(AsyncCall &) const { return true; }
- virtual void dial(AsyncCall &) { (handler)(errNo); }
-
-public:
- Handler handler;
-};
-
-static void icpIncomingConnectionOpened(int errNo);
+static void icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo);
/// \ingroup ServerProtocolICPInternal2
static void icpLogIcp(const Ip::Address &, log_type, int, const char *, int);
AsyncCall::Pointer call = asyncCall(12, 2,
"icpIncomingConnectionOpened",
- IcpListeningStartedDialer(&icpIncomingConnectionOpened));
+ Comm::UdpOpenDialer(&icpIncomingConnectionOpened));
Ipc::StartListening(SOCK_DGRAM,
IPPROTO_UDP,
}
static void
-icpIncomingConnectionOpened(int errNo)
+icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo)
{
- if (!Comm::IsConnOpen(icpIncomingConn))
+ if (!Comm::IsConnOpen(conn))
fatal("Cannot open ICP Port");
- Comm::SetSelect(icpIncomingConn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
+ Comm::SetSelect(conn->fd, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
for (const wordlist *s = Config.mcast_group_list; s; s = s->next)
- ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); // XXX: pass the icpIncomingConn for mcastJoinGroups usage.
+ ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); // XXX: pass the conn for mcastJoinGroups usage.
- debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << icpIncomingConn->local);
+ debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << conn->local);
- fd_note(icpIncomingConn->fd, "Incoming ICP port");
+ fd_note(conn->fd, "Incoming ICP port");
if (Config.Addrs.udp_outgoing.IsNoAddr()) {
- icpOutgoingConn = icpIncomingConn;
+ icpOutgoingConn = conn;
debugs(12, DBG_IMPORTANT, "Sending ICP messages from " << icpOutgoingConn->local);
}
}
#include "snmp_core.h"
#include "snmp/Forwarder.h"
-
-/// dials snmpConnectionOpened call
-class SnmpListeningStartedDialer: public CallDialer,
- public Ipc::StartListeningCb
-{
-public:
- typedef void (*Handler)(const Comm::ConnectionPointer &conn, int errNo);
- SnmpListeningStartedDialer(Handler aHandler): handler(aHandler) {}
-
- virtual void print(std::ostream &os) const { startPrint(os) << ')'; }
-
- virtual bool canDial(AsyncCall &) const { return true; }
- virtual void dial(AsyncCall &) { (handler)(conn, errNo); }
-
-public:
- Handler handler;
-};
-
-
static void snmpPortOpened(const Comm::ConnectionPointer &conn, int errNo);
-
mib_tree_entry *mib_tree_head;
mib_tree_entry *mib_tree_last;
}
AsyncCall::Pointer call = asyncCall(49, 2, "snmpIncomingConnectionOpened",
- SnmpListeningStartedDialer(&snmpPortOpened));
+ Comm::UdpOpenDialer(&snmpPortOpened));
Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, snmpIncomingConn, Ipc::fdnInSnmpSocket, call);
if (!Config.Addrs.snmp_outgoing.IsNoAddr()) {
snmpOutgoingConn->local.SetIPv4();
}
AsyncCall::Pointer call = asyncCall(49, 2, "snmpOutgoingConnectionOpened",
- SnmpListeningStartedDialer(&snmpPortOpened));
+ Comm::UdpOpenDialer(&snmpPortOpened));
Ipc::StartListening(SOCK_DGRAM, IPPROTO_UDP, snmpOutgoingConn, Ipc::fdnOutSnmpSocket, call);
} else {
snmpOutgoingConn = snmpIncomingConn;