static int cicp_llap_find_rsop(ci_private_t *priv, void *arg) { cp_llap_find_t *op = arg; if (priv->thr == NULL) return -EINVAL; return cicp_llap_find(CICP_HANDLE(&priv->thr->netif), &op->ifindex_out, op->hwport, op->vlan_id); }
/** * Put an IP_PKTINFO control message into msg ancillary data buffer. */ static void ip_cmsg_recv_pktinfo(ci_netif* netif, const ci_ip_pkt_fmt* pkt, struct cmsg_state *cmsg_state) { /* TODO: This is horribly inefficient -- two system calls. Could be made * cheap with a user-level llap table. */ struct in_pktinfo info; ci_uint32 addr; int hwport; addr = oo_ip_hdr_const(pkt)->ip_daddr_be32; info.ipi_addr.s_addr = addr; /* Set the ifindex the pkt was received at. */ { ci_ifid_t ifindex = 0; int rc = 0; hwport = netif->state->intf_i_to_hwport[pkt->intf_i]; rc = cicp_llap_find(CICP_HANDLE(netif), &ifindex, CI_HWPORT_ID(hwport), pkt->vlan); if( rc != 0 ) LOG_E(ci_log("%s: cicp_llap_find(intf_i=%d, hwport=%d) failed rc=%d", __FUNCTION__, pkt->intf_i, hwport, rc)); info.ipi_ifindex = ifindex; } /* RFC1122: The specific-destination address is defined to be the * destination address in the IP header unless the header contains a * broadcast or multicast address, in which case the specific-destination * is an IP address assigned to the physical interface on which the * datagram arrived. */ /*\ FIXME: we should drop the packet if this call fails */ cicp_ipif_pktinfo_query(CICP_HANDLE(netif), netif, OO_PKT_P(pkt), info.ipi_ifindex, &info.ipi_spec_dst.s_addr ); ci_put_cmsg(cmsg_state, IPPROTO_IP, IP_PKTINFO, sizeof(info), &info); }