forked from ValdikSS/openvpn-radiusplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IpcSocket.h
73 lines (57 loc) · 1.78 KB
/
IpcSocket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* radiusplugin -- An OpenVPN plugin for do radius authentication
* and accounting.
*
* Copyright (C) 2005 EWE TEL GmbH/Ralf Luebben <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _IPCSOCKET_H_
#define _IPCSOCKET_H_
//#include "radiusplugin.h"
#include <string>
#include <cstring>
#include "User.h"
#include "Exception.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
typedef unsigned char Octet;
/** This class implements the inter process communication
* in this software. Different datatypes can the send over the
* socket: string, int , code (8 bit int).
* For the strings additional the length is sent before the string
* is sent itself. So you don't need to know the length, if you receive
* a string.
*/
class IpcSocket
{
private:
int socket; /**The socket number.*/
public:
IpcSocket();
IpcSocket(int);
~IpcSocket();
int getSocket(void);
void setSocket(int);
void send(string);
void send(int);
void send(Octet *, ssize_t);
int recvInt(void);
string recvStr(void);
void recvBuf(User *);
};
#endif //_IPCSOCKET_H_