Пример #1
0
void Fl_Type::write_properties() 
{
	int level = 0;
	for (Fl_Type* p = parent; p; p = p->parent) level++;
	// repeat this for each attribute:
	if (!label().empty()) {
		write_indent(level+1);
		write_word("label");
		write_word(label());
	}
	if (!user_data().empty()) {
		write_indent(level+1);
		write_word("user_data");
		write_word(user_data());
		if (!user_data_type().empty()) {
			write_word("user_data_type");
			write_word(user_data_type());
		}
	}
	if (!callback().empty()) {
		write_indent(level+1);
		write_word("callback");
		write_word(callback());
	}
	if (is_parent() && open_) write_word("open");
	if (selected) write_word("selected");
	if (!tooltip().empty()) {
		write_indent(level+1);
		write_word("tooltip");
		write_word(tooltip());
	}
}
Пример #2
0
/**
* Activate timer.
*
* @param ctx
*    Pointer to the opaque ZrtpContext structure.
* @param time
*    The time in ms for the timer
* @return
*    zero if activation failed, one if timer was activated
*/
static int32_t ozrtp_activateTimer (ZrtpContext* ctx, int32_t time ) {
	if (user_data(ctx)->timerWillTriggerAt != 0) {
		ortp_error("zrtp_activateTimer while another timer already active");
		return 0;
	}
	struct timeval t;
	gettimeofday(&t,NULL);
	user_data(ctx)->timerWillTriggerAt=time+convert_timeval_to_millis(&t);
	return 1;
}
  TEUCHOS_UNIT_TEST(physics_block, nontemplate_evaluator_builders)
  {
    PHX::KokkosDeviceSession session;

    Teuchos::RCP<panzer::UniqueGlobalIndexer<int,int> > ugi 
          = Teuchos::rcp(new panzer::unit_test::UniqueGlobalIndexer(0,1));
    Teuchos::RCP<const Epetra_Comm> comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));
    panzer::EpetraLinearObjFactory<panzer::Traits,int> elof(comm,ugi);

    Teuchos::RCP<panzer::PhysicsBlock> physics_block = 
      panzer_test_utils::createPhysicsBlock();

    PHX::FieldManager<panzer::Traits> fm;

    Teuchos::ParameterList user_data("User Data");

    physics_block->buildAndRegisterEquationSetEvaluators(fm, user_data);
    physics_block->buildAndRegisterGatherAndOrientationEvaluators(fm, elof, user_data);
    physics_block->buildAndRegisterDOFProjectionsToIPEvaluators(fm, Teuchos::null, user_data);
    physics_block->buildAndRegisterScatterEvaluators(fm, elof, user_data);

    Teuchos::RCP<panzer::ClosureModelFactory_TemplateManager<panzer::Traits> > factory =
      panzer_test_utils::buildModelFactory(); 

    Teuchos::RCP<Teuchos::ParameterList> models = panzer_test_utils::buildModelDescriptors();

    physics_block->buildAndRegisterClosureModelEvaluators(fm,*factory,*models, user_data);
  }
  TEUCHOS_UNIT_TEST(evaluator_factory, basic_construction)
  {
    PHX::KokkosDeviceSession session;

    panzer::FieldLayoutLibrary fl;
    Teuchos::RCP<panzer::IntegrationRule> ir;
    {
      Teuchos::RCP<shards::CellTopology> topo = 
         Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData< shards::Hexahedron<8> >()));
    
      const int num_cells = 20;
      const panzer::CellData cell_data(num_cells,topo);
      const int cubature_degree = 2;      
      ir = Teuchos::rcp(new panzer::IntegrationRule(cubature_degree, cell_data));
      Teuchos::RCP<panzer::BasisIRLayout> basis = Teuchos::rcp(new panzer::BasisIRLayout("Q1",0,*ir));
      
      fl.addFieldAndLayout("Ux",basis);
    }

    std::string model_id = "fluid model";

    Teuchos::ParameterList eqset_params; 

    Teuchos::ParameterList p("Closure Models");
    {
      p.sublist("fluid model").sublist("Density").set<double>("Value",1.0);
      p.sublist("fluid model").sublist("Viscosity").set<double>("Value",1.0);
      p.sublist("fluid model").sublist("Heat Capacity").set<double>("Value",1.0);
      p.sublist("fluid model").sublist("Thermal Conductivity").set<double>("Value",1.0);
    }

    user_app::MyModelFactory<panzer::Traits::Residual> mf;

    Teuchos::RCP< std::vector< Teuchos::RCP<PHX::Evaluator<panzer::Traits> > > > evaluators;

    Teuchos::ParameterList user_data("User Data");

    Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();

    PHX::FieldManager<panzer::Traits> fm;

    evaluators = mf.buildClosureModels(model_id, p, fl, ir, eqset_params, user_data, gd, fm);

    TEST_EQUALITY(evaluators->size(), 8);

    user_app::MyModelFactory_TemplateBuilder builder;
    panzer::ClosureModelFactory_TemplateManager<panzer::Traits> model_factory;
    model_factory.buildObjects(builder);
    evaluators = model_factory.getAsObject<panzer::Traits::Residual>()->buildClosureModels(model_id, p, fl, ir, eqset_params, user_data, gd, fm);

    TEST_EQUALITY(evaluators->size(), 8);

    // Add an unsupported type
    p.sublist("fluid model").sublist("garbage").set<std::string>("Value","help!");
    
    TEST_THROW(model_factory.getAsObject<panzer::Traits::Residual>()->buildClosureModels(model_id, p, fl, ir, eqset_params, user_data, gd, fm), std::logic_error);

  }
