Ejemplo n.º 1
0
static void InstallService() {
  SC_HANDLE hSCManager;
  int status;
  RemoveService();
  hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
  if (hSCManager) {
    SC_HANDLE hService;
    char *pgm;
    char *cmd;
    static const char* multi_opt="--multi";
    static const char* server_opt="--server";
    static const char* data_opt="";
    char *opts = GetMulti() ? (GetContextSwitching() ? "--multi" : "--server") : "";
    SERVICE_DESCRIPTION sd;
    LPTSTR description=(LPTSTR)malloc(4096);
    if (GetMulti()) {
      if (GetContextSwitching()) {
	opts=multi_opt;
	wsprintf(description,TEXT("MDSplus data service listening on port %s.\nPermits multiple connections each with own tdi and tree context\n"),
		 GetPortname());
      } else {
	opts=server_opt;
	wsprintf(description,TEXT("MDSplus data service listening on port %s.\nPermits multiple connections with shared tdi and tree context\n"),
		 GetPortname());
      }
    } else {
      opts=data_opt;
      wsprintf(description,TEXT("MDSplus data service listening on port %s.\nEach connections will spawn a private server.\n"),
	       GetPortname());
    }
    sd.lpDescription=description;
    _get_pgmptr(&pgm);
    cmd = (char *)malloc(strlen(pgm)+strlen(GetPortname())+strlen(GetHostfile())+100);
    sprintf(cmd,"%s --port=%s --hostfile=\"%s\" %s",pgm,GetPortname(),GetHostfile(),opts);
    hService = CreateService(hSCManager, ServiceName(1), ServiceName(0), SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
			     SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, cmd, NULL, NULL, NULL, NULL, NULL);
    if (hService == NULL)
      status = GetLastError();
	else {
      ChangeServiceConfig2(hService,SERVICE_CONFIG_DESCRIPTION,&sd);
	  if (GetMulti()) {
		SERVICE_FAILURE_ACTIONS sfa;
		SC_ACTION actions[] = {{SC_ACTION_RESTART,5000}};
		sfa.dwResetPeriod = INFINITE;
		sfa.lpRebootMsg = NULL;
		sfa.lpCommand = NULL;
		sfa.cActions = 1;
		sfa.lpsaActions=actions;
		status = ChangeServiceConfig2(hService,SERVICE_CONFIG_FAILURE_ACTIONS, &sfa);
		status = GetLastError();
	  }
	}
    free(description);
    free(cmd);
    if (hService)
      CloseServiceHandle(hService);
    CloseServiceHandle(hSCManager);
  }
}
Ejemplo n.º 2
0
static udp_pair *
NewUTP(
    struct ip *pip,
    struct udphdr *pudp)
{
    udp_pair *pup;

    if (0) {
	 printf("trace.c:NewUTP() calling MakeUdpPair()\n");
    }
    pup = MakeUdpPair();
    ++num_udp_pairs;
    /* make a new one, if possible */
    if ((num_udp_pairs+1) >= max_udp_pairs) {
	MoreUdpPairs(num_udp_pairs+1);
    }

    /* create a new UDP pair record and remember where you put it */
    utp[num_udp_pairs] = pup;
    pup->ignore_pair=ignore_pairs[num_udp_pairs];


    /* grab the address from this packet */
    CopyAddr(&pup->addr_pair,
	     pip, ntohs(pudp->uh_sport), ntohs(pudp->uh_dport));

    /* data structure setup */
    pup->a2b.pup = pup;
    pup->b2a.pup = pup;
    pup->a2b.ptwin = &pup->b2a;
    pup->b2a.ptwin = &pup->a2b;

    /* fill in connection name fields */
    pup->a2b.host_letter = strdup(NextHostLetter());
    pup->b2a.host_letter = strdup(NextHostLetter());
    pup->a_hostname = strdup(HostName(pup->addr_pair.a_address));
    pup->a_portname = strdup(ServiceName(pup->addr_pair.a_port));
    pup->a_endpoint =
	strdup(EndpointName(pup->addr_pair.a_address,
			    pup->addr_pair.a_port));
    pup->b_hostname = strdup(HostName(pup->addr_pair.b_address));
    pup->b_portname = strdup(ServiceName(pup->addr_pair.b_port));
    pup->b_endpoint = 
	strdup(EndpointName(pup->addr_pair.b_address,
			    pup->addr_pair.b_port));

    pup->filename = cur_filename;

