VOS_UINT32 VOS_SmV( VOS_SEM Sm_ID )
{
    SEM_CONTROL_BLOCK  *temp_Ptr;

    temp_Ptr = (SEM_CONTROL_BLOCK *)Sm_ID;

    if( temp_Ptr == temp_Ptr->SemId )
    {
        if( temp_Ptr->Flag == VOS_SEM_CTRL_BLK_IDLE)
        {
            VOS_SetErrorNo(VOS_ERRNO_SEMA4_V_NOTACTIVE);
            return(VOS_ERRNO_SEMA4_V_NOTACTIVE);
        }

        if ( NU_SUCCESS == NU_Release_Semaphore( &(temp_Ptr->NuSem) ) )
        {
            return(VOS_OK);
        }
        else
        {
            LogPrint2("# VOS_SmV ID %x Name %s.\r\n", Sm_ID, temp_Ptr->Name);

            VOS_SetErrorNo(VOS_ERRNO_SEMA4_V_CANOTV);
            return(VOS_ERRNO_SEMA4_V_CANOTV);
        }
    }
    else
    {
        VOS_SetErrorNo(VOS_ERRNO_SEMA4_V_IDERR);
        return(VOS_ERRNO_SEMA4_V_IDERR);
    }
}
Ejemplo n.º 2
0
/**
   Nucleus - Release the Lock.

\par Implementation
   - Release the specified semaphore --> UNLOCKED (see "NU_Release_Semaphore").

\param
   lockId   Provides the pointer to the Lock Object.

\return
   IFX_SUCCESS on success.
   IFX_ERROR   on error.
*/
IFX_int32_t IFXOS_LockRelease(
               IFXOS_lock_t *lockId)
{
   if(lockId)
   {
      if (IFXOS_LOCK_INIT_VALID(lockId) == IFX_TRUE)
      {
         if (NU_Release_Semaphore(&lockId->object) == NU_SUCCESS)
         {
            IFXOS_SYS_LOCK_RELEASE_COUNT_INC(lockId->pSysObject);
            IFXOS_SYSOBJECT_CLEAR_OWNER_THR_INFO(lockId->pSysObject);

            return IFX_SUCCESS;
         }
      }
   }

   return IFX_ERROR;
}
Ejemplo n.º 3
0
/** @memo   Release a mutex.

    @doc    Release a mutex

    @precondition A successful call to rtp_sig_mutex_claim
    should be made before calling this function.

    @return void
 */
