Beispiel #1
0
void write_request(struct connection *conn)
{
	int n; /* must be signed. windows does not support ssize_t */

#ifdef WANT_SSL
	if (conn->ssl) {
		n = openssl_write(conn);
		/* openssl_write can return -EAGAIN if the SSL
		 * connection needs a read or write. */
		if (n == -EAGAIN)
			return;
	} else
#endif
		n = send(conn->poll->fd, conn->curp, conn->length,
			 MSG_NOSIGNAL);

	if (n == conn->length) {
		if (verbose > 2)
			printf("+ Sent request\n");
		conn->length = 0;

		/* reset for read */
		set_readable(conn);
		reset_buf(conn);
		NEXT_STATE(conn, read_reply);
	} else if (n > 0) {
		conn->length -= n;
		conn->curp += n;
	} else {
		printf("Write request error\n");
		fail_connection(conn);
	}
}
void sM_LTE_RrcConnectionRelease::start(void)
{
    sM_LteMlDefault::start();

    DECL_NEW_LTE_RRC_PDU( rrcConnectionRelease, DL_DCCH, RRCConnectionRelease, xmlRRCConnectionRelease.c_str() );

    if ( ReleaseCause != -1 )
    {
        rrcConnectionRelease.pdu->criticalExtensions()->c1()->rrcConnectionRelease_r8()->releaseCause()->set(ReleaseCause);
    }

    if ( RedirCarrierInfo_eutra != -1 )
    {
        rrcConnectionRelease.pdu->criticalExtensions()->c1()->rrcConnectionRelease_r8()->setActive_redirectedCarrierInfo(true);
        rrcConnectionRelease.pdu->criticalExtensions()->c1()->rrcConnectionRelease_r8()->redirectedCarrierInfo()->eutra()->set(RedirCarrierInfo_eutra);
    }

    OUTPUT( SAP_LTE_NET_CRRC, NEW_ASP_WITH_DL_DCCH_RRC_PDU( rrcConnectionRelease ) );

    GCO_DUMP(rrcConnectionRelease.pdu);

    delete &rrcConnectionRelease;

    PE_PRINT(" UE <- SS  RRC: RRCConnectionRelease" );

    NEXT_STATE ( CrrcInfoInd );
}
Beispiel #3
0
BOOL IsUTF8_Notepad2(const char* pTest,int nLength)
{
	static int byte_class_table[256] = {
		/*       00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  */
		/* 00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		/* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		/* 90 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
		/* A0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
		/* B0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
		/* C0 */ 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
		/* D0 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
		/* E0 */ 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7,
		/* F0 */ 9,10,10,10,11, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
		/*       00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F  */ };

	/* state table */
	typedef enum {
		kSTART = 0,kA,kB,kC,kD,kE,kF,kG,kERROR,kNumOfStates } utf8_state;

		static utf8_state state_table[] = {
			/*                            kSTART, kA,     kB,     kC,     kD,     kE,     kF,     kG,     kERROR */
			/* 0x00-0x7F: 0            */ kSTART, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0x80-0x8F: 1            */ kERROR, kSTART, kA,     kERROR, kA,     kB,     kERROR, kB,     kERROR,
			/* 0x90-0x9f: 2            */ kERROR, kSTART, kA,     kERROR, kA,     kB,     kB,     kERROR, kERROR,
			/* 0xa0-0xbf: 3            */ kERROR, kSTART, kA,     kA,     kERROR, kB,     kB,     kERROR, kERROR,
			/* 0xc0-0xc1, 0xf5-0xff: 4 */ kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xc2-0xdf: 5            */ kA,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xe0: 6                 */ kC,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xe1-0xec, 0xee-0xef: 7 */ kB,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xed: 8                 */ kD,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xf0: 9                 */ kF,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xf1-0xf3: 10           */ kE,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR,
			/* 0xf4: 11                */ kG,     kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR, kERROR };

#define BYTE_CLASS(b) (byte_class_table[(unsigned char)b])
#define NEXT_STATE(b,cur) (state_table[(BYTE_CLASS(b) * kNumOfStates) + (cur)])

			utf8_state current = kSTART;
			int i;

			const char* pt = pTest;
			int len = nLength;

			for(i = 0; i < len ; i++, pt++) 
			{

				current = NEXT_STATE(*pt,current);
				if (kERROR == current)
					break;
			}

			return (current == kSTART) ? TRUE : FALSE;
}
Beispiel #4
0
void sM_LTE_Paging::start(void)
{
  sM_LteMlDefault::start();

  if( globaldata_base->getUEIdentity(UEIdentity)->IsIMSIpresent() )
  {
    imsi_digits = globaldata_base->getUEIdentity(UEIdentity)->getIMSI();
  }
  else
  {
    imsi_digits = null;
  }

  imsiLength = strlen(imsi_digits);

  DECL_NEW_LTE_RRC_PDU( pagingmsg, PCCH, Paging, xmlPaging.c_str() );

  _CrrcAsp* pagingasp = NEW_ASP_WITH_PCCH_RRC_PDU( pagingmsg, globaldata_lte->getCellConfig(CellNumber)->getCellHandle());
  pagingasp->Choice()->CrrcPcchMessageReq()->RrcCellHandle()->set( globaldata_lte->getCellConfig(CellNumber)->getCellHandle());

  if( imsi_digits != null )
  {
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInfoPresence()->set(MDDB::Lte::Rrc::Crrc::_UeSpecificInfoPresence::UE_SPECIFIC_INFO_PRESENT);
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->setActive_UeSpecificInfo();
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->NumImsiDigits()->set(imsiLength);
    pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->Imsi()->setElementCount( pagingasp, imsiLength);

    for( int i=0; i<imsiLength; i++ )
    {
      pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->IMSI()->Imsi()->BcdDigit(i)->set((imsi_digits[i]-'0'));
      PRINTERR(("%d",(imsi_digits[i]-'0')));
    }
    PRINTERR(("\n"));
  }

  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->PageRepetitions()->set(NUM_OF_PAGEING_REPTITIONS);
  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->PageInfoUeSpecificIdle()->UeSpecificIdleDrxCycleLength()->set(DRX_CYCLE_LENGTH);
  pagingasp->Choice()->CrrcPcchMessageReq()->UeSpecificInformation()->UeSpecificInfo()->ResponseSupervisionDuration()->set(PAGE_RESPONSE_TIMER);

  OUTPUT( SAP_LTE_NET_CRRC, pagingasp );
  PE_PRINT(" UE <- SS  RRC: Paging" );

  GCO_DUMP(pagingasp);

  if (Failure == false )
    notifyCompletion(EV_OK);
  else
    NEXT_STATE ( ReplyState );
}
void sM_LTE_RrcConnectionReestablishment::start(void)
{
  sM_LteMlDefault::start();

  PE_PRINT("           TC: Waiting for RRCConnectionReestablishmentRequest" );

  if ( WaitTimer == 0 )
  {
    rsDefaultTimer->set(WAIT_RRC_REQ);
  }
  else
  {
    rsDefaultTimer->set(WaitTimer);
  }

  NEW_LTE_RRC_PDU( rrcConnectionReestablishment, DL_CCCH, RRCConnectionReestablishment, xmlRRCConnectionReestablishment.c_str() );

  // Temporary hardcoding

  if ( rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->isActive_mac_MainConfig() )
  {
    if ( LteReferenceTestConditions->getDRX_support() == 0 )
      rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->mac_MainConfig()->explicitValue()->setActive_drx_Config(false);
    if ( LteReferenceTestConditions->getPHR_support() == 0 )
      rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->mac_MainConfig()->explicitValue()->setActive_phr_Config(false);
    if ( LteReferenceTestConditions->getTAT_support() == 0 )
      rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->mac_MainConfig()->explicitValue()->timeAlignmentTimerDedicated()->set(7);
  }

  if ( rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->isActive_physicalConfigDedicated() )
  {
    if ( LteReferenceTestConditions->getTargetPowerSupport() == 0 )
    {
      if ( rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->physicalConfigDedicated()->isActive_uplinkPowerControlDedicated() )
        rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->physicalConfigDedicated()->uplinkPowerControlDedicated()->accumulationEnabled()->set(0);
    }
    if ( LteReferenceTestConditions->getSRS_support() == 0 )
      rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->physicalConfigDedicated()->soundingRS_UL_ConfigDedicated()->setActive_release();
    if ( LteReferenceTestConditions->getCQI_support() == 0 )
      rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->radioResourceConfigDedicated()->physicalConfigDedicated()->setActive_cqi_ReportConfig(false);
  }

  NEXT_STATE ( RRCConnectionReestablishmentRequest );
}
void sM_LTE_OpenLoopbackActivation::start(void)
{
	sM_LteMlDefault::start();
	
	DECL_NEW_ETC_PDU( sendpdu, EtcOpenUeTestLoop, xmlOpenUeTestLoop.c_str() );
	
	GCO_DUMP(sendpdu.pdu);
	
	OUTPUT( SAP_LTE_NET_CRRC, NEW_ASP_WITH_EPS_NAS_PDU( sendpdu, UEid ) );
	delete &sendpdu;
	
	PE_PRINT(" UE <- UE  RRC: DlInformationTransfer" );
	PE_PRINT("           NAS: OPEN UE TEST LOOP" );
	PE_PRINT("           TC: Waiting for Open UE Test Loop Complete" );
	
	rsDefaultTimer->set(GEN_EPSSM_TIMER);
	
	NEXT_STATE ( OpenUeTestLoopComplete );
}
/*! **********************************************************************
 * Function: main(void)
 *
 * \brief Program entry point
 *
 * Include: Local to newmain.c
 *
 * Description: stores the current system state and manages all transitions
 *
 * Arguments: None
 *
 * Returns: None
 *************************************************************************/
