kernels/linux-2.4.0/net/irda/irnet/irnet_irda.c
/*------------------------------------------------------------------*/
/*
 * Function irda_find_socket (self)
 *
 *    Find the correct IrNET socket
 *
 * Look into the list of IrNET sockets and finds one with the right
 * properties...
 */
Function irda_find_socket (self)
Find the correct IrNET socket

Look into the list of IrNET sockets and finds one with the right
properties
Function irda_find_socket ( self ) Find the correct IrNET socket Look into the list of IrNET sockets and finds one with the right properties
static inline irnet_socket *
irnet_find_socket(irnet_socket *	self)
{
  irnet_socket *	new = (irnet_socket *) NULL;
  unsigned long		flags;
  int			err;
  DENTER(IRDA_SERV_TRACE, "(self=0x%X)\n", (unsigned int) self);
  self->daddr = irttp_get_daddr(self->tsap);
  err = irnet_daddr_to_dname(self);
  spin_lock_irqsave(&irnet_server.spinlock, flags);
  if(err == 0)
    {
      new = (irnet_socket *) hashbin_find(irnet_server.list,
					  0, self->rname);
      if(new)
	DEBUG(IRDA_SERV_INFO, "Socket 0x%X matches rname ``%s''.\n",
	      (unsigned int) new, new->rname);
    }
  if(new == (irnet_socket *) NULL)
    {
      new = (irnet_socket *) hashbin_get_first(irnet_server.list);
      while(new !=(irnet_socket *) NULL)
	{
	  if((new->raddr == self->daddr) || (new->daddr == self->daddr))
	    {
	      DEBUG(IRDA_SERV_INFO, "Socket 0x%X matches daddr %#08x.\n",
		    (unsigned int) new, self->daddr);
	      break;
	    }
	  new = (irnet_socket *) hashbin_get_next(irnet_server.list);
	}
    }
  if(new == (irnet_socket *) NULL)
    {
      new = (irnet_socket *) hashbin_get_first(irnet_server.list);
      while(new !=(irnet_socket *) NULL)
	{
	  if(!(new->ttp_open) && (new->raddr == DEV_ADDR_ANY) &&
	     (new->rname[0] == '\0') && (new->ppp_open))
	    {
	      DEBUG(IRDA_SERV_INFO, "Socket 0x%X is free.\n",
		    (unsigned int) new);
	      break;
	    }
	  new = (irnet_socket *) hashbin_get_next(irnet_server.list);
	}
    }
  spin_unlock_irqrestore(&irnet_server.spinlock, flags);
  DEXIT(IRDA_SERV_TRACE, " - new = 0x%X\n", (unsigned int) new);
  return new;
}
static inline irnet_socket * irnet_find_socket ( irnet_socket * self ) { irnet_socket * new = ( irnet_socket * ) NULL ; unsigned long flags ; int err ; DENTER ( IRDA_SERV_TRACE , " \n " , ( unsigned int ) self ) ; self -> daddr = irttp_get_daddr ( self -> tsap ) ; err = irnet_daddr_to_dname ( self ) ; spin_lock_irqsave ( & irnet_server . spinlock , flags ) ; if ( err == 0 ) { new = ( irnet_socket * ) hashbin_find ( irnet_server . list , 0 , self -> rname ) ; if ( new ) DEBUG ( IRDA_SERV_INFO , " \n " , ( unsigned int ) new , new -> rname ) ; } if ( new == ( irnet_socket * ) NULL ) { new = ( irnet_socket * ) hashbin_get_first ( irnet_server . list ) ; while ( new != ( irnet_socket * ) NULL ) { if ( ( new -> raddr == self -> daddr ) || ( new -> daddr == self -> daddr ) ) { DEBUG ( IRDA_SERV_INFO , " \n " , ( unsigned int ) new , self -> daddr ) ; break ; } new = ( irnet_socket * ) hashbin_get_next ( irnet_server . list ) ; } } if ( new == ( irnet_socket * ) NULL ) { new = ( irnet_socket * ) hashbin_get_first ( irnet_server . list ) ; while ( new != ( irnet_socket * ) NULL ) { if ( ! ( new -> ttp_open ) && ( new -> raddr == DEV_ADDR_ANY ) && ( new -> rname [ 0 ] == ' \0 ' ) && ( new -> ppp_open ) ) { DEBUG ( IRDA_SERV_INFO , " \n " , ( unsigned int ) new ) ; break ; } new = ( irnet_socket * ) hashbin_get_next ( irnet_server . list ) ; } } spin_unlock_irqrestore ( & irnet_server . spinlock , flags ) ; DEXIT ( IRDA_SERV_TRACE , " \n " , ( unsigned int ) new ) ; return new ; }
Function irda_find_socket (self)
    Find the correct IrNET socket
Function irda_find_socket ( self ) Find the correct IrNET socket
/* Get the address of the requester */ /* Try to get the IrDA nickname of the requester */ /* Protect access to the instance list */ /* So now, try to get an socket having specifically
   * requested that nickname */ /* If no name matches, try to find an socket by the destination address */ /* It can be either the requested destination address (set via the
   * control channel), or the current destination address if the
   * socket is in the middle of a connection request */ /* Does it have the same address ? */ /* Yes !!! Get it.. */ /* If we don't have any socket, get the first unconnected socket */ /* Is it available ? */ /* Yes !!! Get it.. */ /* Spin lock end */