void rtp_sig_mutex_release (
    RTP_HANDLE mutexHandle                /** Handle to the mutex to be released. */
)
{
    NU_Release_Semaphore((NU_SEMAPHORE*)&mutexHandle);
}
Ejemplo n.º 4
0
STATUS NU_Bootp ( CHAR  *dv_name, BOOTP_STRUCT *bp_ptr)
{
    uint16              delay, delay_mask = 3;
    int                 i;
    int                 ret;
    BOOTPLAYER          *bootp_ptr;
    IPLAYER             *ip_ptr;
    UDPLAYER            *udp_pkt;
    NET_BUFFER          *buf_ptr;
    NET_BUFFER          *next_buf=0;
    struct pseudotcp    tcp_chk;
    int16               failed = 0,retval=0;
    DV_DEVICE_ENTRY     *int_face=0;
    int16               socketd;
    uint8               *buffer;
    struct addr_struct  clientaddr;
    uint16              nbytes;
    STATUS              status;
    int16               hlen = sizeof (IPLAYER);
    INT                 length;
    int32               total_size, current_size;
    int                 found = 0;    
    int32               flags;
    SCK_SOCKADDR        sa;
    int32               temp_data_len,temp_total_data_len;
    DLAYER              *ether_header;

	/* Create a socket and bind to it, so that we can receive packets. */
    socketd = NU_Socket(NU_FAMILY_IP, NU_TYPE_DGRAM, NU_NONE);
    if( socketd < 0 )
    {
        NU_Tcp_Log_Error( BOOTP_SOCKET, TCP_FATAL, __FILE__, __LINE__);
        return (NU_BOOTP_INIT_FAILED);
    }

    /* build local address and port to bind to. */
    clientaddr.family = NU_FAMILY_IP;
    clientaddr.port   = IPPORT_BOOTPC;
    clientaddr.id.is_ip_addrs[0] = (uint8) 0;
    clientaddr.id.is_ip_addrs[1] = (uint8) 0;
    clientaddr.id.is_ip_addrs[2] = (uint8) 0;
    clientaddr.id.is_ip_addrs[3] = (uint8) 0;
    clientaddr.name = "ATI";

    /*  Allocate memory for the buffer space */
    status = NU_Allocate_Memory(&System_Memory,(VOID **) &buffer,sizeof(BOOTPLAYER), NU_NO_SUSPEND);
    if (status != NU_SUCCESS)
            return (NU_BOOTP_INIT_FAILED);


    ret = NU_Bind(socketd, &clientaddr, 0);
    if( ret != socketd )
    {
        NU_Tcp_Log_Error( BOOTP_SOCKET_BIND, TCP_FATAL,
                    __FILE__, __LINE__);
        NU_Close_Socket(socketd);
        return (NU_BOOTP_INIT_FAILED);
    }

    UTL_Zero(bp_ptr->bp_mac_addr, sizeof(bp_ptr->bp_mac_addr));
    UTL_Zero(bp_ptr->bp_siaddr,sizeof(bp_ptr->bp_siaddr));
    UTL_Zero(bp_ptr->bp_giaddr,sizeof(bp_ptr->bp_giaddr));
    UTL_Zero(bp_ptr->bp_sname,sizeof(bp_ptr->bp_sname));
    UTL_Zero(bp_ptr->bp_file,sizeof(bp_ptr->bp_file));
	
    /*  Get the device by name to be used on BOOTP for this iteration. */
 
    int_face = DEV_Get_Dev_By_Name(dv_name);

    if (int_face->dev_mtu < BOOTP_MAX_HEADER_SIZE)
        return (NU_BOOTP_INIT_FAILED);

    /* copy the hardware address from the device structure */
    memcpy(bp_ptr->bp_mac_addr, int_face->dev_mac_addr, DADDLEN);

    /*  make sure that the MAC address is a good.  */
    if ( memcmp(bp_ptr->bp_mac_addr, "\0\0\0\0\0\0", 6) == 0)
        return (NU_BOOTP_INIT_FAILED);

    buf_ptr = MEM_Buffer_Chain_Dequeue(&MEM_Buffer_Freelist, BOOTP_MAX_HEADER_SIZE);

    if (buf_ptr == NU_NULL)
        return (NU_NO_BUFFERS);

    buf_ptr->mem_dlist = &BOOTP_List;


    UTL_Zero(buf_ptr->mem_parent_packet, sizeof(NET_PARENT_BUFFER_SIZE));
    
    
    if (buf_ptr->next_buffer != NU_NULL)
    {
        next_buf= buf_ptr->next_buffer;
    }
    
     UTL_Zero(next_buf->mem_packet, sizeof(NET_MAX_BUFFER_SIZE));





    /* Set up pointers to each of the headers that make up a BOOTP Packet.  */
    bootp_ptr = (BOOTPLAYER *)(buf_ptr->mem_parent_packet + (BOOTP_MAX_HEADER_SIZE - (sizeof(BOOTPLAYER))));
    udp_pkt  = (UDPLAYER *) (((char *)bootp_ptr) - sizeof(UDPLAYER));
    ip_ptr   = (IPLAYER *) (((char *)udp_pkt) - sizeof(IPLAYER));

    /*  Build the BOOTP Request Packet  */

    nbytes = BOOTP_init((BOOTPLAYER *)buffer, bp_ptr);

    /*  Initialize the local and foreign port numbers  */

    udp_pkt->source = intswap(IPPORT_BOOTPC);
    udp_pkt->dest   = intswap(IPPORT_BOOTPS);

    /* Set up the UDP Header  */

    udp_pkt->length = intswap ((uint16) (nbytes + sizeof(UDPLAYER)));

    udp_pkt->check = 0;



    buf_ptr->data_ptr = buf_ptr->mem_parent_packet + NET_MAX_UDP_HEADER_SIZE;
    total_size = nbytes;

    /*  Chain the Bootp Request Packet */

    if (total_size > NET_PARENT_BUFFER_SIZE)
    {
       current_size = NET_PARENT_BUFFER_SIZE - sizeof(IPLAYER) - NET_ETHER_HEADER_OFFSET_SIZE;
       total_size =   total_size - current_size;
    }
    else
    {
       current_size =  total_size;
    }

    /*  Copy Bootp Packet into first Buffer */
    memcpy(buf_ptr->data_ptr , buffer, current_size);

    /*  Set the Data Length to the Size of bytes copied.  */
    buf_ptr->data_len = current_size;

    /*  Set the Total data length to the Number of bytes in a Bootp Packet. */
    buf_ptr->mem_total_data_len = nbytes;

    /*  Increment Bootp Buffer to be at the number of bytes copied.  */
    buffer = buffer + current_size;

    /*  Check to make sure there is data to store in the mem_packet */

    while ((total_size) && (next_buf != NU_NULL))
    {

         if (total_size > NET_MAX_BUFFER_SIZE)
         {
             
             current_size = NET_MAX_BUFFER_SIZE;
         }
         else
         {
             current_size = total_size;
         }
         total_size = total_size - current_size;

         /*  Copy the remaining data in the chaining packets  */
         memcpy(next_buf->mem_packet,buffer,current_size);

         /*  Set the Data pointer to the remainder of the packets.  */
         next_buf->data_ptr = next_buf->mem_packet;
         next_buf->next = NU_NULL;
         next_buf->data_len = current_size;


         buffer = buffer + current_size;

         if (next_buf->next_buffer != NU_NULL)
         {
            next_buf = next_buf->next_buffer;
         }

    }

    /* Increment the Packet data pointer to the UDP layer */
    buf_ptr->data_ptr -= sizeof(UDPLAYER);

    /*  Copy the udp_pkt into the parent_packet.  */
    memcpy(buf_ptr->data_ptr,(uint8 *)udp_pkt,sizeof(UDPLAYER));

    /*  Increment the total data length */
    buf_ptr->mem_total_data_len += sizeof(UDPLAYER);

    /*  Increment the data length of this packet.  */
    buf_ptr->data_len += sizeof(UDPLAYER);

    /*  Calculate UDP Checksum  */

    tcp_chk.source  = 0x0;
    tcp_chk.dest    = 0xFFFFFFFF;
    tcp_chk.z       = 0;
    tcp_chk.proto   = IP_UDP_PROT;
    tcp_chk.tcplen  = intswap((uint16)buf_ptr->mem_total_data_len);
    udp_pkt->check =  tcpcheck( (uint16 *)&tcp_chk, buf_ptr);

    /* If a checksum of zero is computed it should be replaced with 0xffff. */
    if (udp_pkt->check == 0)
        udp_pkt->check = 0xFFFF;


   /*  Set up the IP header  */
    ip_ptr->versionandhdrlen = (((hlen >> 2)) | (IP_VERSION << 4));

    /*  Set the IP header to no fragments. */

    ip_ptr->frags = 0;

    /* Set the IP packet ID.  */

    ip_ptr->ident = 0;

    /* Set the type of service. */

    ip_ptr->service = 0;

    length = nbytes +(uint16)sizeof(UDPLAYER);

    /* Set the total length( data and IP header) for this packet. */

    ip_ptr->tlen = intswap((int16)(length + hlen));

    /*  Set the time to live. */

    ip_ptr->ttl = IP_TIME_TO_LIVE;

    /*  Set the protocol. */

    ip_ptr->protocol = IP_UDP_PROT;


    /* We are doing a broadcast, so we do not need this fields. */

    memset(ip_ptr->ipsource,0,4);
    memcpy(ip_ptr->ipdest,"\377\377\377\377",4);


    /*  Compute the IP checksum. */
    ip_ptr->check = 0;
    ip_ptr->check = ipcheck((uint16 *)ip_ptr, (uint16)(hlen >> 1));

    /*  Set the buffer pointer to the IP Layer.  */

    buf_ptr->data_ptr -= sizeof(IPLAYER);

    /*  Add the IPLAYER to the total data length */

    buf_ptr->mem_total_data_len += sizeof(IPLAYER);
    temp_total_data_len =  buf_ptr->mem_total_data_len;

    /*  Set the data length of the current packet.  */

    buf_ptr->data_len += sizeof(IPLAYER);
    temp_data_len =  buf_ptr->data_len;

    /*  Copy the IP header into the parent packet of the buffer chain.  */

    memcpy(buf_ptr->data_ptr,(uint8 *)ip_ptr,sizeof(IPLAYER));

    /*  Set initial Delay for Processing packets.  */

    delay= (delay_mask & NU_rand()) + 1;

    /*  Innitialize the ethernet header.  */

    ether_header = (DLAYER *)sa.sck_data;
    memcpy(ether_header->dest, NET_Ether_Broadaddr, DADDLEN);
    memcpy(ether_header->me, bp_ptr->bp_mac_addr, DADDLEN);
    ether_header->type = EIP;

    sa.sck_family = SK_FAM_UNSPEC;
    sa.sck_len = sizeof(sa);

    /*  Transmit the packet  */

    for(i=0; i< BOOTP_RETRIES; i++)
    {
        
        /* Grab the semaphore because we are about to change the interface
           that the BOOTP request will be sent over. */
        NU_Obtain_Semaphore(&TCP_Resource, NU_SUSPEND);

        /* The device will not send packets until an IP address is attached.
           Temporarily trick it into thinking an IP address is attached so this
           request can be sent.  Then set it back. */
        flags = int_face->dev_flags;
        int_face->dev_flags |= (DV_UP | DV_RUNNING);

        /* Send the packet. */
        status = (*(int_face->dev_output)) (buf_ptr, int_face,
                                            (SCK_SOCKADDR_IP *)&sa, NU_NULL);
        int_face->dev_flags = flags;

        NU_Release_Semaphore(&TCP_Resource);

        if( status != NU_SUCCESS)
        {
            NU_Tcp_Log_Error(BOOTP_SEND_FAILED, TCP_FATAL, __FILE__,__LINE__);
            break;
        }

        /*  Look at each packet on the buffer list to see if it is my reply */
        found = BOOTP_Process_Packets(socketd, bp_ptr, delay);

        if (found)
            break;                           /*  Found the Packet. */

        delay_mask++;


        delay = (delay_mask & NU_rand()) + 1;

        /*  Get the the packet off the Trasmitted list and retrasnmit again. */
        buf_ptr= BOOTP_List.head;
        buf_ptr->data_ptr = BOOTP_List.head->mem_parent_packet + NET_ETHER_HEADER_OFFSET_SIZE;
        buf_ptr->data_len = temp_data_len;
        buf_ptr->mem_total_data_len = temp_total_data_len;
    }  /*  End For Loop */


    if( found == 1 )
    {
        status = DEV_Attach_IP_To_Device( dv_name, bp_ptr->bp_yiaddr,
                                          bp_ptr->bp_net_mask);
        if( status != NU_SUCCESS )
        {
            NU_Tcp_Log_Error( BOOTP_ATTACH_IP, TCP_FATAL,
                  __FILE__, __LINE__);
            failed++;
        }

    }
	
    retval= failed + retval;
	   
    /* Cleanup */
    NU_Close_Socket(socketd);

    /*  Free the Buffer Chain.  */
    MEM_One_Buffer_Chain_Free (buf_ptr, &MEM_Buffer_Freelist);
    NU_Deallocate_Memory(buffer);
    if(!found)
        retval= BOOTP_RECV_FAILED;
    
    return(retval);
    
}  /* NU_Bootp */
Ejemplo n.º 5
0
/*************************************************************************/

