1#!/bin/sh -e
2
3# $NetBSD: vif-bridge-nbsd,v 1.1.1.1 2008/08/07 20:26:57 cegger Exp $
4# Called by xenbackendd
5# Usage: vif-bridge xsdir_backend_path state
6
7DIR=$(dirname "$0")
8. "${DIR}/hotplugpath.sh"
9
10PATH=${bindir}:${sbindir}:${LIBEXEC_BIN}:/bin:/usr/bin:/sbin:/usr/sbin
11export PATH
12
13xpath=$1
14xstatus=$2
15
16case $xstatus in
176)
18	# device removed
19	xenstore-rm $xpath
20	exit 0
21	;;
222)
23	xbridge=$(xenstore-read "$xpath/bridge")
24	xfid=$(xenstore-read "$xpath/frontend-id")
25	xhandle=$(xenstore-read "$xpath/handle")
26	iface=$(xenstore-read "$xpath/vifname")
27	ifconfig $iface up
28	brconfig $xbridge add $iface
29	xenstore-write $xpath/hotplug-status connected
30	exit 0
31	;;
32*)
33	exit 0
34	;;
35esac
36