mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Use a single UDP port in the server.
Several modifications to use a single UDP port in the server. This is currently done using a hack, i.e., pass the UDP socket to worker, close it on the main server and then re-open it (using REUSEADDR). Also several updates in TUN handling to allow more than one clients connecting.
This commit is contained in:
+13
-4
@@ -157,8 +157,7 @@ static int recv_auth_reply(worker_st *ws)
|
||||
uint8_t cmd = 0;
|
||||
struct cmd_auth_reply_st resp;
|
||||
struct msghdr hdr;
|
||||
int ret;
|
||||
|
||||
int ret, cmdlen;
|
||||
union {
|
||||
struct cmsghdr cm;
|
||||
char control[CMSG_SPACE(sizeof(int))];
|
||||
@@ -179,15 +178,25 @@ static int recv_auth_reply(worker_st *ws)
|
||||
hdr.msg_controllen = sizeof(control_un.control);
|
||||
|
||||
ret = recvmsg( ws->cmd_fd, &hdr, 0);
|
||||
if (ret < sizeof(resp)+1) {
|
||||
oclog(ws, LOG_ERR, "Received incorrect data (%d, expected %d) from main", ret, (int)sizeof(resp)+1);
|
||||
|
||||
cmdlen = ret;
|
||||
|
||||
if (cmdlen < 2) {
|
||||
oclog(ws, LOG_ERR, "Received incorrect data (%d, expected %d) from main", cmdlen, (int)2);
|
||||
return -1;
|
||||
}
|
||||
if (cmd != AUTH_REP)
|
||||
return -1;
|
||||
|
||||
cmdlen--;
|
||||
|
||||
switch(resp.reply) {
|
||||
case REP_AUTH_OK:
|
||||
if (cmdlen < sizeof(resp)) {
|
||||
oclog(ws, LOG_ERR, "Received incorrect data (%d, expected %d) from main", ret, (int)sizeof(resp)+1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( (cmptr = CMSG_FIRSTHDR(&hdr)) != NULL && cmptr->cmsg_len == CMSG_LEN(sizeof(int))) {
|
||||
if (cmptr->cmsg_level != SOL_SOCKET)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user