Esempio n. 1
0
/**
 * fip_socket_sanmac - add SAN MAC to the unicast list for input socket
 * @s: ETH_P_FIP packet socket to setsockopt on
 * @ifindex: network interface index to send on
 * @add: 1 to add 0 to del
 */
static int fip_socket_sanmac(int s, int ifindex, unsigned char *mac, int add)
{
	unsigned char smac[ETHER_ADDR_LEN];

	if (fip_get_sanmac(ifindex, smac)) {
		FIP_LOG_DBG("%s: no sanmac, ifindex %d\n", __func__, ifindex);
		memcpy(smac, mac, ETHER_ADDR_LEN);
	}

	return fip_socket_add_addr(s, ifindex, add, smac, false);
}
Esempio n. 2
0
/**
 * fip_ethhdr - fills up the ethhdr for FIP
 * @ifindex: network interface index to send on
 * @mac: mac address of the sending network interface
 * @eh: buffer for ether header
 *
 * Note: assuming no VLAN
 */
static void fip_ethhdr(int ifindex, unsigned char *mac, struct ethhdr *eh)
{
	unsigned char smac[ETHER_ADDR_LEN];
	unsigned char dmac[ETHER_ADDR_LEN] = FIP_ALL_FCF_MACS;
	if (fip_get_sanmac(ifindex, smac))
		memcpy(smac, mac, ETHER_ADDR_LEN);

	eh->h_proto = htons(ETH_P_FIP);
	memcpy(eh->h_source, smac, ETHER_ADDR_LEN);
	memcpy(eh->h_dest, dmac, ETHER_ADDR_LEN);
}
Esempio n. 3
0
/**
 * fip_socket_sanmac - add SAN MAC to the unicast list for input socket
 * @s: ETH_P_FIP packet socket to setsockopt on
 * @ifindex: network interface index to send on
 * @add: 1 to add 0 to del
 */
static void fip_socket_sanmac(int s, int ifindex, int add)
{
	struct packet_mreq mr;
	unsigned char smac[ETHER_ADDR_LEN];

	if (fip_get_sanmac(ifindex, smac))
		return;

	memset(&mr, 0, sizeof(mr));
	mr.mr_ifindex = ifindex;
	mr.mr_type = PACKET_MR_UNICAST;
	mr.mr_alen = ETHER_ADDR_LEN;
	memcpy(mr.mr_address, smac, ETHER_ADDR_LEN);
	if (setsockopt(s, SOL_PACKET,
		       (add) ? PACKET_ADD_MEMBERSHIP : PACKET_DROP_MEMBERSHIP,
		       &mr, sizeof(mr)) < 0)
		FIP_LOG_DBG("PACKET_%s_MEMBERSHIP:failed\n",
			    (add) ? "ADD" : "DROP");
}