Diff for /embedaddon/quagga/isisd/isis_pfpacket.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2013/07/21 23:54:38 version 1.1.1.4, 2016/11/02 10:09:10
Line 26 Line 26
 #include <netpacket/packet.h>  #include <netpacket/packet.h>
   
 #include "log.h"  #include "log.h"
   #include "network.h"
 #include "stream.h"  #include "stream.h"
 #include "if.h"  #include "if.h"
   
Line 54  u_char ALL_L2_ISS[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, Line 55  u_char ALL_L2_ISS[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00,
 u_char ALL_ISS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x05 };  u_char ALL_ISS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x05 };
 u_char ALL_ESS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x04 };  u_char ALL_ESS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x04 };
   
static char discard_buff[8192];static uint8_t discard_buff[8192];
static char sock_buff[8192];static uint8_t sock_buff[8192];
   
 /*  /*
  * if level is 0 we are joining p2p multicast   * if level is 0 we are joining p2p multicast
Line 230  isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c Line 231  isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c
                         LLC_LEN, MSG_PEEK,                          LLC_LEN, MSG_PEEK,
                         (struct sockaddr *) &s_addr, (socklen_t *) &addr_len);                          (struct sockaddr *) &s_addr, (socklen_t *) &addr_len);
   
  if (bytesread < 0)  if ((bytesread < 0) || (s_addr.sll_ifindex != (int)circuit->interface->ifindex))
     {      {
      zlog_warn ("isis_recv_packet_bcast(): ifname %s, fd %d, bytesread %d, "      if (bytesread < 0)
                 "recvfrom(): %s",        {
                 circuit->interface->name, circuit->fd, bytesread,          zlog_warn ("isis_recv_packet_bcast(): ifname %s, fd %d, "
                 safe_strerror (errno));                     "bytesread %d, recvfrom(): %s",
                      circuit->interface->name, circuit->fd, bytesread,
                      safe_strerror (errno));
         }
       if (s_addr.sll_ifindex != (int)circuit->interface->ifindex)
         {
           zlog_warn("packet is received on multiple interfaces: "
                     "socket interface %d, circuit interface %d, "
                     "packet type %u",
                     s_addr.sll_ifindex, circuit->interface->ifindex,
                     s_addr.sll_pkttype);
         }
 
       /* get rid of the packet */        /* get rid of the packet */
       bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff),        bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff),
                             MSG_DONTWAIT, (struct sockaddr *) &s_addr,                              MSG_DONTWAIT, (struct sockaddr *) &s_addr,
Line 323  isis_send_pdu_bcast (struct isis_circuit *circuit, int Line 336  isis_send_pdu_bcast (struct isis_circuit *circuit, int
   /* we need to do the LLC in here because of P2P circuits, which will    /* we need to do the LLC in here because of P2P circuits, which will
    * not need it     * not need it
    */     */
   int written = 1;  
   struct sockaddr_ll sa;    struct sockaddr_ll sa;
   
   stream_set_getp (circuit->snd_stream, 0);    stream_set_getp (circuit->snd_stream, 0);
Line 356  isis_send_pdu_bcast (struct isis_circuit *circuit, int Line 368  isis_send_pdu_bcast (struct isis_circuit *circuit, int
   iov[1].iov_base = circuit->snd_stream->data;    iov[1].iov_base = circuit->snd_stream->data;
   iov[1].iov_len = stream_get_endp (circuit->snd_stream);    iov[1].iov_len = stream_get_endp (circuit->snd_stream);
   
  written = sendmsg (circuit->fd, &msg, 0);  if (sendmsg(circuit->fd, &msg, 0) < 0)
    {
       zlog_warn("IS-IS pfpacket: 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;
 }  }
   
 int  int
 isis_send_pdu_p2p (struct isis_circuit *circuit, int level)  isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
 {  {
   int written = 1;  
   struct sockaddr_ll sa;    struct sockaddr_ll sa;
     ssize_t rv;
   
   stream_set_getp (circuit->snd_stream, 0);    stream_set_getp (circuit->snd_stream, 0);
   memset (&sa, 0, sizeof (struct sockaddr_ll));    memset (&sa, 0, sizeof (struct sockaddr_ll));
Line 381  isis_send_pdu_p2p (struct isis_circuit *circuit, int l Line 399  isis_send_pdu_p2p (struct isis_circuit *circuit, int l
   
   /* lets try correcting the protocol */    /* lets try correcting the protocol */
   sa.sll_protocol = htons (0x00FE);    sa.sll_protocol = htons (0x00FE);
  written = sendto (circuit->fd, circuit->snd_stream->data,  rv = sendto(circuit->fd, circuit->snd_stream->data,
                    stream_get_endp (circuit->snd_stream), 0,               stream_get_endp (circuit->snd_stream), 0,
                    (struct sockaddr *) &sa,              (struct sockaddr *) &sa,
                    sizeof (struct sockaddr_ll));              sizeof (struct sockaddr_ll));
  if (rv < 0)
     {
       zlog_warn("IS-IS pfpacket: 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.3  
changed lines
  Added in v.1.1.1.4


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