Ejemplo n.º 1
0
void System::executeScript(const std::string& filename, WindowBase* wnd) {
    if (!m_scriptSys.ExecuteFile(filename, wnd))
    {
        logEvent(log::error, std::string("Unable to execute Lua file: ") + m_scriptSys.GetLastError());
    }
}
Ejemplo n.º 2
0
void	sptrace_log_alloc(PsmPartition trace, unsigned long addr, int size,
		char *fileName, int lineNbr)
{
	if (!trace) return;
	logEvent(trace, OP_ALLOCATE, addr, size, NULL, fileName, lineNbr, NULL);
}
Ejemplo n.º 3
0
uint64_t EventLogger::logStateEvent(ExecutionState *state, ExecutionState *other,
            unsigned event, uint64_t count) {
    return logEvent(state, event, count);
}
Ejemplo n.º 4
0
static void
eventCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
	int			so		= CFSocketGetNative(s);
	int			status;
	union {
		char			bytes[1024];
		struct kern_event_msg	ev_msg1;	// first kernel event
	} buf;
	struct kern_event_msg	*ev_msg		= &buf.ev_msg1;
	int			offset		= 0;

	status = recv(so, &buf, sizeof(buf), 0);
	if (status == -1) {
		SCLog(TRUE, LOG_ERR, CFSTR("recv() failed: %s"), strerror(errno));
		goto error;
	}

	cache_open();

	while (offset < status) {
		if ((offset + ev_msg->total_size) > status) {
			SCLog(TRUE, LOG_NOTICE, CFSTR("missed SYSPROTO_EVENT event, buffer not big enough"));
			break;
		}

		switch (ev_msg->vendor_code) {
			case KEV_VENDOR_APPLE :
				switch (ev_msg->kev_class) {
					case KEV_NETWORK_CLASS :
						processEvent_Apple_Network(ev_msg);
						break;
					case KEV_IOKIT_CLASS :
					case KEV_SYSTEM_CLASS :
					case KEV_APPLESHARE_CLASS :
					case KEV_FIREWALL_CLASS :
					case KEV_IEEE80211_CLASS :
						break;
					default :
						/* unrecognized (Apple) event class */
						logEvent(CFSTR("New (Apple) class"), ev_msg);
						break;
				}
				break;
			default :
				/* unrecognized vendor code */
				logEvent(CFSTR("New vendor"), ev_msg);
				break;
		}
		offset += ev_msg->total_size;
		ev_msg = (struct kern_event_msg *)(void *)&buf.bytes[offset];
	}

	cache_write(store);
	cache_close();
	post_network_changed();

	return;

    error :

	SCLog(TRUE, LOG_ERR, CFSTR("kernel event monitor disabled."));
	CFSocketInvalidate(s);
	return;

}
// Performs a union operation on two interval lists to produce a
// result list.  The list's intervals may have different
// MdamRefList*s associated with them.  Any reference lists
// associated with otherList are ignored and disjunctNum is used
// instead.  The this list and the otherList are inputs to the
// intersect operation.  The result replaces the this list.  The
// original interval list entries for the this list are deleted.
MdamIntervalList & MdamIntervalList::unionSeparateDisjuncts
                          (const MdamIntervalList & otherList,
                           const Int32 disjunctNum,
                           const ULng32 keyLen,
			   FixedSizeHeapManager & mdamIntervalHeap,
			   FixedSizeHeapManager & mdamRefListEntryHeap)
{
  // Move entries from this into tempIntervalList.
  #if defined ( NA_MDAM_EXECUTOR_DEBUG_ILTF )
  MdamIntervalList tempIntervalList(2);
  #else
  MdamIntervalList tempIntervalList;
  #endif /* NA_MDAM_EXECUTOR_DEBUG_ILTF */

  giveAllIntervals(tempIntervalList);

  MdamIntervalListMerger getNextPoint(&tempIntervalList,
                                      &otherList,
                                      keyLen);
  MdamEndPoint currentEndPoint;
  MdamEndPoint previousEndPoint;

  // Track the active interval for each interval list.  Zero means
  // there is no active interval.  This mechanism permits access
  // to the corresponding reference list.
  MdamInterval * intervalPtr0 = 0;
  MdamInterval * intervalPtr1 = 0;

  while(getNextPoint(currentEndPoint))
    {
      if (getNextPoint.getPreviousActiveIntervals() != 0
          && currentEndPoint.givesNonEmptyInterval(&previousEndPoint,keyLen))
        {
	  // Create a new interval.  The constructor will reverse the 
	  // inclusion of end endpoint, if appropriate, and build
	  // the reference list.
          MdamInterval * tempIntervalPtr = new(mdamIntervalHeap) 
	    MdamInterval(previousEndPoint,
			 currentEndPoint,
			 intervalPtr0,
			 intervalPtr1,
			 disjunctNum,
			 mdamRefListEntryHeap);
          // Append the new interval onto this list.
          append(tempIntervalPtr);
        }; // end if

      // Adjust active reference lists.
      currentEndPoint.adjustIntervalPtr(intervalPtr0, 0);
      currentEndPoint.adjustIntervalPtr(intervalPtr1, 1);

      // Save the current endpoint.
      previousEndPoint = currentEndPoint;
      if (currentEndPoint.end()){previousEndPoint.reverseInclusion();};
    }; // end while

  #if defined ( NA_MDAM_EXECUTOR_DEBUG_ILTF )
  // Log entry for intervals resulting from the union operation.
  logEvent(8,countIntervals(),otherList.intervalListId_);
  #endif /* NA_MDAM_EXECUTOR_DEBUG_ILTF */

  // Delete the original this list entries because the destructor
  // can't.
  tempIntervalList.deleteAllIntervals(mdamIntervalHeap,
                                      mdamRefListEntryHeap);

  return *this;
}
Ejemplo n.º 6
0
void EventsWidget::onPlayerDisconnectEvent(const QString &player)
{
    logEvent("PlayerDisconnect", tr("Player %1 disconnected.").arg(player));
}
Ejemplo n.º 7
0
void RedisClient::SshTransporter::OnSshSocketDestroyed()
{
    m_socket = nullptr;
    emit logEvent("SSH socket detroyed");
}
Ejemplo n.º 8
0
void EventsWidget::onPlayerJoinEvent(const QString &player, const QString &guid)
{
    logEvent("PlayerJoin", tr("Player %1 joined the game (GUID: %2).").arg(player, guid));
}
Ejemplo n.º 9
0
void EventsWidget::onPlayerLeaveEvent(const QString &player, const QString &info)
{
    Q_UNUSED(info);

    logEvent("PlayerLeave", tr("Player %1 left the game.").arg(player)); // TODO: Impelment score stuffs here?
}
Ejemplo n.º 10
0
//====================================
int servuinoFunc(int event, int pin, int value, const char *p, unsigned char uc)
//====================================
{
  int res=999,fail=0;
  char eventText[120];
  char custText[120];

  strcpy(custText,"no-text");

  g_curStep++;

  updateFromRegister();
  clearRW();
  if(g_ongoingInterrupt == S_NO)interruptPinValues();

  if(g_serialMode == S_ON)
    {
      x_pinMode[0] = RX;
      x_pinMode[1] = TX;
    }
  
  sprintf(eventText,"%d Unknown event: %d pin=%d value=%d",g_curStep,event,pin,value);
  
  if(event == S_UNIMPLEMENTED)
    {
      sprintf(eventText,"Unimplemented: %s",p);
    }
  if(event == S_SETUP)
    {
      sprintf(eventText,"setup");
    }
  if(event == S_LOOP)
    {
      sprintf(eventText,"servuinoLoop %d",g_curLoop);
    }
  if(event == S_PIN_MODE_INPUT)
    {
      fail = checkRange(FAIL,"digpin",pin);
      if(fail == 0)
	{
	  x_pinMode[pin] = value;
	  if(value==INPUT)
	    {
	      // Set pin status according to scenario when mode is INPUT
	      res = x_pinScenario[pin][g_curStep];
	      x_pinDigValue[pin] = res;
	      writeRegister(1,R_PIN,pin,value);

	      writeRegister(1,R_DDR,pin,0);
	      sprintf(eventText,"pinMode pin=%d INPUT",pin);
	      sprintf(custText,"%s %d",g_custText[event][pin],pin);
	    }
	}
      res = 0;
    }
  if(event == S_PIN_MODE_OUTPUT)
    {
      fail = checkRange(FAIL,"digpin",pin);
      if(fail == 0)
	{
	  x_pinMode[pin] = value;
	  if(value==OUTPUT)
	    {
	      // Set pin status according to PORT register when mode is OUTPUT
	      x_pinDigValue[pin] = readRegister(R_PORT,pin);

	      writeRegister(1,R_DDR,pin,1);
	      sprintf(eventText,"pinMode pin=%d OUTPUT",pin);
	      sprintf(custText,"%s %d",g_custText[event][pin],pin);
	    }
	}
      res = 0;
    }
  if(event == S_DIGITAL_WRITE_LOW || event == S_DIGITAL_WRITE_HIGH)
    {
      x_pinRW[pin] = T_WRITE;
      fail = checkRange(FAIL,"digpin",pin);
      fail = fail + checkRange(FAIL,"digval",value);
      if(fail == 0)
	{
	  x_pinDigValue[pin] = value;
	  writeRegister(1,R_PORT,pin,value);
	  sprintf(eventText,"digitalWrite pin=%d value=%d",pin,value);
	  sprintf(custText,"%s %d",g_custText[event][pin],value);
	}
      res = 0;
      if(x_pinMode[pin] != OUTPUT) 
	errorLog("DigitalWrite when pin Mode is INPUT",pin);
    }
  if(event == S_DIGITAL_READ)
    {
      x_pinRW[pin] = T_READ;
      res = x_pinScenario[pin][g_curStep];
      x_pinDigValue[pin] = res;
      writeRegister(1,R_PIN,pin,value);
      sprintf(eventText,"digitalRead pin=%d value=%d",pin,res);
      sprintf(custText,"%s %d",g_custText[event][pin],res);
      //value = getDigitalPinValue(pin,currentStep); 
      if(x_pinMode[pin] != INPUT) 
	errorLog("DigitalRead when pin Mode is OUPUT",pin); 
    }
  if(event == S_ANALOG_WRITE)//PWM pinMode OUTPUT not necessary (see arduino.com)
    {
      x_pinRW[pin] = T_WRITE;
      fail = checkRange(FAIL,"pwmpin",pin);
      fail = fail + checkRange(FAIL,"pwmval",value);
      if(fail == 0)
	{
	  x_pinAnaValue[pin] = value;
	  //writeRegister(pin,value);
	  sprintf(eventText,"analogWrite pin=%d value=%d",pin,value);
	  sprintf(custText,"%s %d",g_custText[event][pin],value);
	}
      res = 0;
    }
  if(event == S_ANALOG_READ)
    {
      x_pinRW[pin] = T_READ;
      res = x_pinScenario[pin][g_curStep];
      x_pinAnaValue[pin] = res;
      sprintf(eventText,"analogRead pin=%d value=%d",pin-g_nDigPins,res);
      sprintf(custText,"%s %d",g_custText[event][pin],res);
    }
  if(event == S_ANALOG_REFERENCE)
    {
      sprintf(eventText,"analogReference type=%s",p);
    }
  if(event == S_DELAY)
    {
      sprintf(eventText,"delay %d ms",pin);
      fprintf(f_time,"+ %d %d\n",g_curStep,pin*1000);
    }
  if(event == S_DELAY_MS)
    {
      sprintf(eventText,"delay %d us",pin);
      fprintf(f_time,"+ %d %d\n",g_curStep,pin);
    }
  if(event == S_ATTACH_INTERRUPT_LOW)
    {
      sprintf(eventText,"attached LOW interrupt %d",pin);
    }
  if(event == S_ATTACH_INTERRUPT_RISING)
    {
      sprintf(eventText,"attached RISING interrupt %d",pin);
    }
  if(event == S_ATTACH_INTERRUPT_FALLING)
    {
      sprintf(eventText,"attached FALLING interrupt %d",pin);
    }
  if(event == S_ATTACH_INTERRUPT_CHANGE)
    {
      sprintf(eventText,"attached CHANGE interrupt %d",pin);
    }
  if(event == S_DETACH_INTERRUPT)
    {
      g_interruptType[pin] = 0;
      sprintf(eventText,"detached interrupt %d",pin);
    }
  if(event == S_SERIAL_BEGIN)
    {
      sprintf(eventText,"Serial.begin baud=%d",pin);
      if(g_serialMode == S_ON) 
	errorLog("Serial begin already exists",g_curStep);
      g_serialMode = S_ON;
    }
  if(event == S_SERIAL_END)
    {
      sprintf(eventText,"Serial.end");
      if(g_serialMode != S_ON) 
	errorLog("Serial end without serial.begin",g_curStep);
      g_serialMode = S_OFF;
    }
  if(event == S_SERIAL_PRINT_INT)
    {
      sprintf(eventText,"Serial.print(int) %d",pin);
      fprintf(f_serial,"%d SL [%d]\n",g_curStep,pin);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINT_INT_BASE)
    {
      sprintf(eventText,"Serial.print(int,base) %d base=%d",pin,value);
      fprintf(f_serial,"%d SL [%d]\n",g_curStep,pin);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINT_CHAR)
    {
      sprintf(eventText,"Serial.print(char) %s",p);
      fprintf(f_serial,"%d SL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINT_UCHAR)
    {
      sprintf(eventText,"Serial.print(uchar) %c",uc);
      fprintf(f_serial,"%d SL [%c]\n",g_curStep,uc);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINT_STRING)
    {
      sprintf(eventText,"Serial.print(string) %s",p); 
      fprintf(f_serial,"%d SL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINT_SSTRING)
    {
      sprintf(eventText,"Serial.print(String) %s",p);
      fprintf(f_serial,"%d SL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_INT)
    { 
      sprintf(eventText,"Serial.println(int) %d",pin);
      fprintf(f_serial,"%d NL [%d]\n",g_curStep,pin);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_INT_BASE)
    {
      sprintf(eventText,"Serial.println(int,base) %d base=%d",pin,value);
      fprintf(f_serial,"%d NL [%d]\n",g_curStep,pin);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_CHAR)
    { 
      sprintf(eventText,"Serial.println(char) %s",p);
      fprintf(f_serial,"%d NL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_UCHAR)
    { 
      sprintf(eventText,"Serial.println(uchar) %c",uc);
      fprintf(f_serial,"%d NL [%c]\n",g_curStep,*p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_STRING)
    {
      sprintf(eventText,"Serial.println(string) %s",p); 
      fprintf(f_serial,"%d NL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_SSTRING)
    {
      sprintf(eventText,"Serial.println(String) %s",p);
      fprintf(f_serial,"%d NL [%s]\n",g_curStep,p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_PRINTLN_VOID)
    {
      sprintf(eventText,"Serial.println(void)");
      fprintf(f_serial,"%d NL []\n",g_curStep);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
  if(event == S_SERIAL_WRITE)
    {
      sprintf(eventText,"Serial.write %s",p);
      if(g_serialMode != S_ON) 
	errorLog("Serial print without serial.begin",g_curStep);
    }
    
  if(event == S_EEPROM_WRITE)
    {
      sprintf(eventText,"EEPROM.write address=%d value=%d",pin,value);
      if(pin > 512) 
	   errorLog("EEPROM write: address > 512: ",pin);
	  if(pin < 0) 
	   errorLog("EEPROM write: address < 0: ",pin);
	  if(value > 255) 
	   errorLog("EEPROM write: value > 255: ",value);
	  if(value < 0) 
	   errorLog("EEPROM write: value < 0: ",value);
	  res = 0;
    }
  if(event == S_EEPROM_READ)
    {
      sprintf(eventText,"EEPROM.read address=%d value=%d",pin,value);
      if(pin > 512) 
	   errorLog("EEPROM read: address > 512: ",pin);
	  if(pin < 0) 
	   errorLog("EEPROM read: address < 0: ",pin);
	  if(value > 255) 
	   errorLog("EEPROM read: value > 255: ",value);
	  if(value < 0) 
	   errorLog("EEPROM read: value < 0: ",value);
	  res = 0;
    }


  logEvent(eventText);
  logCust(custText);
  writeStatus();

  if(g_curStep == g_simulationLength) stopEncoding();

  if(g_doInterrupt == S_YES && g_ongoingInterrupt == S_NO)interruptNow();

  return(res);
}
Ejemplo n.º 11
0
int manageIoDevice( Device* device, Heap* ready_queue,
                    ActivityLog* activity_log )
{
    // variables
    char action_message[STD_STR_LEN];
    PCB temp;

    // case: an I/O completion interrupt has been raised
    if( device->data.interrupt_flag )
    {
        // time this action
        stopwatch( 's', IO_TIMER );

        // kill the I/O simulating thread
        pthread_join( device->data.thread_id, NULL );

        // release the device from the process, load it into the main
        // scheduler
        device->data.interrupt_flag = false;
        device->data.in_use = false;
        insert_heap( ready_queue, *(device->working_process), FIFO_HEAP );
        device->working_process = NULL;

        // log this action
        sprintf( action_message, "%s action completed for process %d - "
                                 "process placed back in main scheduler",
                 device->name, device->working_process->pid );
        logEvent( activity_log, SYSTEM, action_message,
                   stopwatch( 'x', IO_TIMER ) );
    }
    // case: an I/O processed is running and needs to be managed
    else if( device->data.in_use )
    {
        // log the maintenance of the process (simulate with a short wait)
        stopwatch( 's', IO_TIMER );
        usleep( IO_MANAGEMENT_TIME );
        sprintf( action_message,
                 "I/O maintnenance: %s still in use by process %d",
                 device->name, device->working_process->pid );
        logEvent( activity_log, SYSTEM, action_message,
                   stopwatch( 'x', IO_TIMER ) );
    }

    // case: an I/O process is wating to run and the I/O device is free
    //       (it is possible that the device was previously freed previously)
    if( !(device->data.in_use) && !is_Heap_empty( &(device->waiting_queue ) ) )
    {
        // start the I/O process on this device
        stopwatch( 's', IO_TIMER );
        temp = remove_PCB_from_Heap( &(device->waiting_queue) );
        device->working_process = &temp;

        // startup the independent I/O action (simulated of course)
        pthread_attr_init( &(device->data.attribute) );
        pthread_create( &(device->data.thread_id), &(device->data.attribute),
                        conductIoProcess, (void*) &(device->data) );

        // log the action
        sprintf( action_message, "Starting process %d on %s",
                 device->working_process->pid, device->name );
        logEvent( activity_log, SYSTEM, action_message,
                  stopwatch( 'x', IO_TIMER ) );
    }
}
Ejemplo n.º 12
0
//returns bytesize of sent filename (or -1 on error); 
static uint32_t sendNextRequestedFile(connectionObject *connection)
{
  uint32_t       filenameBytesize = 0;
  diskFileObject *outgoingFile    = NULL; 
  uint32_t       bytesAlreadyRead = 0; 
  uint32_t       bytesToRead      = 0; 
  uint32_t       fileBytesize     = 0; //TODO eventually make uint64_t + support this in networking + client + server +disklfile etc, switch to 64 bit eventually (used many spots make sure to change all when I do it)...
  
  if(connection == NULL){
    logEvent("Error", "Something was NULL that shouldn't have been");
    goto error; 
  }
  
  //get the requested file name bytesize
  filenameBytesize = connection->router->getIncomingBytesize(connection->router); 
  
  //WARNING the assumption that MAX_FILE_ID_BYTESIZE is exact size of buffer connection->requestedFilename must hold true for security to be present
  if(filenameBytesize > MAX_FILE_ID_BYTESIZE || filenameBytesize == 0){ 
   return 0;  
  }
  
  //initialize filename
  if( !connection->router->receive(connection->router, connection->requestedFilename, filenameBytesize) ){
    logEvent("Error", "Failed to determine requested file name");
    return 0;
  }
     
  //random NOTE (Stop relying on strlen for anything anywhere)
  outgoingFile = getFileById(connection->requestedFilename, filenameBytesize); 
  if(!outgoingFile && !sendFileNotFound(connection)){
    logEvent("Error", "Failed to send file not found to client");
    goto error; 
  }
  
  fileBytesize = outgoingFile->getBytesize(outgoingFile);
  if(fileBytesize == -1){
    logEvent("Error", "Failed to get file bytesize");
    goto error; 
  }
  
  if( !connection->router->transmitBytesize(connection->router, fileBytesize) ){ 
    logEvent("Error", "Failed to transmit file bytesize to client");
    goto error;
  }
  
  
  for(bytesAlreadyRead = 0, bytesToRead = 0; bytesAlreadyRead < fileBytesize; bytesAlreadyRead += bytesToRead){
    bytesToRead = ( (fileBytesize - bytesAlreadyRead) < FILE_CHUNK_BYTESIZE ) ? (fileBytesize - bytesAlreadyRead) : FILE_CHUNK_BYTESIZE; 
  
    if( !outgoingFile->dfRead(outgoingFile, connection->dataCache, bytesToRead, bytesAlreadyRead) ){
      logEvent("Error", "Failed to read file bytes");
      goto error; 
    }
  
    if( !connection->router->transmit(connection->router, connection->dataCache, bytesToRead) ){ //TODO should we make a packet format that is padded and fixed size? I think so. 
      logEvent("Error", "Failed to transmit file to client");
      goto error; 
    }
  }
  

  return filenameBytesize; 
  
  error:
   return -1; 
}
Ejemplo n.º 13
0
static int initializeSharedFiles(const char *sharedFolderPath, uint32_t maxCacheMegabytes)
{
  uint32_t            availableCacheBytes; 
  uint32_t            fileBytesCached; 
  DIR                 *directory; 
  struct dirent       *fileEntry; 
  diskFileObject      *diskFile; 

  if(sharedFolderPath == NULL){
    logEvent("Error", "Something was NULL that shouldn't have been");
    return 0;
  }
  
  initializeFileBank();
  
  //simple unsigned integer wrap protection, limits cache to slightly over four gigabytes
  if(maxCacheMegabytes > UINT32_MAX / BYTES_IN_A_MEGABYTE){
    logEvent("Error", "maximum cache megabyte size supported is (UINT32_MAX / BYTES_IN_A_MEGABYTE), as cache is internally stored in bytes in a uint32_t");   
    return 0; 
  }
  else{
    globalMaxCacheBytes = maxCacheMegabytes * BYTES_IN_A_MEGABYTE;
  }
  
  availableCacheBytes = globalMaxCacheBytes; 

  
  directory = opendir( sharedFolderPath );
  if(directory == NULL){
    logEvent("Error", "Failed to open shared folder");
    return 0;
  }
  
  while((fileEntry = readdir(directory))){
    
    if( !strcmp(fileEntry->d_name, ".") || !strcmp(fileEntry->d_name, "..") ){
      continue;
    }
    
    diskFile = newDiskFile();
    if(diskFile == NULL){
      logEvent("Error", "Failed to create diskFile object");
      return 0; 
    }
    
   if( !diskFile->dfOpen(diskFile, sharedFolderPath, fileEntry->d_name, "r") ){ //TODO make consts in accordance with cert (everywhere)
      logEvent("Error", "Failed to open file on disk");
      return 0; 
    }
    
    fileBytesCached = diskFile->cacheBytes(diskFile, FILE_CHUNK_BYTESIZE); //TODO we need to switch from a byte paradigm to a file chunk paradigm to ensure compatibility with mmap page sizes, don't keep track of max cached bytes but rather max cached file chunks, this cache is too small
    availableCacheBytes -= fileBytesCached; //BROKEN WARNING SEE ABOVE TODO                                                                       //and should be available cache bytes TODO TODO TODO TODO TODO TODO BROKEN WARNING
    
    if( depositFile(diskFile) != 1){
      logEvent("Error", "Failed to deposit a file into shared file bank, does the shared folder have too many files in it?");
      return 0;
    }
  }

  return 1; 
}
Ejemplo n.º 14
0
void System::reset(bool complete)
{
    m_render.cleanup(complete);
    m_windowMgr->reset(complete);

    logEvent(log::system, "Resetting window tree...");
    m_tickedWnd.clear();
    m_subscribeTickWnd.clear();
    m_dragContainer = 0;
    m_tooltipWindow = 0;
    m_dragWindow = 0;
    m_rootWindow = 0;
    m_containsMouse = 0;
    m_focusWindow = 0;
    m_exclusiveInputWindow = 0;
    m_captureWindow = 0;
    m_dragging = false;
    m_dragfired = false;
    m_dragfreeze = false;

    m_rootWindow.reset();
    m_dragContainer.reset();
    m_tooltipWindow.reset();
    m_menuWindow.reset();

    if (complete) {
        m_scriptSys.reset();
        makeLuaBinding();
    }

    m_rootWindow = std::make_shared<WindowBase>(*this, "systemroot");
    if(!m_rootWindow)
        throw std::exception("Couldn't create root window!");

    auto drag = std::make_shared<DragContainer>(*this, "systemdrag");
    m_dragContainer = drag;
    if (!m_dragContainer)
        throw std::exception("Couldn't create drag window!");

    drag->reset();

    auto tooltip = std::make_shared<Tooltip>(*this, "systemtooltip");
    m_tooltipWindow = tooltip;
    if(!tooltip)
        throw std::exception("Couldn't create tooltip window!");

    tooltip->reset();

    auto menu = std::make_shared<Menu>(*this, "systemmenu");
    m_menuWindow = menu;
    if (!m_menuWindow)
        throw std::exception("Couldn't create menu window!");
    m_windowMgr->loadLeafWindow(m_menuWindow, "base/menu.xml");

    menu->reset();

    m_rootWindow->setArea(Rect(point(.0f, .0f), m_render.getSize())); // full window area
    m_rootWindow->setVisible(true);
    m_rootWindow->add(m_dragContainer);
    m_rootWindow->add(m_tooltipWindow);
    m_rootWindow->add(m_menuWindow);
    m_rootWindow->setAcceptDrop(true);




    logEvent(log::system, "Gui subsystem is ready");
}
Ejemplo n.º 15
0
void EventsWidget::onDisconnected()
{
    logEvent("Disconnected", tr("Disconnected."));
}
Ejemplo n.º 16
0
void EventsWidget::onPlayerSpawnEvent(const QString &player, int teamId)
{
    logEvent("PlayerSpawn", tr("Player %1 spawned, and is on team %2.").arg(player).arg(BF4LevelDictionary::getTeam(teamId - 1).name));
}
Ejemplo n.º 17
0
/* Events */
void EventsWidget::onPlayerAuthenticatedEvent(const QString &player)
{
    logEvent("PlayerAuthenticated", tr("Player %1 authenticated.").arg(player));
}
Ejemplo n.º 18
0
void EventsWidget::onPlayerChatEvent(const QString &sender, const QString &message, const QString &target)
{
    Q_UNUSED(target);

    logEvent("PlayerChat", QString("%1: %2").arg(sender).arg(message));
}
Ejemplo n.º 19
0
int main(int argc, char ** argv)
{
    if (security_init() != 0) {
        log(CRITICAL, "Security initialisation Error. Exiting.");
        return EXIT_SECURITY_ERROR;
    }

    if (security_check() != SECURITY_OKAY) {
        log(CRITICAL, "Security check error. Exiting.");
        return EXIT_SECURITY_ERROR;
    }

    interactive_signals();

    int config_status = loadConfig(argc, argv, USAGE_SERVER);
    if (config_status < 0) {
        if (config_status == CONFIG_VERSION) {
            std::cout << argv[0] << " (cyphesis) " << consts::version
                      << " (Cyphesis build " << consts::buildId << ")"
                      << std::endl << std::flush;

            return 0;
        } else if (config_status == CONFIG_HELP) {
            showUsage(argv[0], USAGE_SERVER);
            return 0;
        } else if (config_status != CONFIG_ERROR) {
            log(ERROR, "Unknown error reading configuration.");
        }
        // Fatal error loading config file.
        return EXIT_CONFIG_ERROR;
    }

    if (daemon_flag) {
        int pid = daemonise();
        if (pid == -1) {
            return EXIT_FORK_ERROR;
        } else if (pid > 0) {
            return EXIT_SUCCESS;
        }
    }

    readConfigItem(instance, "usedatabase", database_flag);

    // If we are a daemon logging to syslog, we need to set it up.
    initLogger();

    // Initialise the persistance subsystem. If we have been built with
    // database support, this will open the various databases used to
    // store server data.
    if (database_flag) {
        Persistence * p = Persistence::instance();
        int dbstatus = p->init();
        if (dbstatus < 0) {
            database_flag = false;
            log(ERROR, "Error opening database. Database disabled.");
            if (dbstatus == DATABASE_TABERR) {
                log(INFO, "Database connection established, "
                          "but unable to create required tables.");
                log(INFO, "Please ensure that any obsolete database "
                          "tables have been removed.");
            } else {
                log(INFO, "Unable to connect to the RDBMS.");
                log(INFO, "Please ensure that the RDBMS is running, "
                          "the cyphesis database exists and is accessible "
                          "to the user running cyphesis.");
            }
            log(INFO, String::compose("To disable this message please run:\n\n"
                                      "    cyconfig --%1:usedatabase=false\n\n"
                                      "to permanently disable database usage.",
                                      instance));
        }
    }

    // If the restricted flag is set in the config file, then we
    // don't allow connecting users to create accounts. Accounts must
    // be created manually by the server administrator.
    if (restricted_flag) {
        log(INFO, "Setting restricted mode.");
    }

    readConfigItem(instance, "inittime", timeoffset);

    std::string server_name;
    if (readConfigItem(instance, "servername", server_name) != 0) {
        if (instance == CYPHESIS) {
            server_name = get_hostname();
        } else {
            server_name = instance;
        }
    }

    int nice = 1;
    readConfigItem(instance, "nice", nice);
    
    // Start up the python subsystem.
    init_python_api();

    { // scope for CommServer

    // Create commserver instance that will handle connections from clients.
    // The commserver will create the other server related objects, and the
    // world object pair (World + WorldRouter), and initialise the admin
    // account. The primary ruleset name is passed in so it
    // can be stored and queried by clients.
    Inheritance::instance();

    WorldRouter world;

    Ruleset::init();

    TeleportAuthenticator::init();

    StorageManager store(world);

    // This ID is currently generated every time, but should perhaps be
    // persistent in future.
    std::string server_id, lobby_id;
    long int_id, lobby_int_id;

    if (((int_id = newId(server_id)) < 0) ||
        ((lobby_int_id = newId(lobby_id)) < 0)) {
        log(CRITICAL, "Unable to get server IDs from Database");
        return EXIT_DATABASE_ERROR;
    }

    ServerRouting server(world, ruleset, server_name,
                         server_id, int_id,
                         lobby_id, lobby_int_id);

    CommServer commServer(server);

    if (commServer.setup() != 0) {
        log(CRITICAL, "Internal error setting up server infrastructure");
        return EXIT_SOCKET_ERROR;
    }

    // This is where we should restore the database, before
    // the listen sockets are open. Unlike earlier code, we are
    // attempting to construct the internal state from the database,
    // not creating a new world using the contents of the database as a
    // template

    if (database_flag) {
        // log(INFO, _("Restoring world from database..."));

        store.restoreWorld();
        // FIXME Do the following steps.
        // Read the world entity if any from the database, or set it up.
        // If it was there, make sure it did not get any of the wrong
        // position or orientation data.
        store.initWorld();

        // log(INFO, _("Restored world."));

        CommPSQLSocket * dbsocket = new CommPSQLSocket(commServer,
                                        Persistence::instance()->m_connection);
        commServer.addSocket(dbsocket);
        commServer.addIdle(dbsocket);

        IdleConnector * storage_idle = new IdleConnector(commServer);
        storage_idle->idling.connect(sigc::mem_fun(&store, &StorageManager::tick));
        commServer.addIdle(storage_idle);
    } else {
        std::string adminId;
        long intId = newId(adminId);
        assert(intId >= 0);

        Admin * admin = new Admin(0, "admin", "BAD_HASH", adminId, intId);
        server.addAccount(admin);
    }

    // Add the test object, and call it regularly so it can do what it does.
    // UpdateTester * update_tester = new UpdateTester(commServer);
    // commServer.addIdle(update_tester);

    CommTCPListener * listener = new CommTCPListener(commServer,
          *new CommClientFactory<Connection>());
    if (client_port_num < 0) {
        client_port_num = dynamic_port_start;
        for (; client_port_num <= dynamic_port_end; client_port_num++) {
            if (listener->setup(client_port_num) == 0) {
                break;
            }
        }
        if (client_port_num > dynamic_port_end) {
            log(ERROR, String::compose("Could not find free client listen "
                                       "socket in range %1-%2. Init failed.",
                                       dynamic_port_start, dynamic_port_end));
            log(INFO, String::compose("To allocate 8 more ports please run:"
                                      "\n\n    cyconfig "
                                      "--cyphesis:dynamic_port_end=%1\n\n",
                                      dynamic_port_end + 8));
            return EXIT_PORT_ERROR;
        }
        log(INFO, String::compose("Auto configuring new instance \"%1\" "
                                  "to use port %2.",
                                  instance, client_port_num));
        global_conf->setItem(instance, "tcpport", client_port_num,
                             varconf::USER);
        global_conf->setItem(CYPHESIS, "dynamic_port_start",
                             client_port_num + 1, varconf::USER);
    } else {
        if (listener->setup(client_port_num) != 0) {
            log(ERROR, String::compose("Could not create client listen socket "
                                       "on port %1. Init failed.",
                                       client_port_num));
            return EXIT_SOCKET_ERROR;
        }
    }
    commServer.addSocket(listener);

#ifdef HAVE_SYS_UN_H
    CommUnixListener * localListener = new CommUnixListener(commServer,
          *new CommClientFactory<TrustedConnection>());
    if (localListener->setup(client_socket_name) != 0) {
        log(ERROR, String::compose("Could not create local listen socket "
                                   "with address \"%1\"",
                                   localListener->getPath()));
        delete localListener;
    } else {
        commServer.addSocket(localListener);
    }

    CommUnixListener * pythonListener = new CommUnixListener(commServer,
          *new CommPythonClientFactory());
    if (pythonListener->setup(python_socket_name) != 0) {
        log(ERROR, String::compose("Could not create python listen socket "
                                   "with address %1.",
                                   pythonListener->getPath()));
        delete pythonListener;
    } else {
        commServer.addSocket(pythonListener);
    }
#endif

    CommTCPListener * httpListener = new CommTCPListener(commServer,
          *new CommHttpClientFactory());
    if (httpListener->setup(http_port_num) != 0) {
        log(ERROR, String::compose("Could not create http listen socket on "
                                   "port %1.", http_port_num));
        delete httpListener;
    } else {
        commServer.addSocket(httpListener);
    }

    if (useMetaserver) {
        CommMetaClient * cmc = new CommMetaClient(commServer);
        if (cmc->setup(mserver) == 0) {
            commServer.addIdle(cmc);
        } else {
            log(ERROR, "Error creating metaserver comm channel.");
            delete cmc;
        }
    }

#if defined(HAVE_LIBHOWL) || defined(HAVE_AVAHI)

    CommMDNSPublisher * cmdns = new CommMDNSPublisher(commServer);
    if (cmdns->setup() == 0) {
        commServer.addSocket(cmdns);
        commServer.addIdle(cmdns);
    } else {
        log(ERROR, "Unable to register service with MDNS daemon.");
        delete cmdns;
    }

#endif // defined(HAVE_LIBHOWL) || defined(HAVE_AVAHI)

    // Configuration is now complete, and verified as somewhat sane, so
    // we save the updated user config.

    updateUserConfiguration();

    log(INFO, "Running");
    logEvent(START, "- - - Standalone server startup");

    // Inform things that want to know that we are running.
    running();

    // Reduce our system priority to make it easier to debug a runaway
    // server.
    if (nice != 0) {
        reduce_priority(nice);
    }

    // Loop until the exit flag is set. The exit flag can be set anywhere in
    // the code easily.
    while (!exit_flag) {
        try {
            commServer.poll();
        }
        catch (...) {
            // It is hoped that commonly thrown exception, particularly
            // exceptions that can be caused  by external influences
            // should be caught close to where they are thrown. If
            // an exception makes it here then it should be debugged.
            log(ERROR, "Exception caught in main()");
        }
    }
    // exit flag has been set so we close down the databases, and indicate
    // to the metaserver (if we are using one) that this server is going down.
    // It is assumed that any preparation for the shutdown that is required
    // by the game has been done before exit flag was set.
    log(NOTICE, "Performing clean shutdown...");

    } // close scope of CommServer, WorldRouter, and ServerRouting, which
      // cause the destruction of the server and world objects, and the entire
      // world contents

    Persistence::instance()->shutdown();

    EntityBuilder::instance()->flushFactories();
    EntityBuilder::del();
    ArithmeticBuilder::del();
    MindFactory::del();
    TeleportAuthenticator::del();

    Inheritance::clear();

    // Shutdown the python interpretter. This frees lots of memory, and if
    // the malloc heap is in any way corrupt, a segfault is likely to
    // occur at this point. Previous occassions where pointers have been
    // deleted twice elsewhere in the code, have resulted in a segfault
    // at this point. AlRiddoch 10th November 2001
    shutdown_python_api();

    delete global_conf;

    log(INFO, "Clean shutdown complete.");
    logEvent(STOP, "- - - Standalone server shutdown");
    return 0;
}
Ejemplo n.º 20
0
void EventsWidget::onPlayerTeamChangeEvent(const QString &player, int teamId, int squadId)
{
    Q_UNUSED(squadId);

    logEvent("PlayerTeamChange", tr("Player %1 changed team to %2.").arg(player).arg(teamId));
}
Ejemplo n.º 21
0
static void
processEvent_Apple_Network(struct kern_event_msg *ev_msg)
{
	const char *			eventName = NULL;
	int				dataLen = (ev_msg->total_size - KEV_MSG_HEADER_SIZE);
	void *				event_data = &ev_msg->event_data[0];
	Boolean				handled = TRUE;
	char				ifr_name[IFNAMSIZ];

	switch (ev_msg->kev_subclass) {
		case KEV_INET_SUBCLASS : {
			eventName = inetEventNameString(ev_msg->event_code);
			switch (ev_msg->event_code) {
				case KEV_INET_NEW_ADDR :
				case KEV_INET_CHANGED_ADDR :
				case KEV_INET_ADDR_DELETED :
				case KEV_INET_SIFDSTADDR :
				case KEV_INET_SIFBRDADDR :
				case KEV_INET_SIFNETMASK : {
					struct kev_in_data * ev;

					ev = (struct kev_in_data *)event_data;
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_update_ipv4(NULL, ifr_name);
					break;
				}
				case KEV_INET_ARPCOLLISION : {
					struct kev_in_collision * ev;

					ev = (struct kev_in_collision *)event_data;
					if ((dataLen < sizeof(*ev))
					    || (dataLen < (sizeof(*ev) + ev->hw_len))) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_collision_ipv4(ifr_name,
								 ev->ia_ipaddr,
								 ev->hw_len,
								 ev->hw_addr);
					break;
				}
#if	!TARGET_OS_IPHONE
				case KEV_INET_PORTINUSE : {
					struct kev_in_portinuse	* ev;
					ev = (struct kev_in_portinuse *)event_data;
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					port_in_use_ipv4(ev->port, ev->req_pid);
					break;
				}
#endif	/* !TARGET_OS_IPHONE */
				default :
					handled = FALSE;
					break;
			}
			break;
		}
		case KEV_INET6_SUBCLASS : {
			struct kev_in6_data * ev;

			eventName = inet6EventNameString(ev_msg->event_code);
			ev = (struct kev_in6_data *)event_data;
			switch (ev_msg->event_code) {
				case KEV_INET6_NEW_USER_ADDR :
				case KEV_INET6_CHANGED_ADDR :
				case KEV_INET6_ADDR_DELETED :
				case KEV_INET6_NEW_LL_ADDR :
				case KEV_INET6_NEW_RTADV_ADDR :
				case KEV_INET6_DEFROUTER :
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_update_ipv6(NULL, ifr_name);
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
		case KEV_DL_SUBCLASS : {
			struct net_event_data * ev;

			eventName = dlEventNameString(ev_msg->event_code);
			ev = (struct net_event_data *)event_data;
			switch (ev_msg->event_code) {
				case KEV_DL_IF_ATTACHED :
					/*
					 * new interface added
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_add(ifr_name);
					break;

				case KEV_DL_IF_DETACHED :
					/*
					 * interface removed
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_remove(ifr_name);
					break;

				case KEV_DL_IF_DETACHING :
					/*
					 * interface detaching
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					interface_detaching(ifr_name);
					break;

				case KEV_DL_PROTO_ATTACHED :
				case KEV_DL_PROTO_DETACHED : {
					struct kev_dl_proto_data * protoEvent;

					protoEvent = (struct kev_dl_proto_data *)event_data;
					if (dataLen < sizeof(*protoEvent)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&protoEvent->link_data,
						     ifr_name, sizeof(ifr_name));
					if (protoEvent->proto_remaining_count == 0) {
						mark_if_down(ifr_name);
					} else {
						mark_if_up(ifr_name);
					}
					break;
				}

#ifdef	KEV_DL_IF_IDLE_ROUTE_REFCNT
				case KEV_DL_IF_IDLE_ROUTE_REFCNT: {
					/*
					 * interface route refcnt idle
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					interface_update_idle_state(ifr_name);
					break;
				}
#endif	// KEV_DL_IF_IDLE_ROUTE_REFCNT

				case KEV_DL_LINK_OFF :
				case KEV_DL_LINK_ON :
					/*
					 * update the link status in the store
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_update_status(ifr_name, FALSE);
					break;

#ifdef  KEV_DL_LINK_QUALITY_METRIC_CHANGED
				case KEV_DL_LINK_QUALITY_METRIC_CHANGED: {
					struct kev_dl_link_quality_metric_data * lqm_data;
					lqm_data = (struct kev_dl_link_quality_metric_data *) event_data;

					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					interface_update_quality_metric(ifr_name,
								   lqm_data->link_quality_metric);
					break;
				}
#endif  // KEV_DL_LINK_QUALITY_METRIC_CHANGED

#ifdef	KEV_DL_ISSUES
				case KEV_DL_ISSUES: {
					struct kev_dl_issues *issues;

					issues = (struct kev_dl_issues *)event_data;
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					interface_update_link_issues(ifr_name,
								     issues->timestamp,
								     issues->modid,
								     DLIL_MODIDLEN,
								     issues->info,
								     (bcmp(issues->info, info_zero, DLIL_MODIDLEN) != 0)
									?DLIL_MODARGLEN
									:0);
					break;
				}
#endif	// KEV_DL_ISSUES

				case KEV_DL_SIFFLAGS :
				case KEV_DL_SIFMETRICS :
				case KEV_DL_SIFMTU :
				case KEV_DL_SIFPHYS :
				case KEV_DL_SIFMEDIA :
				case KEV_DL_SIFGENERIC :
				case KEV_DL_ADDMULTI :
				case KEV_DL_DELMULTI :
				case KEV_DL_LINK_ADDRESS_CHANGED :
				case KEV_DL_WAKEFLAGS_CHANGED :
#ifdef  KEV_DL_IFCAP_CHANGED
				case KEV_DL_IFCAP_CHANGED :
#endif	// KEV_DL_IFCAP_CHANGED
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
#ifdef	KEV_ND6_SUBCLASS
		case KEV_ND6_SUBCLASS : {
			eventName = nd6EventNameString(ev_msg->event_code);
			switch (ev_msg->event_code) {
				case KEV_KEV_ND6_RA :
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
#endif	// KEV_ND6_SUBCLASS
		case KEV_LOG_SUBCLASS : {
			break;
		}
		default :
			handled = FALSE;
			break;
	}

	if (handled == FALSE) {
		CFStringRef	evStr;

		evStr = CFStringCreateWithCString(NULL,
						  (eventName != NULL) ? eventName : "New Apple network subclass",
						  kCFStringEncodingASCII);
		logEvent(evStr, ev_msg);
		CFRelease(evStr);
	}
	return;
}
Ejemplo n.º 22
0
void EventsWidget::onServerRoundOverEvent(int winningTeamId)
{
    logEvent("ServerRoundOver", tr("The round has just ended, and %1 won.").arg(winningTeamId));
}
static void
processEvent_Apple_Network(struct kern_event_msg *ev_msg)
{
	const char *			eventName = NULL;
	int				dataLen = (ev_msg->total_size - KEV_MSG_HEADER_SIZE);
	void *				event_data = &ev_msg->event_data[0];
	Boolean				handled = TRUE;
	char				ifr_name[IFNAMSIZ+1];

	switch (ev_msg->kev_subclass) {
		case KEV_INET_SUBCLASS : {
			eventName = inetEventNameString(ev_msg->event_code);
			switch (ev_msg->event_code) {
				case KEV_INET_NEW_ADDR :
				case KEV_INET_CHANGED_ADDR :
				case KEV_INET_ADDR_DELETED :
				case KEV_INET_SIFDSTADDR :
				case KEV_INET_SIFBRDADDR :
				case KEV_INET_SIFNETMASK : {
					struct kev_in_data * ev;

					ev = (struct kev_in_data *)event_data;
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_update_ipv4(NULL, ifr_name);
					break;
				}
				case KEV_INET_ARPCOLLISION : {
					struct kev_in_collision * ev;

					ev = (struct kev_in_collision *)event_data;
					if ((dataLen < sizeof(*ev))
					    || (dataLen < (sizeof(*ev) + ev->hw_len))) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_collision_ipv4(ifr_name,
								 ev->ia_ipaddr,
								 ev->hw_len,
								 ev->hw_addr);
					break;
				}
				default :
					handled = FALSE;
					break;
			}
			break;
		}
		case KEV_INET6_SUBCLASS : {
			struct kev_in6_data * ev;

			eventName = inet6EventNameString(ev_msg->event_code);
			ev = (struct kev_in6_data *)event_data;
			switch (ev_msg->event_code) {
				case KEV_INET6_NEW_USER_ADDR :
				case KEV_INET6_CHANGED_ADDR :
				case KEV_INET6_ADDR_DELETED :
				case KEV_INET6_NEW_LL_ADDR :
				case KEV_INET6_NEW_RTADV_ADDR :
				case KEV_INET6_DEFROUTER :
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
					interface_update_ipv6(NULL, ifr_name);
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
		case KEV_DL_SUBCLASS : {
			struct net_event_data * ev;

			eventName = dlEventNameString(ev_msg->event_code);
			ev = (struct net_event_data *)event_data;
			switch (ev_msg->event_code) {
				case KEV_DL_IF_ATTACHED :
					/*
					 * new interface added
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_add(ifr_name);
					break;

				case KEV_DL_IF_DETACHED :
					/*
					 * interface removed
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_remove(ifr_name);
					break;

				case KEV_DL_IF_DETACHING :
					/*
					 * interface detaching
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					interface_detaching(ifr_name);
					break;

				case KEV_DL_SIFFLAGS :
				case KEV_DL_SIFMETRICS :
				case KEV_DL_SIFMTU :
				case KEV_DL_SIFPHYS :
				case KEV_DL_SIFMEDIA :
				case KEV_DL_SIFGENERIC :
				case KEV_DL_ADDMULTI :
				case KEV_DL_DELMULTI :
					handled = FALSE;
					break;

				case KEV_DL_PROTO_ATTACHED :
				case KEV_DL_PROTO_DETACHED : {
					struct kev_dl_proto_data * protoEvent;

					protoEvent = (struct kev_dl_proto_data *)event_data;
					if (dataLen < sizeof(*protoEvent)) {
						handled = FALSE;
						break;
					}
					copy_if_name(&protoEvent->link_data,
						     ifr_name, sizeof(ifr_name));
					if (protoEvent->proto_remaining_count == 0) {
						mark_if_down(ifr_name);
					} else {
						mark_if_up(ifr_name);
					}
					break;
				}

				case KEV_DL_LINK_OFF :
				case KEV_DL_LINK_ON :
					/*
					 * update the link status in the store
					 */
					if (dataLen < sizeof(*ev)) {
						handled = FALSE;
						break;
					}
					copy_if_name(ev, ifr_name, sizeof(ifr_name));
					link_update_status(ifr_name, FALSE);
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
		case KEV_ATALK_SUBCLASS: {
			struct kev_atalk_data * ev;

			eventName = atalkEventNameString(ev_msg->event_code);
			ev = (struct kev_atalk_data *)event_data;
			if (dataLen < sizeof(*ev)) {
				handled = FALSE;
				break;
			}
			copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name));
			switch (ev_msg->event_code) {
				case KEV_ATALK_ENABLED:
					interface_update_atalk_address(ev, ifr_name);
					break;

				case KEV_ATALK_DISABLED:
					interface_update_shutdown_atalk();
					break;

				case KEV_ATALK_ZONEUPDATED:
					interface_update_atalk_zone(ev, ifr_name);
					break;

				case KEV_ATALK_ROUTERUP:
				case KEV_ATALK_ROUTERUP_INVALID:
				case KEV_ATALK_ROUTERDOWN:
					interface_update_appletalk(NULL, ifr_name);
					break;

				case KEV_ATALK_ZONELISTCHANGED:
					break;

				default :
					handled = FALSE;
					break;
			}
			break;
		}
		default :
			handled = FALSE;
			break;
	}

	if (handled == FALSE) {
		CFStringRef	evStr;

		evStr = CFStringCreateWithCString(NULL,
						  (eventName != NULL) ? eventName : "New Apple network subclass",
						  kCFStringEncodingASCII);
		logEvent(evStr, ev_msg);
		CFRelease(evStr);
	}
	return;
}
Ejemplo n.º 24
0
void EventsWidget::onServerRoundOverPlayersEvent(const QString &playerInfo)
{
    logEvent("ServerRoundOverPlayers", tr("The round has just ended, and %1 is the final detailed player stats.").arg(playerInfo)); // TODO: Check what this actually outputs.
}
MdamIntervalList::MdamIntervalList(const Lng32 callerTag)
         : firstIntervalPtr_(0), lastIntervalPtr_(0),
           intervalListId_(NA_JulianTimestamp())
{
  logEvent(5,0,-1,callerTag);
}
Ejemplo n.º 26
0
void EventsWidget::onServerRoundOverTeamScoresEvent(const QString &teamScores)
{
    logEvent("ServerRoundOverTeamScores", tr("The round has just ended, and %1 is the final ticket/kill/life count for each team.").arg(teamScores));
}
Ejemplo n.º 27
0
void	sptrace_log_memo(PsmPartition trace, unsigned long addr, char *text,
		char *fileName, int lineNbr)
{
	if (!trace) return;
	logEvent(trace, OP_MEMO, addr, -1, text, fileName, lineNbr, NULL);
}
Ejemplo n.º 28
0
/* Connection */
void EventsWidget::onConnected()
{
    logEvent("Connected", tr("Connected to %1:%2.").arg(m_connection->socket->peerAddress().toString()).arg(m_connection->socket->peerPort()));
}
Ejemplo n.º 29
0
void threadUsbMain(void*)
{
	int t;

	logEvent(LOG_THREAD_USB, "USB thread launched");

	usbInit();
	
	logEvent(LOG_THREAD_USB, "USB module initialized");

	while(1==1)
	{
		threadCopyContentDefaultUsbOut();
		threadCopyContentCoreUsbOut();
		usbHandler();
		usbService();

		if ((usbStreamVideo)&(usbConnected))
		{
			Sleep(0);
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
		}
		else
		{
			Sleep(100);
			SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
		}

	}

/*
	int a;
	unsigned char buf2[64];
	int lastPreviewUsbStreamVideo;
	lastPreviewUsbStreamVideo=2;
	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
	int i;
	for(i=0;i<64;i++)
		buf2[i]=0;
	while (1==1)
	{

		threadCopyContentPreviewSetupOut2();

		if (previewUsbConnect)
		{
			usbConnect();
			previewUsbConnect=0;
			usbStatusService();
		}
		if (previewUsbDisconnect)
		{
			usbDisconnect();
			previewUsbDisconnect=0;
		}
		if (lastPreviewUsbStreamVideo!=previewUsbStreamVideo)
		{
			lastPreviewUsbStreamVideo=previewUsbStreamVideo;
			usbStatusService();
		}

		if (usbPipeStrmIn!=INVALID_HANDLE_VALUE)
			Sleep(0);
		else
			Sleep(500);

		WaitForSingleObject(threadMutexUsbBufferAccess, INFINITE);
		usbCopyToUsbBuffer();
	//	j=threadOpenglFrameRate;
		ReleaseMutex(threadMutexUsbBufferAccess);
		usbService(&usbUsbBuffer[0], &buf2[0]);
	}	*/


}
Ejemplo n.º 30
0
InternalIOWork::InternalIOWork(IOService& serv, const String& name)
 : InternalIOService::work(serv.asioService()),
   mName(name)
{
    logEvent("created");
}