#ifdef PLUS
VOID NU_EventsDispatcher(UNSIGNED argc, VOID *argv)
#else   /* !PLUS */
VOID NU_EventsDispatcher(VOID)
#endif  /* !PLUS */
{
    struct uport        *uprt;
    struct port         *prt;
    struct sock_struct  *sock_ptr = NU_NULL;  /* Socket pointer. */
#ifdef PLUS
    STATUS              status;
    UNSIGNED            waittime;
#else   /* !PLUS */
    int16               status,
                        waittime;
#endif  /* !PLUS */
    int16               tmoflag;
    UNSIGNED            event = 0,
                        dat = 0;
    tqe_t               *duptqe,
                        *tqe_wait;           /* Timer queue entry */
#ifdef NU_PPP
    DV_DEVICE_ENTRY     *dev_ptr;
#endif


    /*******************************************************************
       Receive_Message points to a single occurence in the event queue.
       The index 3 signals that the structure is 3 words (or 6 bytes)
       long and is formatted as follows:

       struct
       {
          8 bits: the msg_class
          8 bits: the event
          16 bits: pointer to the next event on the queue
          16 bits: the data field
       }
    *******************************************************************/
#ifdef PLUS
    UNSIGNED    Receive_Message[3] = {0, 0, 0};
    UNSIGNED    actual_size;
#else   /* !PLUS */
    unsigned int      Receive_Message[3];
#endif  /* !PLUS */
    tqe_wait = (tqe_t *)0;

#ifdef PLUS
    /*  Remove compilation warnings for unused parameters.  */
    status = (STATUS) argc + (STATUS) argv;
#endif

    while (1)
    {

        /* Retrieve a message from the event queue.  Note that if the source
           queue is empty this task suspends until something becomes
           available. */
#ifdef PLUS
        NU_Obtain_Semaphore(&TCP_Resource, NU_SUSPEND);
#else   /* !PLUS */
        NU_Request_Resource(TCP_Resource, NU_WAIT_FOREVER);
#endif  /* !PLUS */

        /*  If someone is waiting on the timer list, then we need to
            calculate the next hit time for that timer.  */

        if (!tqe_wait)
            tqe_wait = tcp_timerlist.flink;

        if (tqe_wait) {
#ifdef PLUS
            if (tqe_wait->duetime > NU_Retrieve_Clock())
                waittime = ((UNSIGNED) tqe_wait->duetime - NU_Retrieve_Clock());
            else
                waittime = NU_NO_SUSPEND;
#else   /* !PLUS */
            waittime = (tqe_wait->duetime - NU_Read_Time());
            if (waittime <= 0)
                waittime = (-1);
#endif  /* !PLUS */
        }
        else {
            tqe_wait = (tqe_t *)0;
#ifdef PLUS
            waittime = NU_SUSPEND;
#else   /* !PLUS */
            waittime = NU_WAIT_FOREVER;
#endif  /* !PLUS */
        }

#ifdef PLUS
        /*  If waittime is not NU_SUSPEND then there is a timeout value. */
        if (waittime != NU_NO_SUSPEND) {
            NU_Release_Semaphore(&TCP_Resource);
#else   /* !PLUS */
        if (waittime >= 0) {
            NU_Release_Resource(TCP_Resource);
#endif  /* !PLUS */

#ifdef PLUS
            status = NU_Receive_From_Queue(&eQueue, &Receive_Message[0],
                                           (UNSIGNED)3, &actual_size, waittime);

            NU_Obtain_Semaphore(&TCP_Resource, NU_SUSPEND);
#else   /* !PLUS */
            status = NU_Retrieve_Item(eQueue, Receive_Message, waittime);

            NU_Request_Resource(TCP_Resource, NU_WAIT_FOREVER);
#endif  /* !PLUS */

        }
        else

#ifdef PLUS
            status = NU_TIMEOUT;
#else   /* !PLUS */
            status = NU_QUEUE_TIMEOUT;
#endif  /* !PLUS */

#ifndef INTERRUPT
        netsleep(0);
#endif  /* !INTERRUPT */
        /* Determine if the message was received successfully.	*/

#ifdef PLUS
        if (status == NU_TIMEOUT)
#else   /* !PLUS */
        if (status == NU_QUEUE_TIMEOUT)
#endif  /* !PLUS */
        {
            if (tqe_wait == tcp_timerlist.flink) {

                /*  Take off the head of the list. */
                dll_dequeue((tqe_t *) &tcp_timerlist);

                /*  Place any duplicate entries on to the timer list. */
                duptqe = (tqe_t *)dll_dequeue(&tqe_wait->duplist);
                while (duptqe)
                {
                    tqpost((tqe_t *) &tcp_timerlist, duptqe);
                    duptqe = (tqe_t *)dll_dequeue(&tqe_wait->duplist);
                }

                /*  Place the dequeued entry on the free list. */
                dll_enqueue(&tcptimer_freelist, tqe_wait);

                tmoflag = 1;

                /* Take care of event TCPRETRANS here...other events are
                   handled by the CASE statement below... */

                if (tqe_wait->tqe_event == TCPRETRANS)
                {
                    /*  Get a pointer to the porlist entry.  */
                    prt = portlist[tqe_wait->tqe_data];

                    /*  If there is still data to be transmitted and we
                        still have a connection, update the retransmission
                        timeout value.  */
                    if ((prt->out.num_packets > 0) || (prt->state > SEST))
                    {
                        /*  If a retransmission timeout occurs, exponential
                         *  back-off.  This number returns toward the correct
                         *  value by the RTT measurement code in ackcheck. */
                        if (prt->rto < MAXRTO)
                            prt->rto <<= 1;      /* double it */
                    }

                    tcp_retransmit (prt, tqe_wait->tqe_ext_data);
                    tqe_wait = (tqe_t *)0;
#ifdef PLUS
                    NU_Release_Semaphore(&TCP_Resource);
#else   /* !PLUS */
                    NU_Release_Resource(TCP_Resource);
#endif  /* !PLUS */
                    continue;
                }
                else
                {
                    event = tqe_wait->tqe_event;
                    dat = tqe_wait->tqe_data;
                    status = NU_SUCCESS;
                }
            }
            else
            {
                tqe_wait = (tqe_t *)0;
#ifdef PLUS
                NU_Release_Semaphore(&TCP_Resource);
#else   /* !PLUS */
                NU_Release_Resource(TCP_Resource);
#endif  /* !PLUS */
                continue;
            }
        }
        else
        {
            tmoflag = 0;
            tqe_wait = (tqe_t *)NU_NULL;
        }

        /* Determine if the message was received successfully.  */
        if (status == NU_SUCCESS)
        {
            if (!tmoflag)
            {
                event = (int16)Receive_Message[0];
                dat   = (uint16)Receive_Message[2];
            }

            /* switch on the msg_class/event combination */
            switch (event)
            {
            default:
                break;

            case CONNULL:
                break;

            /***********  CONNECTION CLASS  **********************/
            case CONFAIL:  /* connection attempt failed */
            case CONOPEN:  /* successful connect attempt */

                /* Make sure the socket is not NULL, this is possible if a
                   TCP connection is made and immediately RESET by the
                   foreign host. */
                if ((sock_ptr = socket_list[dat]) != NU_NULL)
                {

                    /* return control to the waiting task */
#ifdef PLUS
                    if (sock_ptr->s_TXTask != NU_NULL)
                        NU_Resume_Task(sock_ptr->s_TXTask);
#else   /* !PLUS */
                    if (sock_ptr->s_TXTask != -1)
                        NU_Start(sock_ptr->s_TXTask);
#endif  /* !PLUS */
                }

                break;

            case TCPACK:
                /* An ack needs to be sent. */

                /* Get a pointer to the port. */
                prt = portlist[dat];

                /* Clear the ACK timer flag in the port. */
                prt->portFlags &= (~ACK_TIMER_SET);

                /* Send the ack. */
                tcp_sendack (prt);

                break;


            case CONTX:

                /*  get a pointer into the port list table at the
                    entry pointed to by dat in the event queue */
                prt = portlist[dat];

                if ( (prt->xmitFlag == NU_SET) &&
                        (prt->out.nextPacket != NU_NULL) )
                {
                    prt->tcpout.flags |= TPUSH;

                    tcp_xmit(prt, prt->out.nextPacket);

                    prt->out.nextPacket = (NET_BUFFER *)prt->out.nextPacket->next;

                    prt->xmitFlag = NU_CLEAR;

                }
                break;

            case WINPROBE:

                /* Get a pointer to the socket. */
                if ((sock_ptr = socket_list[dat]) != NU_NULL)
                {

                    /* restart the waiting task */
#ifdef PLUS
                    if (sock_ptr->s_TXTask != NU_NULL)
                        NU_Resume_Task(sock_ptr->s_TXTask);
#else
                    if (sock_ptr->s_TXTask != -1)
                        NU_Start(sock_ptr->s_TXTask);
#endif
                }
                break;


            case SELECT:

                NU_Resume_Task((NU_TASK *)dat);
                break;


            case ARPRESOLVE:
            case RARP_REQUEST:

                ARP_Event((uint16)dat);

                break;

            case CONRX:

                NET_Demux();
                break;

            /**********************  USER CLASS *************************/
            case UDPDATA:
                /* get a pointer into the port list table at the
                   entry pointed to by dat in the event queue */
                uprt = uportlist[dat];

                if (uprt != NU_NULL)
                {
                    /* return control to the waiting task */
#ifdef PLUS
                    if (uprt->RXTask != NU_NULL)
                        NU_Resume_Task(uprt->RXTask);
#else   /* !PLUS */
                    if (uprt->RXTask != -1)
                        NU_Start(uprt->RXTask);
#endif  /* !PLUS */
                }
                break;

#if INCLUDE_IP_MULTICASTING
            case EV_IGMP_REPORT :

                /* Send an IGMP multicast group membership report. */
                IGMP_REPORT_EVENT(dat);
                break;

#endif /* INCLUDE_IP_MULTICASTING */

            case EV_IP_REASSEMBLY :

                /* Clear the fragment list. The whole datagram has not
                   yet been received. */
                IP_Reassembly_Event((IP_QUEUE_ELEMENT *)dat);
                break;

                /*********************** PPP CLASS ************************/
#ifdef NU_PPP
            case LCP_RESEND:

                /* Remove the PPP header that was added the first time
                   this packet was sent. */
                lcp_state.negotiation_pkt->data_ptr += sizeof (PPP_HEADER);
                lcp_state.negotiation_pkt->data_len -= sizeof (PPP_HEADER);
                lcp_state.negotiation_pkt->mem_total_data_len
                -= sizeof (PPP_HEADER);

                /* Send the packet again. */
                PPP_TX_Packet (lcp_state.negotiation_pkt->mem_buf_device,
                               lcp_state.negotiation_pkt);

                break;

            case LCP_SEND_CONFIG:

                /* Send a new configure request packet */
                LCP_Send_Config_Req ();

                break;

            case HANGUP_MDM:

                MDM_Hangup();

                break;

            case LCP_ECHO_REQ:

                /* Send a echo request packet */
                LCP_Send_Echo_Req ((DV_DEVICE_ENTRY *) dat);

                break;

            case NCP_RESEND:

                /* Remove the PPP header that was added the first time
                   this packet was sent. */
                ncp_state.negotiation_pkt->data_ptr += sizeof (PPP_HEADER);
                ncp_state.negotiation_pkt->data_len -= sizeof (PPP_HEADER);
                ncp_state.negotiation_pkt->mem_total_data_len
                -= sizeof (PPP_HEADER);

                /* Send the packet again. */
                PPP_TX_Packet (ncp_state.negotiation_pkt->mem_buf_device,
                               ncp_state.negotiation_pkt);

                break;

            case NCP_SEND_CONFIG:


                /* Get a pointer to the device structure for this device
                   so that the IP address of this device can be found. */
                dev_ptr = (DV_DEVICE_ENTRY *)dat;

                /* Send it to the host */
                NCP_IP_Send_Config_Req (dev_ptr->dev_addr.dev_ip_addr);

                break;

            case LCP_CLOSE_LINK:

                /* Get a pointer to the device structure for this device
                   so that the IP address of this device can be found. */
                dev_ptr = (DV_DEVICE_ENTRY *)dat;

                /* Close the network down. */
                PPP_Kill_All_Open_Sockets(dev_ptr);

                /* Detach the IP address from this device. */
                DEV_Detach_IP_From_Device (dev_ptr->dev_net_if_name);

                /* Send a terminate request */
                LCP_Send_Terminate_Req();

                /* Start the timer */
                NU_Reset_Timer (&LCP_Restart_Timer, LCP_Timer_Expire,
                                LCP_TIMEOUT_VALUE, LCP_TIMEOUT_VALUE, NU_ENABLE_TIMER);

                break;

            case PAP_SEND_AUTH:

                /* Retransmit the authentication pkt */
                PAP_Send_Authentication();

                break;

            case CHAP_RESEND:

                /* Remove the PPP header that was added the first time
                   this packet was sent. */
                lcp_state.negotiation_pkt->data_ptr += sizeof (PPP_HEADER);
                lcp_state.negotiation_pkt->data_len -= sizeof (PPP_HEADER);
                lcp_state.negotiation_pkt->mem_total_data_len
                -= sizeof (PPP_HEADER);

                /* Resend the last sent chap packet */
                PPP_TX_Packet (lcp_state.negotiation_pkt->mem_buf_device,
                               lcp_state.negotiation_pkt);

                break;

            case CHAP_CHALL:

                /* Send the CHAP challenge */
                CHAP_Send_Challenge();

                break;

#endif /* NU_PPP */


            } /* end switch on msg_class/event combination */
        } /* end if status is NU_SUCCESS */

        /* added 11/3/92 - during ATI mods */
#ifdef PLUS
        NU_Release_Semaphore(&TCP_Resource);
#else   /* !PLUS */
        NU_Release_Resource(TCP_Resource);
#endif  /* !PLUS */

    } /* end while */
}  /* end NU_EventDispatcher */
Ejemplo n.º 6
0
/* Bridge of mopi and nucleus */
void MopiBridgeMessenger()
{
    GBS_MSG msg;
    if (GBS_RecActDstMessage(&msg))
    {
        if (msg.msg == MOPI_THREAD_PROC)
        {
            if(msg.submess)
            {
                ThreadInfo *inf = (ThreadInfo *)msg.data0;

                uint32_t pcnt;
                void **args, *pret = 0, *arg_ptr = msg.data1;
                void *(*ptr_func)(void *, ...) = (void *(*)(void *, ...))msg.submess;

                /* нету параметров */
                if(!arg_ptr)  {
                    ptr_func(0);
                    pcnt = 0;

                } else
                    pcnt = unpack_args(arg_ptr, &args);

                switch(pcnt)
                {
                    case 0:
                        pret = ptr_func(0);
                        break;

                    case 1:
                        pret = ptr_func(args[0]);
                        break;

                    case 2:
                        pret = ptr_func(args[0], args[1]);
                        break;

                    case 3:
                        pret = ptr_func(args[0], args[1], args[2]);
                        break;

                    case 4:
                        pret = ptr_func(args[0], args[1], args[2], args[3]);
                        break;

                    case 5:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4]);
                        break;

                    case 6:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5]);
                        break;

                    case 7:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6]);
                        break;

                    case 8:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6]);
                        break;

                    case 9:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6]);
                        break;

                    case 10:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6], args[7], args[8], args[9]);
                        break;

                    case 11:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6], args[7], args[8], args[9], args[10]);
                        break;

                    case 12:
                        pret = ptr_func(args[0], args[1], args[2], args[3], args[4], args[5],
                                        args[6], args[7], args[8], args[9], args[10], args[11]);
                        break;

                    default:
                        ShowMSG(1, (int)"Bridge invalid param!");
                        break;
                }

                if(inf->sync) {
                    inf->ret = pret;
                    inf->loked = 0;
                    NU_Release_Semaphore(&inf->loker);
                }
                else {
                    free(arg_ptr);
                    free(inf);
                }
            }
        }
        else
        {
            GBS_SendMessage(MMI_CEPID,MSG_HELPER_TRANSLATOR,msg.pid_from,msg.msg,msg.submess);
        }
    }
}