    return(pup);
}
Ejemplo n.º 3
0
static void InitializeService() {
  char name[120];
  hService = RegisterServiceCtrlHandler(ServiceName(1),(LPHANDLER_FUNCTION) serviceHandler);
  sprintf(name,"MDSIP_%s_SHUTDOWN",GetPortname());
  shutdownEventHandle=CreateEvent(NULL,FALSE,FALSE,name);
  SetThisServiceStatus(SERVICE_START_PENDING,1000);
}
Ejemplo n.º 4
0
int main( int argc, char **argv) {
  int x_argc;
  char **x_argv;
  Options options[] = {{"i","install",0,0,0},
		       {"r","remove",0,0,0},
		       {"p","port",1,0,0},
		       {0,0,0,0,0}};
  ParseStdArgs(argc, argv, &x_argc, &x_argv);
  ParseCommand(x_argc,x_argv,options,1,&extra_argc,&extra_argv);
  if (options[2].present && options[2].value)
    SetPortname(options[2].value);
  else if (GetPortname() == 0)
    SetPortname("mdsip");
  if (options[0].present) {
	InstallService();
	exit(0);
  } else if (options[1].present) {
	RemoveService();
	exit(0);
  } else {
      SERVICE_TABLE_ENTRY srvcTable[] = {{ServiceName(1),(LPSERVICE_MAIN_FUNCTION)ServiceMain},{NULL,NULL}};
      WSADATA wsaData;
      WORD wVersionRequested;
      wVersionRequested = MAKEWORD(1,1);
      WSAStartup(wVersionRequested,&wsaData);
      StartServiceCtrlDispatcher(srvcTable);
  }
  return 1;
}
Ejemplo n.º 5
0
static void RemoveService() {
  SC_HANDLE hSCManager = OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE); 
  if (hSCManager) {
    SC_HANDLE hService = OpenService(hSCManager, ServiceName(1), DELETE);
    if (hService) {
      BOOL status;
      status = DeleteService(hService);
      status = CloseServiceHandle(hService);
    }
    CloseServiceHandle(hSCManager);
  }
}
    /** Default constructor can initialize the service name, types of control
	accepted from the NT Service Control Manager, the type of service, and
	the location of Event Log message resources. See vNTEventLog for very
	important information on the hMessageResources parameter.*/
	VNTService(	VSTRING_CONST	pszServiceName = NULL,
				VDWORD			nControlsAccepted =
									SERVICE_ACCEPT_STOP |
									SERVICE_ACCEPT_SHUTDOWN,
				VDWORD			nServiceType =
									SERVICE_WIN32_OWN_PROCESS,
				HINSTANCE		hMessageResources = NULL)
	{
		/* Copy the address of the current object so we can
		access it from the static member callback functions.*/
		m_pThis = this;

		/* Initialize class members.*/
		VZEROSTRUCT(m_Status);
		m_hServiceStatus =				NULL;
		m_nControlsAccepted =			nControlsAccepted;
		m_Status.dwServiceType =		nServiceType;
		m_Status.dwCurrentState =		SERVICE_STOPPED;
		m_Status.dwControlsAccepted =	nControlsAccepted;

		/* Initialize now?*/
		if ( pszServiceName )
			ServiceName(pszServiceName, hMessageResources);
	}
// Copyright 2018 bitHeads, Inc. All Rights Reserved.

#include "BCClientPluginPrivatePCH.h"
#include "ServiceName.h"

ServiceName::ServiceName(const FString &name)
{
    _value = name;
}

const ServiceName ServiceName::None = ServiceName("None");

const ServiceName ServiceName::AuthenticateV2 = ServiceName("authenticationV2");
const ServiceName ServiceName::Identity = ServiceName("identity");
const ServiceName ServiceName::Currency = ServiceName("currency");
const ServiceName ServiceName::FriendData = ServiceName("friendData");
const ServiceName ServiceName::HeartBeat = ServiceName("heartbeat");

const ServiceName ServiceName::PushNotification = ServiceName("pushNotification");
const ServiceName ServiceName::GlobalGameStatistics = ServiceName("globalGameStatistics");
const ServiceName ServiceName::PlayerStatisticsEvent = ServiceName("playerStatisticsEvent");
const ServiceName ServiceName::Twitter = ServiceName("twitter");
const ServiceName ServiceName::Steam = ServiceName("steam");