Пример #5
0
void extension_and_user_data(int i)
{
  while ((nextbits(8) == EXTENSION_START_CODE) ||
         (nextbits(8) == USER_DATA_START_CODE))
  {
    if (i != 1)
      if (nextbits(8) == EXTENSION_START_CODE)
        extension_data(i);
    if (nextbits(8) == USER_DATA_START_CODE)
      user_data();
  }
}
Пример #6
0
/**
 * Switch off the security for the defined part.
 *
 * @param ctx
 *    Pointer to the opaque ZrtpContext structure.
 * @param part Defines for which part (sender or receiver) to
 *    switch off security
 */
static void ozrtp_srtpSecretsOff (ZrtpContext* ctx, int32_t part ) {
	OrtpZrtpContext *userData = user_data(ctx);

	if (userData->srtpRecv != NULL) {
		srtp_dealloc(userData->srtpRecv);
		userData->srtpRecv=NULL;
	}

	if (userData->srtpSend != NULL) {
		srtp_dealloc(userData->srtpSend);
		userData->srtpSend=NULL;
	}

	ortp_message("ZRTP secrets off");
}
Пример #7
0
void Fl_Canvas::AddPluginName (const string &s, int ID) {
     // There's a bug here, that there's no menu at all if no plugins are found
     // This isn't IMMEDIATELY important, as if you've no plugins - there's nothing to copy/paste/etc anyway.
     if (! (m_Menu)) {
        m_Menu = new Fl_Menu_Button (0, 0, 4, 4, NULL);
        m_Menu->type (Fl_Menu_Button::POPUP123);
        m_Menu->textsize (10);
        m_Menu->add ("Edit/Cut Currently Selected Devices", 0, (Fl_Callback*)cb_CutDeviceGroup, user_data());
        m_Menu->add ("Edit/Copy Currently Selected Devices", 0, (Fl_Callback*)cb_CopyDeviceGroup, user_data());
        m_Menu->add ("Edit/Paste Previously Copied Devices", 0, (Fl_Callback*)cb_PasteDeviceGroup, user_data(), FL_MENU_DIVIDER);
        m_Menu->add ("Edit/Merge Existing Patch", 0, (Fl_Callback*)cb_MergePatch, user_data(), FL_MENU_DIVIDER);
        m_Menu->add ("Edit/Delete Currently Selected Devices", 0, (Fl_Callback*)cb_DeleteDeviceGroup, this);
     }
     m_Menu->add (s.c_str(), 0, (Fl_Callback*)cb_AddDeviceFromMenu, &Numbers[ID]);
}
Пример #8
0
/**
 * Switch on the security.
 *
 * ZRTP calls this method after it has computed the SAS and check
 * if it is verified or not. In addition ZRTP provides information
 * about the cipher algorithm and key length for the SRTP session.
 *
 * This method must enable SRTP processing if it was not enabled
 * during sertSecretsReady().
 *
 * @param ctx
 *    Pointer to the opaque ZrtpContext structure.
 * @param c The name of the used cipher algorithm and mode, or
 *    NULL
 *
 * @param s The SAS string
 *
 * @param verified if <code>verified</code> is true then SAS was
 *    verified by both parties during a previous call.
 */