void main() {
    systemState state = {INIT, UNDEF};
    TrackingData target;


//    configureSerial();
//    configureRange();
    //configureAD();
    initialiseMenu(&state);

    for (;;)
    {
       	serviceMenu();

        switch (state.current)
        {
            case INIT:
                initialization(&state);
                break;
            case SRCH:
                search(&state);
                dispSearching();
                break;
            case TRCK:
                target = track(&state);
                dispTrack(target);
                break;
            case MENU:
                break;
            case RAW_RANGE_STATE:
                range();
                dispRawRange();
                Delay10KTCYx(255);
                break;
            default:     //Any other undefined state
                NEXT_STATE(INIT, state);       //Set the next state to be Initialize
                break;
        }
    }

}
void sM_LTE_RrcConnectionReconfiguration_meas_xml::start(void)
{
  sM_LteMlDefault::start();

  /******************************************************************************/
  /* SS->UE  RRC: RRCConnectionReconfiguration                                  */
  /******************************************************************************/

  DECL_NEW_LTE_RRC_PDU( rrcConnectionReconfiguration, DL_DCCH, RRCConnectionReconfiguration, xmlRRCConnectionReconfiguration.c_str() );

  CodecContext *cc = rrcConnectionReconfiguration.root->code();

  // Serving cell and intra-freq neigbours
  rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(0)->measObject()->measObjectEUTRA()->carrierFreq()->set(cc, CarrierFreq_cell0);
  rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(0)->measObject()->measObjectEUTRA()->allowedMeasBandwidth()->set(cc, AllowedMeasBandwidth_cell0);

  if ( MeasType == 1 )
  {
    // Inter-freq neigbour
    rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(1)->measObject()->measObjectEUTRA()->carrierFreq()->set(cc, CarrierFreq_cell1);
    rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(1)->measObject()->measObjectEUTRA()->allowedMeasBandwidth()->set(cc, AllowedMeasBandwidth_cell1);
  }

  _CrrcAsp* pCrrcAsp = NEW_ASP_WITH_DL_DCCH_RRC_PDU( rrcConnectionReconfiguration, globaldata_lte->getUEIdentity(0)->getUEHandle() );
  pCrrcAsp->Choice()->CrrcDlDcchMessageReq()->SupervisionDuration()->set(WAIT_RRC_RECONF);

  OUTPUT( SAP_LTE_NET_CRRC, pCrrcAsp);

  GCO_DUMP(rrcConnectionReconfiguration.pdu);

  delete &rrcConnectionReconfiguration;

  PE_PRINT(" SS -> UE  RRC: RRCConnectionReconfiguration " );

  PE_PRINT("           TC: Waiting for RRCConnectionReconfigurationComplete" );

  NEXT_STATE ( RRCConnectionReconfigurationComplete );
}
Beispiel #9
0
/* State function */
static int read_chunkblock(struct connection *conn)
{
	size_t bytes;

	bytes = conn->endp - conn->curp;
	if (bytes > (size_t)conn->length)
		bytes = conn->length;

	if (bytes > 0) {
		if (conn->zs) {
			if (write_output_gzipped(conn, bytes) < 0) {
				printf("Gzipped write error\n");
				return 1;
			}
		} else if (!write_output(conn, bytes))
			return 1;
	}

	conn->length -= bytes;
	if (conn->length <= 0) {
		if (verbose > 1)
			printf("Read block\n");
		conn->curp += bytes;
		conn->length = 0;
		conn->cstate = CS_START_CR;
		NEXT_STATE(conn, read_file_chunked);
		if (conn->endp > conn->curp)
			return read_file_chunked(conn);
		else if (conn->rlen == 0)
			reset_buf(conn);
		return 0;
	}

	reset_buf(conn);
	return 0;
}
ON_LTE_UL_CCCH_RRC_PDU( sM_LTE_RrcConnectionReestablishment, RRCConnectionReestablishmentRequest, RRCConnectionReestablishmentRequest )
{
  rsDefaultTimer->reset();

  GCO_DUMP(pdu);

  Rnti = asp->Rnti()->get();
  std::string tmp = cmw_Utils(" UE -> SS  RRC: RRCConnectionReestablishmentRequest (Cell #%i)", asp->RrcCellHandle()->get() );
  PE_PRINT(tmp.c_str());

  if ( xmlRRCConnectionReestablishmentRequest != "" )
  {
    if ( GCO_MATCHF(root, xmlRRCConnectionReestablishmentRequest.c_str()) )
    {
      PE_PRINT("####### Message is OK #######" );
    }
    else
    {
      PE_ERR("####### Message is NOK #######" );
      NOTIFY_COMPLETION_FAILURE();
    }
  }

  if ( CellHandleTarget != -1 )
  {
    if ( asp->RrcCellHandle()->get() != CellHandleTarget )
    {
      std::string tmp = cmw_Utils("####### Message received in wrong cell (%i), Valid cell is %i #######", asp->RrcCellHandle()->get(), CellHandleTarget );
      PE_ERR(tmp.c_str());
      NOTIFY_COMPLETION_FAILURE();
      retcode = EV_FAIL;
    }
  }

  NEXT_STATE ( GetMacUeId );
}
Beispiel #11
0
/* State function */
static int read_file_chunked(struct connection *conn)
{
	if (conn->curp >= conn->endp) {
		printf("Hmmm, %s already empty (%d)\n", conn->url, conn->rlen);
		return 1;
	}

	if (conn->cstate == CS_START_CR) {
		if (*conn->curp != '\r') {
			printf("BAD CHUNK END '%02x'\n", *conn->curp);
			return 1;
		}
		conn->cstate = CS_START_LF;
		INC_CURP(conn);
	}

	if (conn->cstate == CS_START_LF) {
		if (*conn->curp != '\n') {
			printf("BAD CHUNK END '%02x'\n", *conn->curp);
			return 1;
		}
		conn->cstate = CS_DIGITS;
		INC_CURP(conn);
	}

	if (conn->curp == conn->endp)
		return 0; /* Need to read next chunk */

	if (conn->cstate == CS_DIGITS) {
		while (isxdigit(*conn->curp)) {
			if (isdigit(*conn->curp))
				conn->length = conn->length * 16 +
					*conn->curp - '0';
			else
				conn->length = conn->length * 16 +
					tolower(*conn->curp) - 'a' + 10;
			INC_CURP(conn);
		}
		conn->cstate = CS_END_CR;
	}

	if (conn->cstate == CS_END_CR) {
		/* Apache seems to tack on spaces (for last real block?) */
		while (*conn->curp == ' ')
			INC_CURP(conn);

		if (*conn->curp != '\r') {
			printf("BAD CHUNK LINE '%02x'\n", *conn->curp);
			return 1;
		}
		conn->cstate = CS_END_LF;
		INC_CURP(conn);
	}

	if (*conn->curp != '\n') {
		printf("BAD CHUNK LINE '%02x'\n", *conn->curp);
		return 1;
	}
	++conn->curp; /* not INC_CURP */

	if (conn->length > 0) {
		if (verbose > 2)
			printf("Chunk %x = %d\n", conn->length, conn->length);
		NEXT_STATE(conn, read_chunkblock);
		return read_chunkblock(conn);
	}

	if (verbose > 1)
		printf("Last chunk\n");
	conn->cstate = CS_NONE;
	if (conn->regexp && !conn->matched)
		return do_process_html(conn);
	close_connection(conn);
	return 0;
}
Beispiel #12
0
/* State function */
int read_reply(struct connection *conn)
{
	char *p, *fname;
	int status = 1;
	int chunked = 0;
	int needopen = 1;

	p = strstr(conn->buf, "\n\r\n");
	if (p) {
		*(p + 1) = '\0';
		conn->curp = p + 3;
		if (verbose > 1)
			printf("- Reply %d bytes\n",
			       (int)(conn->curp - conn->buf));
	} else if (conn->curp == conn->endp) {
		printf("Unexpected reply EOF %s\n", conn->url);
		return 1;
	} else if (conn->rlen > 0) {
		/* I have never seen this happen */
		conn->curp = conn->endp;
		return 0;
	} else {
		/* I have seen this once: the reply did not contain
		 * CRs, just LFs */
		printf("REPLY TOO LONG %s\n", conn->url);
		return 1;
	}

	if (verbose > 2)
		fputs(conn->buf, stdout);

	if (strncmp(conn->buf, "HTTP/1.1 ", 9) &&
		strncmp(conn->buf, "HTTP/1.0 ", 9)) {
		if (verbose)
			printf("%s: Bad status line %s\n",
				   conn->host, conn->buf);
		return 1;
	}

	status = strtol(conn->buf + 9, NULL, 10);

	switch (status) {
	case 200: /* OK */
		if (verbose)
			printf("200 %s\n", conn->url);

		p = strstr(conn->buf, "Content-Length:");
		if (!p)
			p = strstr(conn->buf, "Content-length:");
		conn->length = p ? strtol(p + 15, NULL, 10) : 0;

		p = strstr(conn->buf, "Transfer-Encoding:");
		if (p) {
			p += 18;
			while (isspace(*p))
				++p;
			if (strncmp(p, "chunk", 5) == 0) {
				if (verbose > 1)
					printf("Chunking\n");
				chunked = 1;
			} else
				printf("OH oh. %s: %s", conn->host, p);
		}
		p = strstr(conn->buf, "Content-Encoding:");
		if (p) {
			p += 17;
			while (isspace(*p))
				++p;
			if (strncmp(p, "gzip", 4) == 0) {
				if (verbose > 1)
					printf("GZIP\n");
				if (gzip_init(conn))
					return 1;
			} else
				printf("OH oh. %s: %s", conn->host, p);
		}
		if (verbose > 1 && conn->length == 0 && !chunked)
			printf("Warning: No content length for %s\n",
				   conn->url);
		break;

	case 301: /* Moved Permanently */
	case 302: /* Moved Temporarily */
		return redirect(conn, status);

	case 0:
		printf("HUH? NO STATUS\n");
		status = 2;
		/* fall thru */
	default:
		printf("%d: %s\n", status, conn->url);
		return status;
	}

	if (*method == 'H') {
		/* for head request we are done */
		close_connection(conn);
		return 0;
	}

	if (conn->regexp && !conn->matched)
		fname = conn->regfname;
	else
		needopen = 0; /* defer open */

	if (needopen) {
		conn->out = open(fname, WRITE_FLAGS, 0664);
		if (conn->out < 0) {
			my_perror(fname);
			return 1;
		}

		if (verbose > 1)
			printf("Output %s -> %s\n", conn->url, fname);
	} else if (verbose > 1)
		printf("Output %s deferred\n", conn->url);

	if (chunked) {
		conn->cstate = CS_DIGITS;
		NEXT_STATE(conn, read_file_chunked);
		conn->length = 0; /* paranoia */
	} else if (conn->zs) {
		NEXT_STATE(conn, read_file_gzip);
	} else if (conn->length == 0)
		NEXT_STATE(conn, read_file_unsized);
	else
		NEXT_STATE(conn, read_file);

	if (conn->curp < conn->endp)
		return conn->func(conn);

	return 0;
}
void sM_LTE_RrcConnectionReconfiguration_meas::start(void)
{
  sM_LteMlDefault::start();

  /******************************************************************************/
  /* SS->UE  RRC: RRCConnectionReconfiguration                                  */
  /******************************************************************************/

  DECL_NEW_LTE_RRC_PDU( rrcConnectionReconfiguration, DL_DCCH, RRCConnectionReconfiguration, xmlRRCConnectionReconfiguration.c_str() );

  CodecContext *cc = rrcConnectionReconfiguration.root->code();

  // Serving cell
  rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(0)->measObject()->measObjectEUTRA()->carrierFreq()->set(cc, CarrierFreq);
  rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->measObjectToAddModList()->value(0)->measObject()->measObjectEUTRA()->allowedMeasBandwidth()->set(cc, AllowedMeasBandwidth);

  // EventA1
  if ( rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->isActive_eventA1() )
  {
    if ( RsrpOrRsrq == false )
    {
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA1()->a1_Threshold()->setActive_threshold_RSRP();
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA1()->a1_Threshold()->threshold_RSRP()->set(cc, Threshold);
    }
    else
    {
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA1()->a1_Threshold()->setActive_threshold_RSRQ();
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA1()->a1_Threshold()->threshold_RSRQ()->set(cc, Threshold);
    }
  }

  // EventA2
  if ( rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->isActive_eventA2() )
  {
    if ( RsrpOrRsrq == false )
    {
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA2()->a2_Threshold()->setActive_threshold_RSRP();
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA2()->a2_Threshold()->threshold_RSRP()->set(cc, Threshold);
    }
    else
    {
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA2()->a2_Threshold()->setActive_threshold_RSRQ();
      rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->eventId()->eventA2()->a2_Threshold()->threshold_RSRQ()->set(cc, Threshold);
    }
  }

  rrcConnectionReconfiguration.pdu->criticalExtensions()->c1()->rrcConnectionReconfiguration_r8()->measConfig()->reportConfigToAddModList()->value(0)->reportConfig()->reportConfigEUTRA()->triggerType()->event()->hysteresis()->set(cc, Hysteresis);

  _CrrcAsp* pCrrcAsp = NEW_ASP_WITH_DL_DCCH_RRC_PDU( rrcConnectionReconfiguration, globaldata_lte->getUEIdentity(0)->getUEHandle() );
  pCrrcAsp->Choice()->CrrcDlDcchMessageReq()->SupervisionDuration()->set(WAIT_RRC_RECONF);

  OUTPUT( SAP_LTE_NET_CRRC, pCrrcAsp);

  GCO_DUMP(rrcConnectionReconfiguration.pdu);

  delete &rrcConnectionReconfiguration;

  PE_PRINT(" SS -> UE  RRC: RRCConnectionReconfiguration " );

  PE_PRINT("           TC: Waiting for RRCConnectionReconfigurationComplete" );

  NEXT_STATE ( RRCConnectionReconfigurationComplete );
}
Beispiel #14
0
int
smellslike_ssl_request(const struct NetFrame *frame, struct SmellsSSL *smell, const unsigned char *px, unsigned length)
{
	unsigned state = smell->state;
	unsigned offset = 0;
#define NEXT_STATE(state, offset, lenth) if (++state == 0 || ++offset >= length) break
	while (offset < length)
	switch (state) {
	case (unsigned)-1:
		//offset = length;
		smell->state = state;
		return 0;
		break;

	case 0:
		smell->type = px[offset];
		switch (px[offset]) {
		case 22:
			NEXT_STATE(state, offset, length);
			break;
		default:
			state = (unsigned)-1;
			continue;
		}

	case 1: /*version major */
		smell->version_major = px[offset];
		switch (px[offset]) {
		case 3:
			NEXT_STATE(state, offset, length);
			break;
		default:
			state = (unsigned)-1;
			continue;
		}

	case 2: /* version minor */
		smell->version_minor = px[offset];
		NEXT_STATE(state, offset, length);

	case 3:
		smell->length = px[offset]<<8;
		NEXT_STATE(state, offset, length);

	case 4:
		smell->length |= px[offset];
		if (smell->length < 10) {
			state = (unsigned)-1;
			continue;
		}
		NEXT_STATE(state, offset, length);

	case 5:
		smell->subtype = px[offset];
		switch (px[offset]) {
		case 1:
			NEXT_STATE(state, offset, length);
			break;
		case 16:
			state = (unsigned)-1;
			continue;
		}

	case 6:
		if (px[offset] != 0) {
			state = (unsigned)-1;
			continue;
		}
		NEXT_STATE(state, offset, length);

	case 7:
		smell->inner_length = px[offset]<<8;
		NEXT_STATE(state, offset, length);

	case 8:
		smell->inner_length |= px[offset];
		if (smell->inner_length > smell->length+4) {
			state = (unsigned)-1;
			continue;
		}
		if (smell->inner_length < 10) {
			state = (unsigned)-1;
			continue;
		}
		if (smell->inner_length < smell->length - 10) {
			state = (unsigned)-1;
			continue;
		}
		NEXT_STATE(state, offset, length);

	case 9: /* Handshake: Version Major */
		if (px[offset] != smell->version_major) {
			printf("%u.%u.%u.%u:%u -> %u.%u.%u.%u:%u\n",
				(frame->src_ipv4>>24)&0xFF,
				(frame->src_ipv4>>16)&0xFF,
				(frame->src_ipv4>> 8)&0xFF,
				(frame->src_ipv4>> 0)&0xFF,
				frame->src_port,

				(frame->dst_ipv4>>24)&0xFF,
				(frame->dst_ipv4>>16)&0xFF,
				(frame->dst_ipv4>> 8)&0xFF,
				(frame->dst_ipv4>> 0)&0xFF,
				frame->dst_port

				);
			state = (unsigned)-1;
			continue;
		}
		NEXT_STATE(state, offset, length);

	case 10: /* Handshake: Version Minor */
		NEXT_STATE(state, offset, length);



		return 1;


	}
ON_ASPX( sM_LTE_RrcConnectionReestablishment, GetMacUeId, SAP_LTE_NET_CRRC, MDDB::Lte::Rrc::Crrc, _CrrcAsp, CrrcUpdateUeConfigInd )
{
  globaldata_lte->getUEIdentity()->setUEHandle(asp->RrcUeHandle()->get());
  globaldata_lte->getUEIdentity()->setMacUeId(asp->MacUeId()->get());
  globaldata_lte->getUEIdentity()->setCRNTI(asp->Crnti()->get());

  UeId = asp->MacUeId()->get();
  globaldata_lte->getUEIdentity(0)->setncc( rrcConnectionReestablishment.pdu->criticalExtensions()->c1()->rrcConnectionReestablishment_r8()->nextHopChainingCount()->get() );

  PE_PRINT("           TC: Security input parameters");
  PE_PRINT("           TC: PhyCellId = " << globaldata_lte->getCellConfig(CellHandleSource)->getPhyCellId() );
  PE_PRINT("           TC: DLEARFCN = " << globaldata_lte->getCellConfig(CellHandleSource)->getDLEARFCN() );
  PE_PRINT("           TC: NCC = " << globaldata_lte->getUEIdentity(0)->getncc() );

  RUN_NEWP_STATEMACHINE ( sM_LTE_CrrcSecurityConfigReq, null,
    (
    0,               // CorruptKenb
    true,            // ReestablishmentOrHandover
    CellHandleSource // CellId
    )
  );

  if ( LteReferenceTestConditions->getPx_TimingAdvance() != -1 )
  {
    RUN_NEWP_STATEMACHINE ( sM_LTE_TimingAdvance, null,
      (
      std::string("Lte_CmacTimingControlConfigReq.xml"), // CmacTimingControlConfigReq
      UeId                                               // UeId
      )
    );

    RUN_NEWP_STATEMACHINE ( sM_SystemTC, null, ( TC_PRELIMINARY_VERDICT, retcode=MLAPI::lastRunReturnCode ));
  }

  if ( LteReferenceTestConditions->getTargetPowerSupport() == 1 )
  {
    RUN_NEWP_STATEMACHINE ( sM_LTE_TxPowerControl, null,
      (
      std::string("Lte_CmacPowerControlConfigReq.xml"),   // CmacPowerControlConfigReq
      LteReferenceTestConditions->getTargetPowerPusch(),  // TargetPowerPusch
      LteReferenceTestConditions->getTargetPowerPucch(),  // TargetPowerPucch
      UeId                                                // UeId
      )
    );

    RUN_NEWP_STATEMACHINE ( sM_SystemTC, null, ( TC_PRELIMINARY_VERDICT, retcode=MLAPI::lastRunReturnCode ));
  }

  if( EV_OK == retcode )
  {
    pCrrcAsp = NEW_ASP_WITH_DL_CCCH_RRC_PDU ( rrcConnectionReestablishment, asp->RrcUeHandle()->get(), Rnti );
    pCrrcAsp->Choice()->CrrcDlCcchMessageReq()->SupervisionDuration()->set(GEN_RRC_TIMER);

    GCO_DUMP(rrcConnectionReestablishment.pdu);

    OUTPUT( SAP_LTE_NET_CRRC, pCrrcAsp );

    PE_PRINT(" SS -> UE  RRC: RRCConnectionReestablishment " );

    PE_PRINT("           TC: Waiting for RRCConnectionReestablishmentComplete" );

    NEXT_STATE( RRCConnectionReestablishmentComplete );
  }
  else
  {
    PE_ERR("####### Timing advance setting failed #######" );
    NOTIFY_COMPLETION_FAILURE();
  }
}
Beispiel #16
0
/* While we're working:
	 * compute better solutions for T seconds
	 * send my fit back to the master process.
	 * get a number back. if it's my rank, broadcast my s array to everyone!
*/
void driver(int rank, int np, data_t D, int n, int k, double p, double tol, long sec, long maxsec)
{
    srand(time(NULL) + rank);

    int s[n];
    gen_starting_set(n, k, s);

    time_t start = time(0), fullstart = start;
    double fit = 0, oldfit = 0;

    int run = 0, stop = 0;

    double *fits = NULL;
    if (rank == 0)
        fits = (double *) malloc(sizeof(double) * np);

    do {

        start = time(0);

        do {
            int u, v;

            fit = NEXT_STATE(D, n, s, k, p, &u, &v, run);

            if (u >= 0)
                s[u] = 0;
            if (v >= 0)
                s[v] = 1;
        } while(difftime(time(0), start) < sec);

        //printf("Run %d, rank %d, fit %g\n", run, rank, fit);

        MPI_Gather(&fit, 1, MPI_DOUBLE, fits, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
        int new_rank = 0;

        /* Master process: find best fit. */
        if (rank == 0) {
            double max = 0;
            for (int i = 0; i < np; i++) {
                printf("Run %d, rank %d, fit %g\n", run, i, fits[i]);
                if (fits[i] > max) {
                    max = fits[i];
                    new_rank = i;
                }
            }
            if (max - oldfit < tol || (difftime(time(0), fullstart) > maxsec)) {
                stop = 1;
            }
            oldfit = max;
        }

        MPI_Bcast(&new_rank, 1, MPI_INT, 0, MPI_COMM_WORLD);

        /* update s, or send it... */
        MPI_Bcast(s, n, MPI_INT, new_rank, MPI_COMM_WORLD);

        MPI_Barrier(MPI_COMM_WORLD);

        if (rank == new_rank) {
            printf("Best fit: %f (rank %d)\n", fit, new_rank);
            print_s(s, n);
        }

        run++;

        MPI_Bcast(&stop, 1, MPI_INT, 0, MPI_COMM_WORLD);
    } while(!stop);
}