This routine didn't seem to work at all in freeipmi-0.2.2-qa0 (would
call sendto with NULL pointer).  The routine is below, with the two
changes are commented with ARC:.

Andy
---

ssize_t 
ipmi_lan_sendto (int sockfd, 
                 const void *buffer, 
                 size_t buffer_size, 
                 int flags, 
                 const struct sockaddr *server_addr, 
                 socklen_t server_addr_len)
{
  void *packet = NULL;
  size_t packet_length = 0;
  ssize_t bytes_sent = 0;
  int fusepad = 0;
  
  if (buffer == NULL || buffer_size == 0 || server_addr == NULL)
    {
      errno = EINVAL;
      return (-1);
    }
  
  /*
    Note from Table 12-8, RMCP Packet for IPMI via Ethernet footnote
    Some LAN adapter chips may have a problem where packets of overall
    lengths 56, 84, 112, 128, or 156 are not handled correctly. The
    PAD byte is added as necessary to avoid these overall
    lengths. Remote console software must use the PAD byte when
    formatting packets to any 10/100 Ethernet device that accepts RMCP
    packets. -- Anand Babu
  */
  
  if (buffer_size == 56  ||
      buffer_size == 84  ||
      buffer_size == 112 ||
      buffer_size == 128 ||
      buffer_size == 156)
    {
      packet_length = buffer_size + IPMI_LAN_PKT_PAD_SIZE;
      packet = alloca (packet_length);
      memset (packet, 0, packet_length);
      memcpy (packet, buffer, buffer_size);
      fusepad = 1;
    } else {  /* ARC: was missing */
      packet_length = buffer_size;
      packet = buffer;
    }
  
  bytes_sent = sendto (sockfd, 
                       packet, 
                       packet_length, 
                       flags, 
                       server_addr, 
                       server_addr_len);
  
  if (bytes_sent == -1)
    return (-1);
  
  if (fusepad)  /* ARC: change condition */
    return (bytes_sent - IPMI_LAN_PKT_PAD_SIZE);
  
  return bytes_sent;
}


_______________________________________________
Freeipmi-devel mailing list
Freeipmi-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/freeipmi-devel

Reply via email to