]> git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Messages.h
Switched from sendto/recvfrom to sendmsg/recvmsg for UDS I/O. Replaced
[thirdparty/squid.git] / src / ipc / Messages.h
1 /*
2 * $Id$
3 *
4 * DEBUG: section 54 Interprocess Communication
5 *
6 */
7
8 #ifndef SQUID_IPC_MESSAGES_H
9 #define SQUID_IPC_MESSAGES_H
10
11 #include <sys/types.h>
12 #include <sys/socket.h>
13
14 /// Declare IPC messages. These classes translate between high-level
15 /// information and low-level TypedMsgHdr (i.e., struct msghdr) buffers.
16
17 namespace Ipc
18 {
19
20 class TypedMsgHdr;
21
22 typedef enum { mtNone = 0, mtRegistration, mtDescriptor } MessageType;
23
24 /// Strand location details
25 class StrandCoord {
26 public:
27 StrandCoord(); ///< unknown location
28 StrandCoord(int akidId, pid_t aPid); ///< from registrant
29 explicit StrandCoord(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
30 void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
31
32 public:
33 int kidId; ///< internal Squid process number
34 pid_t pid; ///< OS process or thread identifier
35 };
36
37 /// a [socket] descriptor information
38 class Descriptor
39 {
40 public:
41 explicit Descriptor(int fd); ///< from descriptor sender
42 explicit Descriptor(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
43 void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
44
45 public:
46 int fd; ///< raw descriptor value
47 };
48
49
50 } // namespace Ipc;
51
52
53 #endif /* SQUID_IPC_MESSAGES_H */