freebsd-dev/sbin/ipf/libipf/getifname.c
Cy Schubert 44bc301921 ipfilter userland: Style(9) requires a space after return
Reported by:    jrtc27
Fixes:          2582ae5740
MFC after:      1 month
2022-01-03 19:37:25 -08:00

55 lines
969 B
C

/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* $Id$
*/
#include "ipf.h"
#include "kmem.h"
/*
* Given a pointer to an interface in the kernel, return a pointer to a
* string which is the interface name.
*/
char *
getifname(struct ifnet *ptr)
{
#if SOLARIS
# include <sys/mutex.h>
# include <sys/condvar.h>
# include "../pfil/qif.h"
char *ifname;
qif_t qif;
if ((void *)ptr == (void *)-1)
return ("!");
if (ptr == NULL)
return ("-");
if (kmemcpy((char *)&qif, (u_long)ptr, sizeof(qif)) == -1)
return ("X");
ifname = strdup(qif.qf_name);
if ((ifname != NULL) && (*ifname == '\0')) {
free(ifname);
return ("!");
}
return (ifname);
#else
struct ifnet netif;
if ((void *)ptr == (void *)-1)
return ("!");
if (ptr == NULL)
return ("-");
if (kmemcpy((char *)&netif, (u_long)ptr, sizeof(netif)) == -1)
return ("X");
return (strdup(netif.if_xname));
#endif
}