static void ozrtp_rtpSecretsOn (ZrtpContext* ctx, char* c, char* s, int32_t verified ){
//	OrtpZrtpContext *userData = user_data(ctx);

	// srtp processing is enabled in SecretsReady fuction when receiver secrets are ready
	// Indeed, the secrets on is called before both parts are given to secretsReady.

	OrtpEventData *eventData;
	OrtpEvent *ev;
	ev=ortp_event_new(ORTP_EVENT_ZRTP_SAS_READY);
	eventData=ortp_event_get_data(ev);
	memcpy(eventData->info.zrtp_sas.sas,s,4);
	eventData->info.zrtp_sas.sas[4]=0;
	eventData->info.zrtp_sas.verified=(verified != 0) ? TRUE : FALSE;
	rtp_session_dispatch_event(user_data(ctx)->session, ev);
	ortp_message("ZRTP secrets on: SAS is %s previously verified %s - algo %s", s, verified == 0 ? "no" : "yes", c);
}
Пример #9
0
void Fl_Type::read_property(const Fl_String &c) {
  if (!strcmp(c,"label"))
    label(read_word());
  else if (!strcmp(c,"tooltip"))
    tooltip(read_word());
  else if (!strcmp(c,"user_data"))
    user_data(read_word());
  else if (!strcmp(c,"user_data_type"))
    user_data_type(read_word());
  else if (!strcmp(c,"callback"))
    callback(read_word());
  else if (!strcmp(c,"open"))
    open_ = 1;
  else if (!strcmp(c,"selected"))
    select(this,1);
  else
    read_error("Unknown property \"%s\"", c.c_str());
}
void
test_lifetime()
    {
    int count=0;
    try
        {
        throw test_exception() << test_7(user_data(count));
        BOOST_TEST(false);
        }
    catch(
    boost::exception & x )
        {
        BOOST_TEST(count==1);
        BOOST_TEST( boost::get_error_info<test_7>(x) );
        }
    catch(
    ... )
        {
        BOOST_TEST(false);
        }
    BOOST_TEST(!count);
    }
