summaryrefslogtreecommitdiff
path: root/apps/drwho/SM_Server.cpp
blob: 6fb7569a5cdf0ea9b38b728ccaf2a88c630960a9 (plain)
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
// $Id$

#include "Options.h"
#include "PMS_All.h"
#include "PMS_Flo.h"
#include "PMS_Usr.h"
#include "PMS_Ruser.h"
#include "SM_Server.h"

int 
SM_Server::demux (char *packet, int &packet_length)
{
  switch (GET_PACKET_TYPE (packet))
    {
    case Options::PROTO_USR:
      ACE_NEW_RETURN (this->pm_server,
                      PMS_Usr,
                      -1);
      break;
    case Options::PROTO_ALL:
      ACE_NEW_RETURN (this->pm_server,
                      PMS_All,
                      -1);
      break;
    case Options::PROTO_FLO:
      ACE_NEW_RETURN (this->pm_server,
                      PMS_Flo,
                      -1);
      break;
    case Options::PROTO_RUSER:
      ACE_NEW_RETURN (this->pm_server,
                      PMS_Ruser,
                      -1);
      break;
    default:
      ACE_DEBUG ((LM_DEBUG, 
                  "%s: bad protocol\n",
                  Options::program_name));
      return -1;
    }

  packet_length = SUBTRACT_PACKET_TYPE (packet_length);

  if (pm_server->decode (SKIP_PACKET_TYPE (packet),
                         packet_length) < 0)
    return -1;

  if (pm_server->process () < 0)
    return -1;

  return 1;
}

int 
SM_Server::mux (char *packet,
                int &packet_length)
{
  return pm_server->encode (packet, packet_length);
}

SM_Server::SM_Server (void)
{
}

SM_Server::~SM_Server (void)
{
}