struct usb_interface_descriptor *next_interface(const struct usb_interface_descriptor *d) { struct usb_endpoint_descriptor *ep = first_endpoint(d); unsigned int i = 0; for (i = 0; ep && i < d->bNumEndpoints; i += is_endpoint(ep), ep = next_endpoint(ep)) {} return (struct usb_interface_descriptor *)ep; }
static void test_forward_permanent (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); // the permanent profile CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub4 = obj4->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 permanently stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- consume second profile of obj2 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444)); // ----- reached end, next_profile() must yield NULL profile = stub1->next_profile (); FRANKS_ASSERT (profile == 0); FRANKS_ASSERT (stub1->forward_profiles () != 0); }
/* The interface can be followed not only by endpoint descriptors, but by other types of descriptors too. */ int get_interface_size(const struct usb_interface_descriptor *d) { struct usb_endpoint_descriptor *ed = 0; unsigned int i = 0; int len = 0; if (!is_interface(d)) { return 0; } len = d->bLength; ed = first_endpoint(d); for (i = 0; ed && i < d->bNumEndpoints; i += is_endpoint(ed), ed = next_endpoint(ed)) { len += ed->bLength; } return len; }
struct usb_endpoint_descriptor *find_endpoint( const struct usb_interface_descriptor *d, int EndpointAddress) { struct usb_endpoint_descriptor *ed = first_endpoint(d); int i = 0; if (!d) { return 0; } for (i = 0; ed && i < d->bNumEndpoints; ed = next_endpoint(ed)) { int ok = is_endpoint(ed); i += ok; if (ok && ed->bEndpointAddress == EndpointAddress) { return ed; } } return 0; }
static void test_forward (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); CORBA::Object_var obj2 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:2222,iiop:192.168.1.3:2222/NameService"); CORBA::Object_var obj3 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:3333,iiop:192.168.1.3:3333/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub2 = obj2->_stubobj (); TAO_Stub *stub3 = obj3->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub1->base_profiles())) ); // ----- consume second profile of obj3 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 3333)); // ----- consume second profile of obj2 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 2222)); // ----- consume second profile of obj1 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 1111)); FRANKS_ASSERT (stub1->forward_profiles () == 0); // ----- reached end, next_profile() must yield NULL profile = stub1->next_profile (); }
static void test_forward_permanent_mix (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); CORBA::Object_var obj2 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:2222,iiop:192.168.1.3:2222/NameService"); CORBA::Object_var obj3 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:3333,iiop:192.168.1.3:3333/NameService"); CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService"); CORBA::Object_var obj5 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:5555,iiop:192.168.1.3:5555/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub2 = obj2->_stubobj (); TAO_Stub *stub3 = obj3->_stubobj (); TAO_Stub *stub4 = obj4->_stubobj (); TAO_Stub *stub5 = obj5->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub1->base_profiles())) ); // ----- forward to obj4 permanently stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- consume second profile from obj4 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- forward to obj5 permanently stub1->add_forward_profiles (stub5->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 5555)); // ----- stringified object reference must be equal to obj5->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub5->base_profiles())) ); // ----- consume second profile from obj5 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 5555)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub5->base_profiles())) ); // reached end of profiles, next_profile must return NULL profile = stub1->next_profile (); FRANKS_ASSERT (profile == 0); }