Exemple #1
0
static inline int
irnet_connect_tsap(irnet_socket *	self)
{
  int		err;

  DENTER(IRDA_SR_TRACE, "(self=0x%p)\n", self);

  
  err = irnet_open_tsap(self);
  if(err != 0)
    {
      clear_bit(0, &self->ttp_connect);
      DERROR(IRDA_SR_ERROR, "connect aborted!\n");
      return(err);
    }

  
  err = irttp_connect_request(self->tsap, self->dtsap_sel,
			      self->rsaddr, self->daddr, NULL,
			      self->max_sdu_size_rx, NULL);
  if(err != 0)
    {
      clear_bit(0, &self->ttp_connect);
      DERROR(IRDA_SR_ERROR, "connect aborted!\n");
      return(err);
    }

  

  DEXIT(IRDA_SR_TRACE, "\n");
  return(err);
}
Exemple #2
0
/*
 * Connect to the other side :
 *	o convert device name to an address
 *	o find the socket number (dlsap)
 *	o Establish the connection
 */
int
irda_irnet_connect(irnet_socket *	self)
{
  int		err;

  DENTER(IRDA_SOCK_TRACE, "(self=0x%X)\n", (unsigned int) self);

  /* Check if we have opened a local TSAP :
   * If we have already opened a TSAP, it means that either we are already
   * connected or in the process of doing so... */
  if(self->tsap != NULL)
    DRETURN(-EBUSY, IRDA_SOCK_INFO, "Already connecting...\n");

  /* Insert ourselves in the hashbin so that the IrNET server can find us.
   * Notes : 4th arg is string of 32 char max and must be null terminated
   *	     When 4th arg is used (string), 3rd arg isn't (int)
   *	     Can't re-insert (MUST remove first) so check for that... */
  if((irnet_server.running) && (self->q.q_next == NULL))
    {
      unsigned long		flags;
      spin_lock_irqsave(&irnet_server.spinlock, flags);
      hashbin_insert(irnet_server.list, (irda_queue_t *) self, 0, self->rname);
      spin_unlock_irqrestore(&irnet_server.spinlock, flags);
      DEBUG(IRDA_SOCK_INFO, "Inserted ``%s'' in hashbin...\n", self->rname);
    }

  /* If we don't have anything (no address, no name) */
  if((self->raddr == DEV_ADDR_ANY) && (self->rname[0] == '\0'))
    {
      /* Try to find a suitable address */
      if((err = irnet_discover_daddr_and_lsap_sel(self)) != 0) 
	DRETURN(err, IRDA_SOCK_INFO, "auto-connect failed!\n");
    }
  else
    {
      /* If we have only the name (no address), try to get an address */
      if(self->raddr == DEV_ADDR_ANY)
	{
	  if((err = irnet_dname_to_daddr(self)) != 0)
	    DRETURN(err, IRDA_SOCK_INFO, "name-connect failed!\n");
	}
      else
	/* Use the requested destination address */
	self->daddr = self->raddr;

      /* Query remote LM-IAS to find LSAP selector */
      if((err = irnet_find_lsap_sel(self)) != 0)
	DRETURN(err, IRDA_SOCK_INFO, "connect failed!\n");
    }
  DEBUG(IRDA_SOCK_INFO, "daddr = %08x, lsap = %d, starting IrTTP connection\n",
	self->daddr, self->dtsap_sel);

  /* Open a local TSAP (an IrTTP instance) */
  err = irnet_open_tsap(self);
  DABORT(err != 0, err, IRDA_SOCK_ERROR, "connect aborted!\n");

  /* Connect to remote device */
  err = irttp_connect_request(self->tsap, self->dtsap_sel, 
			      self->saddr, self->daddr, NULL, 
			      self->max_sdu_size_rx, NULL);
  DABORT(err != 0, err, IRDA_SOCK_ERROR, "connect aborted!\n");

  DEXIT(IRDA_SOCK_TRACE, "\n");
  return(0);
}