Ejemplo n.º 1
0
/*!
  Loads the libary named lib<libname>.so using dlopen().

  \param libname the library name.
  \return the library handle.
 */
void * tool_load_lib ( const char * libname )
{
    char filename[255];
    void *dllhand;

    //PEGASUS_CMPIR_LIBTYPE appends libname with the lib extn based on os.
    sprintf ( filename, PEGASUS_CMPIR_LIBTYPE, libname );

    //invoke dlopen under unix and LoadLibrary under windows OS.
    dllhand = (void *) PEGASUS_CMPIR_LOADLIBRARY(filename,RTLD_LAZY);
    if (dllhand == 0)
    {
#if defined PEGASUS_OS_TYPE_UNIX
        TRACE_CRITICAL(
            ("Trying to load library: %s failed with %s\n",
            libname,
            dlerror()) );
#else
        TRACE_CRITICAL(
            ("Trying to load library: %s failed with %s\n",
            libname,
            strerror(errno)) );
#endif
    }
    return dllhand;
}
Ejemplo n.º 2
0
void start_debugger()
{

#ifdef PEGASUS_OS_TYPE_UNIX
    int ch;
    char * debugger = getenv("RCMPI_DEBUGGER");

    if (debugger != NULL)
    {
        if ((ch = fork()))
        {
            sleep(20); /* wait until debugger traces us */
        }
        else
        {
            char pid[10];
            char * argv[] = { debugger,
                "OOP-Provider",
                pid,
                NULL};
            sprintf(pid, "%d", getppid());
            execv(debugger, argv);

            TRACE_CRITICAL(("could not start debugger \"%s\", "
                "check RCMPI_DEBUGGER environment "
                "variable.",
                debugger));
            exit(-1);
        }
    }
#endif
}
Ejemplo n.º 3
0
// Helper function
void __free_ind_object (ind_object *obj)
{
    switch (obj->type)
    {
        case PEGASUS_INDICATION_OBJECT_TYPE_CMPI_SELECT_EXP :
            CMRelease ( (CMPISelectExp*)obj->ptr);
            break;
        case PEGASUS_INDICATION_OBJECT_TYPE_CMPI_SELECT_COND:
            CMRelease ( (CMPISelectCond*)obj->ptr);
            break;
        case PEGASUS_INDICATION_OBJECT_TYPE_CMPI_SUB_COND:
            CMRelease ( (CMPISubCond*)obj->ptr);
            break;
        case PEGASUS_INDICATION_OBJECT_TYPE_CMPI_PREDICATE:
            CMRelease ( (CMPIPredicate*)obj->ptr);
            break;
        default :
            TRACE_CRITICAL(("Unknown Object type: %d", obj->type ));
    }
}
Ejemplo n.º 4
0
void cleanup_indicationObjects (CMPIUint32 ctx_id)
{
    indication_objects *tmp, *prev;
    ind_object *obj;

    TRACE_NORMAL(("Cleaning all Indication Objects."));

    INIT_LOCK(_indication_objects_lock);
    CMPI_BrokerExt_Ftab->lockMutex(_indication_objects_lock);
    tmp = __indication_objects;
    while (tmp)
    {
        if (tmp->ctx_id == ctx_id)
        {
            break;
        }
        prev = tmp;
        tmp = tmp->next;
    }
    if (!tmp)
    {
        TRACE_CRITICAL(("Indication context id (%u) not found.", ctx_id));
        return;
    }
    while (tmp->objects)
    {
        obj = tmp->objects;
        tmp->objects = tmp->objects->next;
        __free_ind_object (obj);
    }
    if (tmp == __indication_objects)
    {
        __indication_objects = __indication_objects->next;
    }
    else
    {
        prev->next = tmp->next;
    }
    free (tmp);
    CMPI_BrokerExt_Ftab->unlockMutex(_indication_objects_lock);
}
Ejemplo n.º 5
0
/*!
  The function evaluates the up-call ticket, retrieves the appropriate
  broker handle, and passes on the request to __handle_MB_call(), if
  successful.

  \param socket the connection socket.
 */
