Authen-Smb

 view release on metacpan or  search on metacpan

smbval/rfcnb-io.c  view on Meta::CPAN


*/


int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len)

{ int read_len, pkt_len;
  char hdr[RFCNB_Pkt_Hdr_Len];      /* Local space for the header */
  struct RFCNB_Pkt *pkt_frag;
  int more, this_time, offset, frag_len, this_len;
  BOOL seen_keep_alive = TRUE;

  /* Read that header straight into the buffer */

  if (len < RFCNB_Pkt_Hdr_Len) { /* What a bozo */

#ifdef RFCNB_DEBUG
    fprintf(stderr, "Trying to read less than a packet:");
    perror("");
#endif
    RFCNB_errno = RFCNBE_BadParam;
    return(RFCNBE_Bad);

  }

  /* We discard keep alives here ... */

  if (RFCNB_Timeout > 0) 
    alarm(RFCNB_Timeout);

  while (seen_keep_alive) {

    if ((read_len = read(con -> fd, hdr, sizeof(hdr))) < 0) { /* Problems */
#ifdef RFCNB_DEBUG
      fprintf(stderr, "Reading the packet, we got:");
      perror("");
#endif
      if (errno == EINTR)
	RFCNB_errno = RFCNBE_Timeout;
      else
	RFCNB_errno = RFCNBE_BadRead;

smbval/rfcnb-io.c  view on Meta::CPAN

    }

    if (RFCNB_Pkt_Type(hdr) == RFCNB_SESSION_KEEP_ALIVE) {

#ifdef RFCNB_DEBUG
      fprintf(stderr, "RFCNB KEEP ALIVE received\n");
#endif
      
    }
    else {
      seen_keep_alive = FALSE;
    }

  }
 
  /* What if we got less than or equal to a hdr size in bytes? */

  if (read_len < sizeof(hdr)) { /* We got a small packet */

    /* Now we need to copy the hdr portion we got into the supplied packet */

smbval/session.c  view on Meta::CPAN

  if ((ret_len = RFCNB_Get_Pkt(con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) {

#ifdef RFCNB_DEBUG
    fprintf(stderr, "Bad packet return in RFCNB_Recv... \n");
#endif

    return(RFCNBE_Bad);

  }

  /* We should check that we go a message and not a keep alive */

  pkt -> next = NULL;

  RFCNB_Free_Pkt(pkt);

  return(ret_len);

}

/* We just disconnect from the other end, as there is nothing in the RFCNB */



( run in 1.113 second using v1.01-cache-2.11-cpan-df04353d9ac )