Пример #11
0
/**
* Send a ZRTP packet via RTP.
*
* ZRTP calls this method to send a ZRTP packet via the RTP session.
*
* @param ctx
*    Pointer to the opaque ZrtpContext structure.
* @param data
*    Points to ZRTP message to send.
* @param length
*    The length in bytes of the data
* @return
*    zero if sending failed, one if packet was sent
*/
static int32_t ozrtp_sendDataZRTP (ZrtpContext* ctx, const uint8_t* data, const int32_t length ){
	OrtpZrtpContext *userData = user_data(ctx);
	RtpSession *session = userData->session;
	struct sockaddr *destaddr=(struct sockaddr*)&session->rtp.rem_addr;
	socklen_t destlen=session->rtp.rem_addrlen;
	ortp_socket_t sockfd=session->rtp.socket;

	// Create ZRTP packet

	int32_t newlength = length + 3*4; // strangely, given length includes CRC size !!!!
	uint32_t* buffer32 = alloca(newlength);
	uint8_t *buffer8=(uint8_t*)buffer32;
	uint16_t *buffer16=(uint16_t*)buffer32;

	uint16_t seqNumber=userData->last_sent_zrtp_seq_number++;

	*buffer8 = 0x10;
	buffer8[1]=0;
	buffer16[1] = htons(seqNumber);
	buffer32[1] = htonl(ZRTP_MAGIC);
	buffer32[2] = htonl(session->snd.ssrc);
	memcpy(buffer32+3, data, length);
	uint32_t cks=zrtp_EndCksum(zrtp_GenerateCksum(buffer8, newlength-CRC_SIZE));
	buffer32[newlength/4-1] = htonl(cks);

	print_zrtp_packet("sent", buffer8);

	// Send packet
	ssize_t bytesSent = sendto(sockfd, (void*)buffer8, newlength,0,destaddr,destlen);
	if (bytesSent == -1 || bytesSent < length) {
		ortp_error("zrtp_sendDataZRTP: sent only %d bytes out of %d", (int)bytesSent, length);
		return 0;
	} else {
		return 1;
	}
}
Пример #12
0
turtle_input::turtle_input(const std::string& path) {
    raptor_world* world = raptor_new_world();
    raptor_parser* parser = raptor_new_parser(world, "turtle");

    unsigned char* uri_string;
    raptor_uri *uri, *base_uri;
    uri_string = raptor_uri_filename_to_uri_string(path.c_str());
    uri = raptor_new_uri(world, uri_string);
    base_uri = raptor_uri_copy(uri);

    std::pair<triples_t*, raptor_uri*> user_data(&triples_, base_uri);
    raptor_parser_set_statement_handler(parser, (void*)&user_data,
                                        &statement_handler);

    triples_.clear();
    raptor_parser_parse_file(parser, uri, base_uri);

    raptor_free_uri(base_uri);
    raptor_free_uri(uri);
    raptor_free_memory(uri_string);

    raptor_free_parser(parser);
    raptor_free_world(world);
}
Пример #13
0
/**
* Cancel the active timer.
*
* @param ctx
*    Pointer to the opaque ZrtpContext structure.
* @return
*    zero if cancel action failed, one if timer was canceled
*/
static int32_t ozrtp_cancelTimer(ZrtpContext* ctx) {
	user_data(ctx)->timerWillTriggerAt=0;
	return 1;
}
Пример #14
0
TEUCHOS_UNIT_TEST(gs_evaluators, gather_constr)
{
    PHX::KokkosDeviceSession session;

    const std::size_t workset_size = 20;
    Teuchos::RCP<panzer::BasisIRLayout> linBasis = buildLinearBasis(workset_size);

    Teuchos::RCP<std::vector<std::string> > fieldNames
        = Teuchos::rcp(new std::vector<std::string>);
    fieldNames->push_back("dog");

    Teuchos::ParameterList pl;
    pl.set("Basis",linBasis);
    pl.set("Field Names",fieldNames);

    Teuchos::RCP<panzer_stk_classic::STK_Interface> mesh = buildMesh(2,2);

    RCP<Epetra_Comm> Comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD));

    Teuchos::RCP<Teuchos::ParameterList> ipb = Teuchos::parameterList("Physics Blocks");
    std::vector<panzer::BC> bcs;
    testInitialzation(ipb, bcs);

    Teuchos::RCP<panzer::FieldManagerBuilder> fmb =
        Teuchos::rcp(new panzer::FieldManagerBuilder);

    // build physics blocks
    //////////////////////////////////////////////////////////////
    Teuchos::RCP<user_app::MyFactory> eqset_factory = Teuchos::rcp(new user_app::MyFactory);
    user_app::BCFactory bc_factory;
    std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physicsBlocks;

    {
        std::map<std::string,std::string> block_ids_to_physics_ids;
        block_ids_to_physics_ids["eblock-0_0"] = "test physics";
        block_ids_to_physics_ids["eblock-1_0"] = "test physics";

        std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
        block_ids_to_cell_topo["eblock-0_0"] = mesh->getCellTopology("eblock-0_0");
        block_ids_to_cell_topo["eblock-1_0"] = mesh->getCellTopology("eblock-1_0");

        Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData();

        int default_integration_order = 1;

        panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
                                   block_ids_to_cell_topo,
                                   ipb,
                                   default_integration_order,
                                   workset_size,
                                   eqset_factory,
                                   gd,
                                   false,
                                   physicsBlocks);
    }

    Teuchos::RCP<panzer_stk_classic::WorksetFactory> wkstFactory
        = Teuchos::rcp(new panzer_stk_classic::WorksetFactory(mesh)); // build STK workset factory
    Teuchos::RCP<panzer::WorksetContainer> wkstContainer     // attach it to a workset container (uses lazy evaluation)
        = Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,physicsBlocks,workset_size));

    // build DOF Manager
    /////////////////////////////////////////////////////////////

    // build the connection manager
    const Teuchos::RCP<panzer::ConnManager<int,int> >
    conn_manager = Teuchos::rcp(new panzer_stk_classic::STKConnManager<int>(mesh));

    panzer::DOFManagerFactory<int,int> globalIndexerFactory;
    RCP<panzer::UniqueGlobalIndexer<int,int> > dofManager
        = globalIndexerFactory.buildUniqueGlobalIndexer(Teuchos::opaqueWrapper(MPI_COMM_WORLD),physicsBlocks,conn_manager);

    Teuchos::RCP<panzer::EpetraLinearObjFactory<panzer::Traits,int> > eLinObjFactory
        = Teuchos::rcp(new panzer::EpetraLinearObjFactory<panzer::Traits,int>(Comm.getConst(),dofManager));
    Teuchos::RCP<panzer::LinearObjFactory<panzer::Traits> > linObjFactory = eLinObjFactory;

    // setup field manager build
    /////////////////////////////////////////////////////////////

    // Add in the application specific closure model factory
    user_app::MyModelFactory_TemplateBuilder cm_builder;
    panzer::ClosureModelFactory_TemplateManager<panzer::Traits> cm_factory;
    cm_factory.buildObjects(cm_builder);

    Teuchos::ParameterList closure_models("Closure Models");
    closure_models.sublist("solid").sublist("SOURCE_TEMPERATURE").set<double>("Value",1.0);
    closure_models.sublist("ion solid").sublist("SOURCE_ION_TEMPERATURE").set<double>("Value",1.0);

    Teuchos::ParameterList user_data("User Data");

    fmb->setWorksetContainer(wkstContainer);
    fmb->setupVolumeFieldManagers(physicsBlocks,cm_factory,closure_models,*linObjFactory,user_data);
    fmb->setupBCFieldManagers(bcs,physicsBlocks,*eqset_factory,cm_factory,bc_factory,closure_models,*linObjFactory,user_data);

    fmb->writeVolumeGraphvizDependencyFiles("field_manager",physicsBlocks);

    panzer::AssemblyEngine_TemplateManager<panzer::Traits> ae_tm;
    panzer::AssemblyEngine_TemplateBuilder builder(fmb,linObjFactory);
    ae_tm.buildObjects(builder);

    RCP<panzer::EpetraLinearObjContainer> eGhosted
        = Teuchos::rcp_dynamic_cast<panzer::EpetraLinearObjContainer>(linObjFactory->buildGhostedLinearObjContainer());
    RCP<panzer::EpetraLinearObjContainer> eGlobal
        = Teuchos::rcp_dynamic_cast<panzer::EpetraLinearObjContainer>(linObjFactory->buildLinearObjContainer());
    eLinObjFactory->initializeGhostedContainer(panzer::EpetraLinearObjContainer::X |
            panzer::EpetraLinearObjContainer::DxDt |
            panzer::EpetraLinearObjContainer::F |
            panzer::EpetraLinearObjContainer::Mat,*eGhosted);
    eLinObjFactory->initializeContainer(panzer::EpetraLinearObjContainer::X |
                                        panzer::EpetraLinearObjContainer::DxDt |
                                        panzer::EpetraLinearObjContainer::F |
                                        panzer::EpetraLinearObjContainer::Mat,*eGlobal);
    panzer::AssemblyEngineInArgs input(eGhosted,eGlobal);

    ae_tm.getAsObject<panzer::Traits::Residual>()->evaluate(input);
    ae_tm.getAsObject<panzer::Traits::Jacobian>()->evaluate(input);
}
Пример #15
0
/**
 * Leave synchronization mutex.
 *
 * @param ctx
 *    Pointer to the opaque ZrtpContext structure.
 */