static void __verify_MB_call(int socket)
{
    comm_ticket ticket;
    CONST CMPIBroker *broker;

    TRACE_VERBOSE(("entered function."));
    TRACE_NORMAL(("handling incoming broker service request."));

    io_read_fixed_length(socket, &ticket, sizeof(comm_ticket));
    broker = verify_ticket(&ticket);

    if (broker == NULL) {

        TRACE_CRITICAL(("ticket invalid, could not obtain a broker"
                        " handle."));
        // return bad status.
        close(socket);

    } else
        __handle_MB_call(socket, broker);

    TRACE_VERBOSE(("leaving function."));
}
Ejemplo n.º 6
0
int usbd_mv_ioctl(void *context, unsigned int cmd, unsigned long arg)
{
	struct vhci_device_descriptor *pdev = context;
	int result = 0;
	unsigned long flags;
	struct waitable_queue_entry *pqentry;
	struct vhci_queue_data *pqdata;
	PUNRB punrb;

	TRACE("usbd_mv_ioctl: ++ cmd=%d arg=%lu\n", cmd, arg);

	switch(cmd)
	{
		case 0: /* read unrb */

			if( pdev->reset_in_progress )
			{
				TRACE("usbd_mv_ioctl: reset in progress\n");
				result = -ENODATA;
				break;
			}

			punrb = (PUNRB)((char*)pdev->readbuf+arg);

			TRACE("usbd_mv_ioctl: read unrb\n");

			/* get next queued urb or unrb */
			usbd_wq_lock(&pdev->queue_pending_transfer_unrb,flags);
			pqentry = usbd_wq_remove_head(&pdev->queue_pending_transfer_unrb);
			usbd_wq_unlock(&pdev->queue_pending_transfer_unrb,flags);

			do /*while(0)*/
			{
				if( pqentry == NULL )
				{
					TRACE("usbd_mv_ioctl: no entry\n");
					result = -ENODATA;
					break;
				}

				pqdata = (struct vhci_queue_data *)pqentry->data;

				if( pqdata->purb )
				{
					result = usbd_pack_urb(pqdata->purb, pqdata->unique_id, punrb);

					if( result != 0 ) 
					{
						TRACE_CRITICAL("usbd_mv_ioctl: can not pack urb, result=%d\n", result);
						result = -ENODATA;
						usbd_vhci_device_complete_urb(pqdata->purb, -EINVAL);
						break;
					}

					dump_unrb(punrb);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
					spin_lock(&pqdata->purb->lock);
					if( pqdata->purb->status == -EINPROGRESS )
#else
					if( !pqdata->purb->unlinked )
#endif
					{
						/* urb is still pending, put it back into queue */
						usbd_wq_add_tail_locked(&pdev->queue_pending_completion_unrb, pqentry);

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
						spin_unlock(&pqdata->purb->lock);
#endif

						TRACE("usbd_mv_ioctl: urb copied successfully\n");

						/* do not free this entry, as it was queued again */
						pqentry = NULL;
					} else
					{
						TRACE("usbd_mv_ioctl: urb has been cancelled!\n");
						/* somebody has cancelled the urb while we were messing with it */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
						spin_unlock(&pqdata->purb->lock);
#endif
						usbd_vhci_device_complete_urb(pqdata->purb, -1);
						result = -ENODATA;
					}
					break;
				}

				if( pqdata->punrb )
				{
					memcpy(punrb, pqdata->punrb, pqdata->punrb->Header.Size);
					dump_unrb(punrb);
					if(punrb->Header.Function == UNRB_FUNCTION_RESET_PORT) 
					{
						pdev->reset_in_progress = 1;

						/* put unrb into pending queue */
						usbd_wq_add_tail_locked(&pdev->queue_pending_completion_unrb, pqentry);

						pqentry = NULL;
					} else kfree(pqdata->punrb);
					TRACE("usbd_mv_ioctl: unrb copied successfully(2)\n");
					break;
				}

				result = -ENODATA;

			} while(0);

			if( pqentry ) 
				usbd_wq_free_entry(pqentry);

			break;

		case 1: /* write unrb */

			TRACE("usbd_mv_ioctl: write unrb\n");

			punrb = (PUNRB)((char*)pdev->writebuf+arg);

			dump_unrb(punrb);

			usbd_wq_lock(&pdev->queue_pending_completion_unrb,flags);
			pqentry = usbd_wq_get_first(&pdev->queue_pending_completion_unrb);
			while(pqentry)
			{
				pqdata = (struct vhci_queue_data *)pqentry->data;
			
				if( pqdata->unique_id == punrb->Header.UniqueId )
				{
					usbd_wq_remove_entry(pqentry);
					break;
				} 

				pqentry = usbd_wq_get_next(&pdev->queue_pending_completion_unrb, pqentry);
			}
			usbd_wq_unlock(&pdev->queue_pending_completion_unrb,flags);

			if( pqentry )
			{
				pqdata = (struct vhci_queue_data *)pqentry->data;

				if( pqdata->purb )
				{
					int status;
					TRACE("usbd_mv_ioctl: unpacking urb\n");
					status = usbd_unpack_urb(punrb, pqdata->purb);
					usbd_vhci_device_complete_urb(pqdata->purb, status);
				}
				if( pqdata->punrb )
				{
					if(punrb->Header.Function == UNRB_FUNCTION_RESET_PORT)
					{
						TRACE("usbd_mv_ioctl: reset completed\n");
						pdev->reset_in_progress = 0;
						usbd_wq_wake_up(&pdev->queue_pending_transfer_unrb);
					}

					TRACE("usbd_mv_ioctl: freeing unrb\n");
					kfree(pqdata->punrb);
				}

				usbd_wq_free_entry(pqentry);
			} else
			{
				TRACE("usbd_mv_ioctl: urb not found\n");
			}
			break;

		default:
			TRACE("usbd_mv_ioctl: invalid request\n");
			result = -EINVAL;
			break;
	}

	TRACE("usbd_mv_ioctl: -- result=%d\n", result);

	return result;
}
Ejemplo n.º 7
0
char * value2Chars ( CMPIType type, CMPIValue * value )
{
    char str[256],*p;
    unsigned int size;
    CMPIString *cStr;
    TRACE_NORMAL(("value2string type 0x%x CMPIValue.", type));

    if (type & CMPI_ARRAY)
    {

//      TRACE_INFO(("serializing array object type."));
//      return __serialize_CMPIArray ( fd, value->array );

    }
    else if (type & CMPI_ENC)
    {

        TRACE_INFO(("trying to stringify encapsulated data type."));

        switch (type)
        {
            case CMPI_instance:
                break;

            case CMPI_ref:
                cStr=__oft_toString(value->ref,NULL);
                return strdup((char*)cStr->hdl);
                break;

            case CMPI_args:
                break;

            case CMPI_filter:
                break;

            case CMPI_string:
            case CMPI_numericString:
            case CMPI_booleanString:
            case CMPI_dateTimeString:
            case CMPI_classNameString:
                size=(unsigned int) strlen((char*)value->string->hdl);
                p=malloc(size+8);
                sprintf(p,"\"%s\"",(char*)value->string->hdl);
                return strdup(p);

            case CMPI_dateTime:
                break;

        }
        TRACE_CRITICAL(("non-supported encapsulated data type."));


    }
    else if (type & CMPI_SIMPLE)
    {

        TRACE_INFO(("serializing simple value."));

        switch (type)
        {
            case CMPI_boolean:
                return strdup(value->boolean ? "true" : "false" );

            case CMPI_char16:
                break;
        }

        TRACE_CRITICAL(("non-supported simple data type."));

    }
    else if (type & CMPI_INTEGER)
    {

        TRACE_INFO(("serializing integer value."));

        switch (type)
        {
            case CMPI_uint8:
                sprintf(str,"%u",value->uint8);
                return strdup(str);
            case CMPI_sint8:
                sprintf(str,"%d",value->sint8);
                return strdup(str);
            case CMPI_uint16:
                sprintf(str,"%u",value->uint16);
                return strdup(str);
            case CMPI_sint16:
                sprintf(str,"%d",value->sint16);
                return strdup(str);
            case CMPI_uint32:
                sprintf(str,"%u",value->uint32);
                return strdup(str);
            case CMPI_sint32:
                sprintf(str,"%d",value->sint32);
                return strdup(str);
            case CMPI_uint64:
#if defined CMPI_PLATFORM_WIN32_IX86_MSVC
                sprintf(str,"I64u",value->uint64);
#else
                sprintf(str,"%llu",value->uint64);
#endif
                return strdup(str);
            case CMPI_sint64:

#if defined CMPI_PLATFORM_WIN32_IX86_MSVC
                sprintf(str,"%I64d",value->sint64);
#else
                sprintf(str,"%lld",value->sint64);
#endif
                return strdup(str);
        }

        TRACE_CRITICAL(("non-supported integer data type."));

    }
    else if (type & CMPI_REAL)
    {

        switch (type)
        {
            case CMPI_real32:
                sprintf(str,"%g",value->real32);
                return strdup(str);
            case CMPI_real64:
                sprintf(str,"%g",value->real64);
                return strdup(str);
        }

        TRACE_CRITICAL(("non-supported floating point data type."));
    }
    sprintf(str,"*NOT RECOGNIZED VALUE TYPE %d*",type);
    return strdup(str);
}