Diff for /embedaddon/quagga/isisd/isis_dlpi.c between versions 1.1.1.2 and 1.1.1.4

version 1.1.1.2, 2012/10/09 09:22:28 version 1.1.1.4, 2016/11/02 10:09:10
Line 33 Line 33
 #include <sys/pfmod.h>  #include <sys/pfmod.h>
   
 #include "log.h"  #include "log.h"
   #include "network.h"
 #include "stream.h"  #include "stream.h"
 #include "if.h"  #include "if.h"
   
Line 90  static u_short pf_filter[] = Line 91  static u_short pf_filter[] =
  * interfaces plus the (optional; not needed) Solaris packet filter module.   * interfaces plus the (optional; not needed) Solaris packet filter module.
  */   */
   
static voidstatic int
 dlpisend (int fd, const void *cbuf, size_t cbuflen,  dlpisend (int fd, const void *cbuf, size_t cbuflen,
   const void *dbuf, size_t dbuflen, int flags)    const void *dbuf, size_t dbuflen, int flags)
 {  {
   const struct strbuf *ctlptr = NULL;    const struct strbuf *ctlptr = NULL;
   const struct strbuf *dataptr = NULL;    const struct strbuf *dataptr = NULL;
   struct strbuf ctlbuf, databuf;    struct strbuf ctlbuf, databuf;
     int rv;
   
   if (cbuf != NULL)    if (cbuf != NULL)
     {      {
Line 115  dlpisend (int fd, const void *cbuf, size_t cbuflen, Line 117  dlpisend (int fd, const void *cbuf, size_t cbuflen,
     }      }
   
   /* We assume this doesn't happen often and isn't operationally significant */    /* We assume this doesn't happen often and isn't operationally significant */
  if (putmsg (fd, ctlptr, dataptr, flags) == -1)  rv = putmsg(fd, ctlptr, dataptr, flags);
    zlog_debug ("%s: putmsg: %s", __func__, safe_strerror (errno));  if (rv == -1 && dbuf == NULL)
     {
       /*
        * For actual PDU transmission - recognizable buf dbuf != NULL,
        * the error is passed upwards and should not be printed here.
        */
       zlog_debug ("%s: putmsg: %s", __func__, safe_strerror (errno));
     }
   return rv;
 }  }
   
 static ssize_t  static ssize_t
Line 174  dlpiok (int fd, t_uscalar_t oprim) Line 184  dlpiok (int fd, t_uscalar_t oprim)
   dl_ok_ack_t *doa = (dl_ok_ack_t *)dlpi_ctl;    dl_ok_ack_t *doa = (dl_ok_ack_t *)dlpi_ctl;
   
   retv = dlpirctl (fd);    retv = dlpirctl (fd);
  if (retv < DL_OK_ACK_SIZE || doa->dl_primitive != DL_OK_ACK ||  if (retv < (ssize_t)DL_OK_ACK_SIZE || doa->dl_primitive != DL_OK_ACK ||
     doa->dl_correct_primitive != oprim)      doa->dl_correct_primitive != oprim)
     {      {
       return -1;        return -1;
Line 196  dlpiinfo (int fd) Line 206  dlpiinfo (int fd)
   /* Info_req uses M_PCPROTO. */    /* Info_req uses M_PCPROTO. */
   dlpisend (fd, &dir, sizeof (dir), NULL, 0, RS_HIPRI);    dlpisend (fd, &dir, sizeof (dir), NULL, 0, RS_HIPRI);
   retv = dlpirctl (fd);    retv = dlpirctl (fd);
  if (retv < DL_INFO_ACK_SIZE || dlpi_ctl[0] != DL_INFO_ACK)  if (retv < (ssize_t)DL_INFO_ACK_SIZE || dlpi_ctl[0] != DL_INFO_ACK)
     return -1;      return -1;
   else    else
     return retv;      return retv;
Line 251  dlpibind (int fd) Line 261  dlpibind (int fd)
   dlpisend (fd, &dbr, sizeof (dbr), NULL, 0, 0);    dlpisend (fd, &dbr, sizeof (dbr), NULL, 0, 0);
   
   retv = dlpirctl (fd);    retv = dlpirctl (fd);
  if (retv < DL_BIND_ACK_SIZE || dba->dl_primitive != DL_BIND_ACK)  if (retv < (ssize_t)DL_BIND_ACK_SIZE || dba->dl_primitive != DL_BIND_ACK)
     return -1;      return -1;
   else    else
     return 0;      return 0;
Line 287  dlpiaddr (int fd, u_char *addr) Line 297  dlpiaddr (int fd, u_char *addr)
   dlpisend (fd, &dpar, sizeof (dpar), NULL, 0, 0);    dlpisend (fd, &dpar, sizeof (dpar), NULL, 0, 0);
   
   retv = dlpirctl (fd);    retv = dlpirctl (fd);
  if (retv < DL_PHYS_ADDR_ACK_SIZE || dpaa->dl_primitive != DL_PHYS_ADDR_ACK)  if (retv < (ssize_t)DL_PHYS_ADDR_ACK_SIZE
       || dpaa->dl_primitive != DL_PHYS_ADDR_ACK)
     return -1;      return -1;
   
   if (dpaa->dl_addr_offset < DL_PHYS_ADDR_ACK_SIZE ||    if (dpaa->dl_addr_offset < DL_PHYS_ADDR_ACK_SIZE ||
     dpaa->dl_addr_length != ETHERADDRL ||      dpaa->dl_addr_length != ETHERADDRL ||
    dpaa->dl_addr_offset + dpaa->dl_addr_length > retv)    dpaa->dl_addr_offset + dpaa->dl_addr_length > (size_t)retv)
     return -1;      return -1;
   
   bcopy((char *)dpaa + dpaa->dl_addr_offset, addr, ETHERADDRL);    bcopy((char *)dpaa + dpaa->dl_addr_offset, addr, ETHERADDRL);
Line 302  dlpiaddr (int fd, u_char *addr) Line 313  dlpiaddr (int fd, u_char *addr)
 static int  static int
 open_dlpi_dev (struct isis_circuit *circuit)  open_dlpi_dev (struct isis_circuit *circuit)
 {  {
  int fd, unit, retval;  int fd = -1, unit, retval;
   char devpath[MAXPATHLEN];    char devpath[MAXPATHLEN];
   dl_info_ack_t *dia = (dl_info_ack_t *)dlpi_ctl;    dl_info_ack_t *dia = (dl_info_ack_t *)dlpi_ctl;
   ssize_t acklen;    ssize_t acklen;
Line 403  open_dlpi_dev (struct isis_circuit *circuit) Line 414  open_dlpi_dev (struct isis_circuit *circuit)
     case DL_100BT:      case DL_100BT:
       break;        break;
     default:      default:
      zlog_warn ("%s: unexpected mac type on %s: %d", __func__,      zlog_warn ("%s: unexpected mac type on %s: %lld", __func__,
        circuit->interface->name, dia->dl_mac_type);        circuit->interface->name, (long long)dia->dl_mac_type);
       close (fd);        close (fd);
       return ISIS_WARNING;        return ISIS_WARNING;
     }      }
Line 442  open_dlpi_dev (struct isis_circuit *circuit) Line 453  open_dlpi_dev (struct isis_circuit *circuit)
    * 8.4.2 - Broadcast subnetwork IIH PDUs     * 8.4.2 - Broadcast subnetwork IIH PDUs
    */     */
   retval = 0;    retval = 0;
  if (circuit->is_type & IS_LEVEL_1)  retval |= dlpimcast (fd, ALL_L1_ISS);
    {  retval |= dlpimcast (fd, ALL_ISS);
      retval |= dlpimcast (fd, ALL_L1_ISS);  retval |= dlpimcast (fd, ALL_L2_ISS);
      retval |= dlpimcast (fd, ALL_ISS); 
    } 
  if (circuit->is_type & IS_LEVEL_2) 
    retval |= dlpimcast (fd, ALL_L2_ISS); 
   
   if (retval != 0)    if (retval != 0)
     {      {
Line 560  isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c Line 567  isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c
       return ISIS_WARNING;        return ISIS_WARNING;
     }      }
   
  if (ctlbuf.len < DL_UNITDATA_IND_SIZE ||  if (ctlbuf.len < (ssize_t)DL_UNITDATA_IND_SIZE ||
     dui->dl_primitive != DL_UNITDATA_IND)      dui->dl_primitive != DL_UNITDATA_IND)
     return ISIS_WARNING;      return ISIS_WARNING;
   
   if (dui->dl_src_addr_length != ETHERADDRL + 2 ||    if (dui->dl_src_addr_length != ETHERADDRL + 2 ||
     dui->dl_src_addr_offset < DL_UNITDATA_IND_SIZE ||      dui->dl_src_addr_offset < DL_UNITDATA_IND_SIZE ||
    dui->dl_src_addr_offset + dui->dl_src_addr_length > ctlbuf.len)    dui->dl_src_addr_offset + dui->dl_src_addr_length > (size_t)ctlbuf.len)
     return ISIS_WARNING;      return ISIS_WARNING;
   
   memcpy (ssnpa, (char *)dui + dui->dl_src_addr_offset +    memcpy (ssnpa, (char *)dui + dui->dl_src_addr_offset +
Line 590  isis_send_pdu_bcast (struct isis_circuit *circuit, int Line 597  isis_send_pdu_bcast (struct isis_circuit *circuit, int
   char *dstaddr;    char *dstaddr;
   u_short *dstsap;    u_short *dstsap;
   int buflen;    int buflen;
     int rv;
   
   buflen = stream_get_endp (circuit->snd_stream) + LLC_LEN;    buflen = stream_get_endp (circuit->snd_stream) + LLC_LEN;
  if (buflen > sizeof (sock_buff))  if ((size_t)buflen > sizeof (sock_buff))
     {      {
      zlog_warn ("isis_send_pdu_bcast: sock_buff size %lu is less than "      zlog_warn ("isis_send_pdu_bcast: sock_buff size %zu is less than "
                  "output pdu size %d on circuit %s",                   "output pdu size %d on circuit %s",
                  sizeof (sock_buff), buflen, circuit->interface->name);                   sizeof (sock_buff), buflen, circuit->interface->name);
       return ISIS_WARNING;        return ISIS_WARNING;
Line 629  isis_send_pdu_bcast (struct isis_circuit *circuit, int Line 637  isis_send_pdu_bcast (struct isis_circuit *circuit, int
   sock_buff[2] = 0x03;    sock_buff[2] = 0x03;
   memcpy (sock_buff + LLC_LEN, circuit->snd_stream->data,    memcpy (sock_buff + LLC_LEN, circuit->snd_stream->data,
           stream_get_endp (circuit->snd_stream));            stream_get_endp (circuit->snd_stream));
  dlpisend (circuit->fd, dur, sizeof (*dur) + dur->dl_dest_addr_length,  rv = dlpisend(circuit->fd, dur, sizeof (*dur) + dur->dl_dest_addr_length,
            sock_buff, buflen, 0);                sock_buff, buflen, 0);
   if (rv < 0)
     {
       zlog_warn("IS-IS dlpi: could not transmit packet on %s: %s",
                 circuit->interface->name, safe_strerror(errno));
       if (ERRNO_IO_RETRY(errno))
         return ISIS_WARNING;
       return ISIS_ERROR;
     }
 
   return ISIS_OK;    return ISIS_OK;
 }  }
   

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>