const ServiceName ServiceName::Presence = ServiceName("presence");
const ServiceName ServiceName::PlayerState = ServiceName("playerState");
const ServiceName ServiceName::Entity = ServiceName("entity");
const ServiceName ServiceName::GlobalEntity = ServiceName("globalEntity");
const ServiceName ServiceName::Friend = ServiceName("friend");
const ServiceName ServiceName::Time = ServiceName("time");
const ServiceName ServiceName::Tournament = ServiceName("tournament");
Ejemplo n.º 8
0
namespace BrainCloud
{
    const ServiceName ServiceName::None = ServiceName("None");

    const ServiceName ServiceName::Authenticate = ServiceName("authentication");
    const ServiceName ServiceName::AuthenticateV2 = ServiceName("authenticationV2");
    const ServiceName ServiceName::Identity = ServiceName("identity");
    const ServiceName ServiceName::Currency = ServiceName("currency");
    const ServiceName ServiceName::FriendData = ServiceName("friendData");
    const ServiceName ServiceName::HeartBeat = ServiceName("heartbeat");
    const ServiceName ServiceName::ServerTime = ServiceName("time");

    const ServiceName ServiceName::PushNotification = ServiceName("pushNotification");
    const ServiceName ServiceName::GlobalGameStatistics = ServiceName("globalGameStatistics");
    const ServiceName ServiceName::PlayerStatisticsEvent = ServiceName("playerStatisticsEvent");
    const ServiceName ServiceName::Twitter = ServiceName("twitter");
    const ServiceName ServiceName::Steam = ServiceName("steam");

    const ServiceName ServiceName::PlayerState = ServiceName("playerState");
    const ServiceName ServiceName::Entity = ServiceName("entity");
    const ServiceName ServiceName::GlobalEntity = ServiceName("globalEntity");
    const ServiceName ServiceName::Friend = ServiceName("friend");
    const ServiceName ServiceName::Time = ServiceName("time");

    const ServiceName ServiceName::SocialLeaderboard = ServiceName("socialLeaderboard");
	const ServiceName ServiceName::Leaderboard = ServiceName("leaderboard");
    const ServiceName ServiceName::Event = ServiceName("event");
    const ServiceName ServiceName::Product = ServiceName("product");
    const ServiceName ServiceName::PlayerStatistics = ServiceName("playerStatistics");
    const ServiceName ServiceName::GlobalStatistics = ServiceName("globalGameStatistics");
    const ServiceName ServiceName::AsyncMatch = ServiceName("asyncMatch");

    const ServiceName ServiceName::Script = ServiceName("script");
    const ServiceName ServiceName::MatchMaking = ServiceName("matchMaking");
    const ServiceName ServiceName::OneWayMatch = ServiceName("onewayMatch");
    const ServiceName ServiceName::PlaybackStream = ServiceName("playbackStream");
    const ServiceName ServiceName::Gamification = ServiceName("gamification");

    const ServiceName ServiceName::GlobalApp = ServiceName("globalApp");
    const ServiceName ServiceName::S3Handling = ServiceName("s3Handling");
    const ServiceName ServiceName::RedemptionCode = ServiceName("redemptionCode");
    const ServiceName ServiceName::DataStream = ServiceName("dataStream");
    const ServiceName ServiceName::Profanity = ServiceName("profanity");
    const ServiceName ServiceName::File = ServiceName("file");
    const ServiceName ServiceName::Group = ServiceName("group");
	const ServiceName ServiceName::Mail = ServiceName("mail");

    ServiceName::ServiceName(const char * value)
    {
        _value = value;
    }

    bool ServiceName::operator== (const ServiceName& s) const
    {
        return _value == s.getValue();
    }