static void ozrtp_synchLeave(ZrtpContext* ctx){
	ortp_mutex_unlock(&user_data(ctx)->mutex);
}
Пример #16
0
/**
 * Enter synchronization mutex.
 *
 * GNU ZRTP requires one mutex to synchronize its
 * processing. Because mutex implementations depend on the
 * underlying infrastructure, for example operating system or
 * thread implementation, GNU ZRTP delegates mutex handling to the
 * specific part of its implementation.
 *
 * @param ctx
 *    Pointer to the opaque ZrtpContext structure.
 */
static void ozrtp_synchEnter(ZrtpContext* ctx){
	ortp_mutex_lock(&user_data(ctx)->mutex);
}
Пример #17
0
/**
 * SRTP crypto data ready for the sender or receiver.
 *
 * The ZRTP implementation calls this method right after all SRTP
 * secrets are computed and ready to be used. The parameter points
 * to a structure that contains pointers to the SRTP secrets and a
 * <code>enum Role</code>. The called method (the implementation
 * of this abstract method) must either copy the pointers to the SRTP
 * data or the SRTP data itself to a save place. The SrtpSecret_t
 * structure is destroyed after the callback method returns to the
 * ZRTP implementation.
 *
 * The SRTP data themselves are obtained in the ZRtp object and are
 * valid as long as the ZRtp object is active. TheZRtp's
 * destructor clears the secrets. Thus the called method needs to
 * save the pointers only, ZRtp takes care of the data.
 *
 * The implementing class may enable SRTP processing in this
 * method or delay it to srtpSecertsOn().
 *
 * @param ctx
 *    Pointer to the opaque ZrtpContext structure.
 * @param secrets A pointer to a SrtpSecret_t structure that
 *     contains all necessary data.
 *
 * @param part for which part (Sender or Receiver) this data is
 *     valid.
 *
 * @return Returns false if something went wrong during
 *    initialization of SRTP context, for example memory shortage.
 */
