Example #1
0
func CreateBridge(name string) error {
	if CheckBridge(name) == nil {
		return nil
	}
	if C.CreateBridge(C.CString(name)) < 0 {
		return errors.New("Failed to create bridge")
	}
	return nil
}
Example #2
0
func (t *TapManager) AddToBridge(bridge string) error {
	err := CheckBridge(bridge)
	if err != nil {
		if C.CreateBridge(C.CString(bridge)) != 0 {
			return errors.New("Failed to create bridge")
		}
	}
	if C.AddTapToBridge(C.CString(bridge), C.CString(t.name)) != 0 {
		return errors.New("Failed to add tap to bridge")
	}
	return nil
}