version 1.1.1.1, 2012/02/21 17:26:11
|
version 1.1.1.2, 2012/10/09 09:22:28
|
Line 134 open_packet_socket (struct isis_circuit *circuit)
|
Line 134 open_packet_socket (struct isis_circuit *circuit)
|
|
|
circuit->fd = fd; |
circuit->fd = fd; |
|
|
if (circuit->circ_type == CIRCUIT_T_BROADCAST) | if (if_is_broadcast (circuit->interface)) |
{ |
{ |
/* |
/* |
* Join to multicast groups |
* Join to multicast groups |
Line 142 open_packet_socket (struct isis_circuit *circuit)
|
Line 142 open_packet_socket (struct isis_circuit *circuit)
|
* 8.4.2 - Broadcast subnetwork IIH PDUs |
* 8.4.2 - Broadcast subnetwork IIH PDUs |
* FIXME: is there a case only one will fail?? |
* FIXME: is there a case only one will fail?? |
*/ |
*/ |
if (circuit->circuit_is_type & IS_LEVEL_1) | if (circuit->is_type & IS_LEVEL_1) |
{ | /* joining ALL_L1_ISS */ |
/* joining ALL_L1_ISS */ | retval = isis_multicast_join (circuit->fd, 1, |
retval = isis_multicast_join (circuit->fd, 1, | circuit->interface->ifindex); |
circuit->interface->ifindex); | if (circuit->is_type & IS_LEVEL_2) |
/* joining ALL_ISS */ | /* joining ALL_L2_ISS */ |
retval = isis_multicast_join (circuit->fd, 3, | retval = isis_multicast_join (circuit->fd, 2, |
circuit->interface->ifindex); | circuit->interface->ifindex); |
} | /* joining ALL_ISS (used in RFC 5309 p2p-over-lan as well) */ |
if (circuit->circuit_is_type & IS_LEVEL_2) | retval = isis_multicast_join (circuit->fd, 3, |
/* joining ALL_L2_ISS */ | circuit->interface->ifindex); |
retval = isis_multicast_join (circuit->fd, 2, | |
circuit->interface->ifindex); | |
} |
} |
else |
else |
{ |
{ |
retval = |
retval = |
isis_multicast_join (circuit->fd, 0, circuit->interface->ifindex); | isis_multicast_join (circuit->fd, 0, circuit->interface->ifindex); |
} |
} |
|
|
return retval; |
return retval; |
Line 184 isis_sock_init (struct isis_circuit *circuit)
|
Line 182 isis_sock_init (struct isis_circuit *circuit)
|
goto end; |
goto end; |
} |
} |
|
|
if (circuit->circ_type == CIRCUIT_T_BROADCAST) | /* Assign Rx and Tx callbacks are based on real if type */ |
| if (if_is_broadcast (circuit->interface)) |
{ |
{ |
circuit->tx = isis_send_pdu_bcast; |
circuit->tx = isis_send_pdu_bcast; |
circuit->rx = isis_recv_pdu_bcast; |
circuit->rx = isis_recv_pdu_bcast; |
} |
} |
else if (circuit->circ_type == CIRCUIT_T_P2P) | else if (if_is_pointopoint (circuit->interface)) |
{ |
{ |
circuit->tx = isis_send_pdu_p2p; |
circuit->tx = isis_send_pdu_p2p; |
circuit->rx = isis_recv_pdu_p2p; |
circuit->rx = isis_recv_pdu_p2p; |
Line 232 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 (!circuit->area) { |
|
return ISIS_OK; |
|
} |
|
|
|
if (bytesread < 0) |
if (bytesread < 0) |
{ |
{ |
zlog_warn ("isis_recv_packet_bcast(): fd %d, recvfrom (): %s", | zlog_warn ("isis_recv_packet_bcast(): ifname %s, fd %d, bytesread %d, " |
circuit->fd, safe_strerror (errno)); | "recvfrom(): %s", |
zlog_warn ("circuit is %s", circuit->interface->name); | circuit->interface->name, circuit->fd, bytesread, |
zlog_warn ("circuit fd %d", circuit->fd); | safe_strerror (errno)); |
zlog_warn ("bytesread %d", bytesread); | |
/* get rid of the packet */ |
/* get rid of the packet */ |
bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff)); | bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff), |
| MSG_DONTWAIT, (struct sockaddr *) &s_addr, |
| (socklen_t *) &addr_len); |
return ISIS_WARNING; |
return ISIS_WARNING; |
} |
} |
/* |
/* |
Line 253 isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c
|
Line 249 isis_recv_pdu_bcast (struct isis_circuit *circuit, u_c
|
if (!llc_check (llc) || s_addr.sll_pkttype == PACKET_OUTGOING) |
if (!llc_check (llc) || s_addr.sll_pkttype == PACKET_OUTGOING) |
{ |
{ |
/* Read the packet into discard buff */ |
/* Read the packet into discard buff */ |
bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff)); | bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff), |
| MSG_DONTWAIT, (struct sockaddr *) &s_addr, |
| (socklen_t *) &addr_len); |
if (bytesread < 0) |
if (bytesread < 0) |
zlog_warn ("isis_recv_pdu_bcast(): read() failed"); | zlog_warn ("isis_recv_pdu_bcast(): recvfrom() failed"); |
return ISIS_WARNING; |
return ISIS_WARNING; |
} |
} |
|
|
/* on lan we have to read to the static buff first */ |
/* on lan we have to read to the static buff first */ |
bytesread = recvfrom (circuit->fd, sock_buff, circuit->interface->mtu, 0, | bytesread = recvfrom (circuit->fd, sock_buff, sizeof (sock_buff), MSG_DONTWAIT, |
(struct sockaddr *) &s_addr, (socklen_t *) &addr_len); |
(struct sockaddr *) &s_addr, (socklen_t *) &addr_len); |
|
if (bytesread < 0) |
|
{ |
|
zlog_warn ("isis_recv_pdu_bcast(): recvfrom() failed"); |
|
return ISIS_WARNING; |
|
} |
|
|
/* then we lose the LLC */ |
/* then we lose the LLC */ |
stream_write (circuit->rcv_stream, sock_buff + LLC_LEN, bytesread - LLC_LEN); |
stream_write (circuit->rcv_stream, sock_buff + LLC_LEN, bytesread - LLC_LEN); |
Line 289 isis_recv_pdu_p2p (struct isis_circuit *circuit, u_cha
|
Line 292 isis_recv_pdu_p2p (struct isis_circuit *circuit, u_cha
|
if (s_addr.sll_pkttype == PACKET_OUTGOING) |
if (s_addr.sll_pkttype == PACKET_OUTGOING) |
{ |
{ |
/* Read the packet into discard buff */ |
/* Read the packet into discard buff */ |
bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff)); | bytesread = recvfrom (circuit->fd, discard_buff, sizeof (discard_buff), |
| MSG_DONTWAIT, (struct sockaddr *) &s_addr, |
| (socklen_t *) &addr_len); |
if (bytesread < 0) |
if (bytesread < 0) |
zlog_warn ("isis_recv_pdu_p2p(): read() failed"); | zlog_warn ("isis_recv_pdu_p2p(): recvfrom() failed"); |
return ISIS_WARNING; |
return ISIS_WARNING; |
} |
} |
|
|
Line 313 isis_recv_pdu_p2p (struct isis_circuit *circuit, u_cha
|
Line 318 isis_recv_pdu_p2p (struct isis_circuit *circuit, u_cha
|
int |
int |
isis_send_pdu_bcast (struct isis_circuit *circuit, int level) |
isis_send_pdu_bcast (struct isis_circuit *circuit, int level) |
{ |
{ |
|
struct msghdr msg; |
|
struct iovec iov[2]; |
|
|
/* 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 |
*/ |
*/ |
Line 325 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
Line 333 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN); |
sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN); |
sa.sll_ifindex = circuit->interface->ifindex; |
sa.sll_ifindex = circuit->interface->ifindex; |
sa.sll_halen = ETH_ALEN; |
sa.sll_halen = ETH_ALEN; |
if (level == 1) | /* RFC5309 section 4.1 recommends ALL_ISS */ |
| if (circuit->circ_type == CIRCUIT_T_P2P) |
| memcpy (&sa.sll_addr, ALL_ISS, ETH_ALEN); |
| else if (level == 1) |
memcpy (&sa.sll_addr, ALL_L1_ISS, ETH_ALEN); |
memcpy (&sa.sll_addr, ALL_L1_ISS, ETH_ALEN); |
else |
else |
memcpy (&sa.sll_addr, ALL_L2_ISS, ETH_ALEN); |
memcpy (&sa.sll_addr, ALL_L2_ISS, ETH_ALEN); |
Line 336 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
Line 347 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
sock_buff[1] = 0xFE; |
sock_buff[1] = 0xFE; |
sock_buff[2] = 0x03; |
sock_buff[2] = 0x03; |
|
|
/* then we copy the data */ | memset (&msg, 0, sizeof (msg)); |
memcpy (sock_buff + LLC_LEN, circuit->snd_stream->data, | msg.msg_name = &sa; |
stream_get_endp (circuit->snd_stream)); | msg.msg_namelen = sizeof (struct sockaddr_ll); |
| msg.msg_iov = iov; |
| msg.msg_iovlen = 2; |
| iov[0].iov_base = sock_buff; |
| iov[0].iov_len = LLC_LEN; |
| iov[1].iov_base = circuit->snd_stream->data; |
| iov[1].iov_len = stream_get_endp (circuit->snd_stream); |
|
|
/* now we can send this */ | written = sendmsg (circuit->fd, &msg, 0); |
written = sendto (circuit->fd, sock_buff, | |
stream_get_endp(circuit->snd_stream) + LLC_LEN, 0, | |
(struct sockaddr *) &sa, sizeof (struct sockaddr_ll)); | |
|
|
return ISIS_OK; |
return ISIS_OK; |
} |
} |
Line 351 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
Line 365 isis_send_pdu_bcast (struct isis_circuit *circuit, int
|
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; |
int written = 1; |
struct sockaddr_ll sa; |
struct sockaddr_ll sa; |
|
|