static int32_t ozrtp_srtpSecretsReady (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part ) {
	srtp_policy_t policy;
	err_status_t srtpCreateStatus;
	err_status_t addStreamStatus;
	OrtpZrtpContext *userData = user_data(ctx);

	ortp_message("ZRTP secrets for %s are ready; auth tag len is %i",
	             (part == ForSender) ? "sender" : "receiver",secrets->srtpAuthTagLen);

	// Get authentication and cipher algorithms in srtp format
	if (secrets->authAlgorithm != zrtp_Sha1) {
		ortp_fatal("unsupported authentication algorithm by srtp");
	}

	if (secrets->symEncAlgorithm != zrtp_Aes) {
		ortp_fatal("unsupported cipher algorithm by srtp");
	}

	/*
	 * Don't use crypto_policy_set_from_profile_for_rtp(), it is totally buggy.
	 */
	memset(&policy,0,sizeof(policy));

	if (secrets->srtpAuthTagLen == 32){
		crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtp);
		crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy.rtcp);
	}else if (secrets->srtpAuthTagLen == 80){
		crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtp);
		crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy.rtcp);
	}else{
		ortp_fatal("unsupported auth tag len");
	}

	if (part == ForSender) {
		srtpCreateStatus=srtp_create(&userData->srtpSend, NULL);
		policy.ssrc.type=ssrc_specific;
		policy.ssrc.value=userData->session->snd.ssrc; // us
		policy.key=key_with_salt(secrets, secrets->role);
		addStreamStatus=srtp_add_stream(userData->srtpSend, &policy);
	} else { //if (part == ForReceiver)
		srtpCreateStatus=srtp_create(&userData->srtpRecv, NULL);
		policy.ssrc.type = ssrc_any_inbound; /*we don't know the incoming ssrc will be */
		int32_t peerRole=secrets->role == Initiator ? Responder : Initiator;
		policy.key=key_with_salt(secrets,peerRole);
		addStreamStatus=srtp_add_stream(userData->srtpRecv, &policy);
	}

	ortp_free(policy.key);

	if (srtpCreateStatus != err_status_ok) {
		ortp_error("ZRTP Error %u during creation of SRTP context for %s",
			srtpCreateStatus, (part == ForSender) ? "sender" : "receiver");
		return 0;
	}
	if (addStreamStatus != err_status_ok) {
		ortp_error("ZRTP Error %u during addition of SRTP stream for %s",
			addStreamStatus, (part == ForSender) ? "sender" : "receiver");
		return 0;
	}
	return 1;
}
Пример #18
0
// Return TRUE if the data parsing finished, FALSE otherwise.
// estream->pos is advanced. Data is only processed if esstream->error
// is FALSE, parsing can set esstream->error to TRUE.
static int extension_and_user_data(struct bitstream *esstream, int udtype)
{
    dbg_print(DMT_VERBOSE, "Extension and user data(%d)\n", udtype);

    if (esstream->error || esstream->bitsleft <= 0)
        return 0;

    // Remember where to continue
    unsigned char *eau_start = esstream->pos;

    uint8_t startcode;

    do
    {
        startcode = next_start_code(esstream);

        if ( startcode == 0xB2 || startcode == 0xB5 )
        {
            read_u32(esstream); // Advance bitstream
            unsigned char *dstart = esstream->pos;

            // Advanve esstream to the next startcode.  Verify that
            // the whole extension was available and discard blocks
            // followed by PACK headers.  The latter usually indicates
            // a PS treated as an ES. 
            uint8_t nextstartcode = search_start_code(esstream);
            if (nextstartcode == 0xBA)
            {
                mprint("\nFound PACK header in ES data. Probably wrong stream mode!\n");
                esstream->error = 1;
                return 0;
            }

            if (esstream->error)
            {
                dbg_print(DMT_VERBOSE, "Extension and user data - syntax problem\n");
                return 0;
            }

            if (esstream->bitsleft < 0)
            {
                dbg_print(DMT_VERBOSE, "Extension and user data - inclomplete\n");
                // Restore to where we need to continue
                init_bitstream(esstream, eau_start, esstream->end);
                esstream->bitsleft = -1; // Redundant
                return 0;
            }

            if (startcode == 0xB2)
            {
                struct bitstream ustream;
                init_bitstream(&ustream, dstart, esstream->pos);
                user_data(&ustream, udtype);
            }
            else
            {
                dbg_print(DMT_VERBOSE, "Skip %d bytes extension data.\n",
                           esstream->pos - dstart);
            }
            // If we get here esstream points to the end of a block
            // of extension or user data.  Should we run out of data in
            // this loop this is where we want to restart after getting more.
            eau_start = esstream->pos;
        }
    }
    while(startcode == 0xB2 || startcode == 0xB5);

    if (esstream->error)
    {
        dbg_print(DMT_VERBOSE, "Extension and user data - syntax problem\n");
        return 0;
    }
    if (esstream->bitsleft < 0)
    {
        dbg_print(DMT_VERBOSE, "Extension and user data - inclomplete\n");
        // Restore to where we need to continue
        init_bitstream(esstream, eau_start, esstream->end);
        esstream->bitsleft = -1; // Redundant
        return 0;
    }

    dbg_print(DMT_VERBOSE, "Extension and user data - processed\n");

    // Read complete
    return 1;
}
Fl_Cairo_Window_Wrapper::Fl_Cairo_Window_Wrapper(Dart_Handle ref, int w, int h, const char* l) : Fl_Cairo_Window(w, h) {
  label(l);
  _ref = Dart_NewPersistentHandle(ref);
  user_data(&_ref);
  set_draw_cb(draw_cb);
}
Пример #20
0
/**
* Send information messages to the hosting environment.
*
* The ZRTP implementation uses this method to send information
* messages to the host. Along with the message ZRTP provides a
* severity indicator that defines: Info, Warning, Error,
* Alert. Refer to the <code>MessageSeverity</code> enum above.
*
* @param ctx
*    Pointer to the opaque ZrtpContext structure.
* @param severity
*     This defines the message's severity
* @param subCode
*     The subcode identifying the reason.
* @see ZrtpCodes#MessageSeverity
*/
static void ozrtp_sendInfo (ZrtpContext* ctx, int32_t severity, int32_t subCode ) {
	const char* submsg;
	switch (subCode) {
		case zrtp_InfoHelloReceived:
			/*!< Hello received, preparing a Commit */
			submsg="zrtp_InfoHelloReceived";
			break;
		case zrtp_InfoCommitDHGenerated:
			/*!< Commit: Generated a public DH key */
			submsg="zrtp_InfoCommitDHGenerated";
			break;
		case zrtp_InfoRespCommitReceived:
			 /*!< Responder: Commit received, preparing DHPart1 */
			submsg="zrtp_InfoRespCommitReceived";
			break;
		case zrtp_InfoDH1DHGenerated:
			/*!< DH1Part: Generated a public DH key */
			submsg="zrtp_InfoDH1DHGenerated";
			break;
		case zrtp_InfoInitDH1Received:
           /*!< Initiator: DHPart1 received, preparing DHPart2 */
			submsg="zrtp_InfoInitDH1Received";
			break;
		case zrtp_InfoRespDH2Received:
			/*!< Responder: DHPart2 received, preparing Confirm1 */
			submsg="zrtp_InfoRespDH2Received";
			break;
		case zrtp_InfoInitConf1Received:
			/*!< Initiator: Confirm1 received, preparing Confirm2 */
			submsg="zrtp_InfoInitConf1Received";
			break;
		case zrtp_InfoRespConf2Received:
			/*!< Responder: Confirm2 received, preparing Conf2Ack */
			submsg="zrtp_InfoRespConf2Received";
			break;
		case zrtp_InfoRSMatchFound:
			/*!< At least one retained secrets matches - security OK */
			submsg="zrtp_InfoRSMatchFound";
			break;
		case zrtp_InfoSecureStateOn:
			/*!< Entered secure state */
			submsg="zrtp_InfoSecureStateOn";
			break;
		case zrtp_InfoSecureStateOff:
			/*!< No more security for this session */
			submsg="zrtp_InfoSecureStateOff";
			break;
		default:
			submsg="unkwown";
			break;
	}

	switch (severity) {
		case zrtp_Info:
			ortp_message("ZRTP INFO %s",submsg);
			break;
		case zrtp_Warning: /*!< A Warning message - security can be established */
			ortp_warning("ZRTP %s",submsg);
			break;
		case zrtp_Severe:/*!< Severe error, security will not be established */
			ortp_error("ZRTP SEVERE %s",submsg);
			break;
		case zrtp_ZrtpError:
			ortp_error("ZRTP ERROR %s",submsg);
			break;
		default:
			ortp_error("ZRTP UNKNOWN ERROR %s",submsg);
			break;
	}


	if (subCode == zrtp_InfoSecureStateOn || subCode == zrtp_InfoSecureStateOff) {
		OrtpEventData *eventData;
		OrtpEvent *ev;
		ev=ortp_event_new(ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED);
		eventData=ortp_event_get_data(ev);
		eventData->info.zrtp_stream_encrypted=(subCode == zrtp_InfoSecureStateOn);
		rtp_session_dispatch_event(user_data(ctx)->session, ev);
	}
}