inetdevice.h revision f9c6d3f8a5acd9bda0f5bc161fd50f4913e6ffcb
15115240jeff/*-
25115240jeff * Copyright (c) 2010 Isilon Systems, Inc.
35115240jeff * Copyright (c) 2010 iX Systems, Inc.
45115240jeff * Copyright (c) 2010 Panasas, Inc.
5387f5b6hselasky * Copyright (c) 2013 Mellanox Technologies, Ltd.
65115240jeff * All rights reserved.
75115240jeff *
85115240jeff * Redistribution and use in source and binary forms, with or without
95115240jeff * modification, are permitted provided that the following conditions
105115240jeff * are met:
115115240jeff * 1. Redistributions of source code must retain the above copyright
125115240jeff *    notice unmodified, this list of conditions, and the following
135115240jeff *    disclaimer.
145115240jeff * 2. Redistributions in binary form must reproduce the above copyright
155115240jeff *    notice, this list of conditions and the following disclaimer in the
165115240jeff *    documentation and/or other materials provided with the distribution.
175115240jeff *
185115240jeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
195115240jeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
205115240jeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
215115240jeff * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
225115240jeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
235115240jeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245115240jeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255115240jeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265115240jeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
275115240jeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28623abddhselasky *
29623abddhselasky * $FreeBSD$
305115240jeff */
315115240jeff#ifndef	_LINUX_INETDEVICE_H_
325115240jeff#define	_LINUX_INETDEVICE_H_
335115240jeff
345115240jeff#include <linux/netdevice.h>
355115240jeff
365115240jeffstatic inline struct net_device *
37f9c6d3fhselaskyip_dev_find(struct vnet *vnet, uint32_t addr)
385115240jeff{
395115240jeff	struct sockaddr_in sin;
405115240jeff	struct ifaddr *ifa;
415115240jeff	struct ifnet *ifp;
425115240jeff
435115240jeff	memset(&sin, 0, sizeof(sin));
445115240jeff	sin.sin_addr.s_addr = addr;
455115240jeff	sin.sin_len = sizeof(sin);
465115240jeff	sin.sin_family = AF_INET;
47f9c6d3fhselasky	CURVNET_SET_QUIET(vnet);
485115240jeff	ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
49f9c6d3fhselasky	CURVNET_RESTORE();
505115240jeff	if (ifa) {
515115240jeff		ifp = ifa->ifa_ifp;
525115240jeff		if_ref(ifp);
535115240jeff		ifa_free(ifa);
54f9c6d3fhselasky	} else {
55f9c6d3fhselasky		ifp = NULL;
565115240jeff	}
575115240jeff	return (ifp);
585115240jeff}
595115240jeff
605115240jeff#endif	/* _LINUX_INETDEVICE_H_ */
61