    void ServiceName::operator= (const ServiceName& s)
    {
        _value = s.getValue();
    }
}
Ejemplo n.º 9
0
TestCoreService::TestCoreService()
:CoreServiceBase(ServiceName())
{

}
Ejemplo n.º 10
0
void
rules_test (tcb * thisdir, segment * pseg, seglen len, quadrant * pquad,
            u_short this_ip_id, Bool pkt_already_seen, double recovery_time)
{
  double DeltaT2, RTO, Mean_RTT, RTT_min;
  char type_of_segment =
    real_rules_test (thisdir, pseg, len, pquad, this_ip_id, pkt_already_seen,
                     &recovery_time);
  tcb *otherdir;
  int dir, num_acked;
#ifdef LOG_OOO
  extern FILE *fp_dup_ooo_log;
#endif

  if (pkt_already_seen)
    {
      pseg->type_of_segment = type_of_segment;
      num_acked = (pseg->prev != NULL) ? pseg->prev->acked : 0;
    }
  else
    {
      pseg->prev->type_of_segment = type_of_segment;
      num_acked = (pseg->prev->prev != NULL) ? pseg->prev->prev->acked : 0;
    }
  /* LM added */

  dir = (&(thisdir->ptp->c2s)) == thisdir;
  otherdir = (dir == C2S) ? &(thisdir->ptp->s2c) : &(thisdir->ptp->c2s);

  DeltaT2 =
    time2double (current_time) - time2double (pquad->seglist_tail->time);

  Mean_RTT =
    Average (thisdir->rtt_sum,
             thisdir->rtt_count) + Average (otherdir->rtt_sum,
                                            otherdir->rtt_count);
  RTO =
    Mean_RTT +
    4 *
    (Stdev
     (thisdir->rtt_sum + otherdir->rtt_sum,
      thisdir->rtt_sum2 + otherdir->rtt_sum2,
      thisdir->rtt_count + otherdir->rtt_count));

  RTT_min = (double) (thisdir->rtt_min + otherdir->rtt_min);

#ifdef LOG_OOO
  if (type_of_segment != 0)
    {
      wfprintf (fp_dup_ooo_log, "T: %f ",
               (elapsed (first_packet, current_time) / 1000.0));
      if (dir == C2S)
        {
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.a_address),
                   ServiceName (thisdir->ptp->addr_pair.a_port));
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.b_address),
                   ServiceName (thisdir->ptp->addr_pair.b_port));
        }
      else
        {
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.b_address),
                   ServiceName (thisdir->ptp->addr_pair.b_port));
          wfprintf (fp_dup_ooo_log, "%s %s ",
                   HostName (thisdir->ptp->addr_pair.a_address),
                   ServiceName (thisdir->ptp->addr_pair.a_port));
        }

      wfprintf (fp_dup_ooo_log,
               "%lu %lu %d %d %u %d %u %d %lf %lf %lu %lf %lf %lf %d",
               thisdir->data_pkts,
               thisdir->data_bytes,
               (type_of_segment & 15),
               thisdir->fsack_req && otherdir->fsack_req,
               thisdir->mss,
               (dir == C2S),
               (internal_dst),
               thisdir->initialwin_bytes,
               recovery_time / 1000.0,
               DeltaT2 / 1000.0,
               len, RTO / 1000.0, RTT_min / 1000.0, Mean_RTT / 1000.0,
               num_acked);
      wfprintf (fp_dup_ooo_log, " %f %f %f %f\n", thisdir->srtt / 1000.0,
               thisdir->rttvar / 1000.0, otherdir->srtt / 1000.0,
               otherdir->rttvar / 1000.0);
    }

#endif

  if (internal_src && !internal_dst)
    {
      add_histo (tcp_anomalies_out, aggregateType (type_of_segment));
    }
  else if (!internal_src && internal_dst)
    {
      add_histo (tcp_anomalies_in, aggregateType (type_of_segment));
    }
#ifndef LOG_UNKNOWN
  else if (internal_src && internal_dst)
#else
  else
#endif
    {
      add_histo (tcp_anomalies_loc, aggregateType (type_of_segment));
    }
  if (dir == C2S)
    {
      add_histo (tcp_anomalies_c2s, aggregateType (type_of_segment));
    }
  else
    {
      add_histo (tcp_anomalies_s2c, aggregateType (type_of_segment));
    }

/* just keep the main classification  and discard bit larger than
   BATCH_CLASSIFICATION*/
  switch (type_of_segment & (BATCH_CLASSIFICATION - 1))
    {
    case IN_SEQUENCE:
      /* just ignore them */
      break;
    case RETRANSMISSION_RTO:
      thisdir->rtx_RTO++;
      break;
    case RETRANSMISSION_FR:
      thisdir->rtx_FR++;
      break;
    case REORDERING:
      thisdir->reordering++;
      break;
    case NETWORK_DUPLICATE:
      thisdir->net_dup++;
      break;
    case FLOW_CONTROL:
      thisdir->flow_control++;
      break;
    case UNNECESSARY_RETRANSMISSION_FR:
      thisdir->unnecessary_rtx_FR++;
      break;
    case UNNECESSARY_RETRANSMISSION_RTO:
      thisdir->unnecessary_rtx_RTO++;
      break;
    default:
      thisdir->unknown++;
    }
}