/*
 * 	IEEE 802.1Q GARP VLAN Registration Protocol (GVRP)
 *
 * 	Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
 *
 *	This program is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU General Public License
 *	version 2 as published by the Free Software Foundation.
 */
#include <linux/types.h>
#include <linux/if_vlan.h>
#include <net/garp.h>
#include "vlan.h"

#define GARP_GVRP_ADDRESS	{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x21 }

enum gvrp_attributes {
	GVRP_ATTR_INVALID,
	GVRP_ATTR_VID,
	__GVRP_ATTR_MAX
};
#define GVRP_ATTR_MAX	(__GVRP_ATTR_MAX - 1)

static struct garp_application vlan_gvrp_app __read_mostly = {
	.proto.group_address	= GARP_GVRP_ADDRESS,
	.maxattr		= GVRP_ATTR_MAX,
	.type			= GARP_APPLICATION_GVRP,
};

int vlan_gvrp_request_join(const struct net_device *dev)
{
	const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
	__be16 vlan_id = htons(vlan->vlan_id);

	if (vlan->vlan_proto != htons(ETH_P_8021Q))
		return 0;
	return garp_request_join(vlan->real_dev, &vlan_gvrp_app,
				 &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
}

void vlan_gvrp_request_leave(const struct net_device *dev)
{
	const struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
	__be16 vlan_id = htons(vlan->vlan_id);

	if (vlan->vlan_proto != htons(ETH_P_8021Q))
		return;
	garp_request_leave(vlan->real_dev, &vlan_gvrp_app,
			   &vlan_id, sizeof(vlan_id), GVRP_ATTR_VID);
}

int vlan_gvrp_init_applicant(struct net_device *dev)
{
	return garp_init_applicant(dev, &vlan_gvrp_app);
}

void vlan_gvrp_uninit_applicant(struct net_device *dev)
{
	garp_uninit_applicant(dev, &vlan_gvrp_app);
}

int __init vlan_gvrp_init(void)
{
	return garp_register_application(&vlan_gvrp_app);
}

void vlan_gvrp_uninit(void)
{
	garp_unregister_application(&vlan_gvrp_app);
}
ivate-remove'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/uapi/mtd/Kbuild?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/uapi/mtd/Kbuild?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/uapi/mtd/Kbuild?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/uapi/mtd/Kbuild'>
<input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='e9ea828f62891ca91e3f80bf4a438f337d59977d'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>uapi</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi/mtd?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>mtd</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/uapi/mtd/Kbuild?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d'>Kbuild</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/uapi/mtd/Kbuild?h=nds-private-remove&amp;id=e9ea828f62891ca91e3f80bf4a438f337d59977d&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>