mirror of
https://github.com/opnsense/src.git
synced 2026-06-10 09:11:07 -04:00
tools: apply ng_iface.RELENG_10.diff
This commit is contained in:
parent
b866da1843
commit
f07c6ab097
2 changed files with 59 additions and 0 deletions
|
|
@ -70,9 +70,11 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/libkern.h>
|
||||
#include <sys/ctype.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
|
|
@ -164,6 +166,13 @@ static const struct ng_cmdlist ng_iface_cmds[] = {
|
|||
NULL,
|
||||
&ng_parse_string_type
|
||||
},
|
||||
{
|
||||
NGM_IFACE_COOKIE,
|
||||
NGM_IFACE_SET_IFNAME,
|
||||
"setifname",
|
||||
&ng_parse_string_type,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NGM_IFACE_COOKIE,
|
||||
NGM_IFACE_POINT2POINT,
|
||||
|
|
@ -608,6 +617,10 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||
struct ng_mesg *resp = NULL;
|
||||
int error = 0;
|
||||
struct ng_mesg *msg;
|
||||
char *new_name;
|
||||
size_t namelen, onamelen;
|
||||
struct sockaddr_dl *sdl = NULL;
|
||||
struct ifaddr *ifa = NULL;
|
||||
|
||||
NGI_GET_MSG(item, msg);
|
||||
switch (msg->header.typecookie) {
|
||||
|
|
@ -622,6 +635,49 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||
strlcpy(resp->data, ifp->if_xname, IFNAMSIZ);
|
||||
break;
|
||||
|
||||
case NGM_IFACE_SET_IFNAME:
|
||||
|
||||
new_name = (char *)msg->data;
|
||||
/* Announce the departure of the interface. */
|
||||
//new_name[strlen(new_name)] = '\0';
|
||||
|
||||
/* Deny request if interface is UP */
|
||||
if ((ifp->if_flags & IFF_UP) != 0) {
|
||||
error = EBUSY;
|
||||
break;
|
||||
}
|
||||
|
||||
//rt_ifannouncemsg(ifp, IFAN_DEPARTURE);
|
||||
EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
|
||||
|
||||
strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname));
|
||||
ifa = ifp->if_addr;
|
||||
IFA_LOCK(ifa);
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
|
||||
namelen = strlen(new_name) + 1;
|
||||
onamelen = sdl->sdl_nlen;
|
||||
/*
|
||||
* Move the address if needed. This is safe because we
|
||||
* allocate space for a name of length IFNAMSIZ when we
|
||||
* create this in if_attach().
|
||||
*/
|
||||
if (namelen != onamelen) {
|
||||
bcopy(sdl->sdl_data + onamelen,
|
||||
sdl->sdl_data + namelen, sdl->sdl_alen);
|
||||
}
|
||||
bcopy(new_name, sdl->sdl_data, namelen);
|
||||
sdl->sdl_nlen = namelen;
|
||||
sdl = (struct sockaddr_dl *)ifa->ifa_netmask;
|
||||
bzero(sdl->sdl_data, onamelen);
|
||||
while (namelen != 0)
|
||||
sdl->sdl_data[--namelen] = 0xff;
|
||||
IFA_UNLOCK(ifa);
|
||||
|
||||
EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
|
||||
/* Announce the return of the interface. */
|
||||
//rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
|
||||
break;
|
||||
|
||||
case NGM_IFACE_POINT2POINT:
|
||||
case NGM_IFACE_BROADCAST:
|
||||
{
|
||||
|
|
@ -699,9 +755,11 @@ ng_iface_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||
switch (msg->header.cmd) {
|
||||
case NGM_LINK_IS_UP:
|
||||
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
if_link_state_change(ifp, LINK_STATE_UP);
|
||||
break;
|
||||
case NGM_LINK_IS_DOWN:
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
if_link_state_change(ifp, LINK_STATE_DOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ enum {
|
|||
NGM_IFACE_POINT2POINT,
|
||||
NGM_IFACE_BROADCAST,
|
||||
NGM_IFACE_GET_IFINDEX,
|
||||
NGM_IFACE_SET_IFNAME,
|
||||
};
|
||||
|
||||
#define MTAG_NGIF NGM_IFACE_COOKIE
|
||||
|
|
|
|||
Loading…
Reference in a new issue