예제 #1
0
func (t *Tun) SetNetmask(mask net.IPMask) error {
	c_name, c_mask := C.CString(t.Name), C.CString(net.IP(mask).String())
	defer C.free(unsafe.Pointer(c_name))
	defer C.free(unsafe.Pointer(c_mask))

	if C.if_setaddr(C.SIOCSIFNETMASK, c_name, c_mask) < 0 {
		return fmt.Errorf("set netmask fail")
	}
	return nil
}
예제 #2
0
func (t *Tun) SetDestAddr(ip net.IP) error {
	c_name, c_addr := C.CString(t.Name), C.CString(ip.String())
	defer C.free(unsafe.Pointer(c_name))
	defer C.free(unsafe.Pointer(c_addr))

	if C.if_setaddr(C.SIOCSIFDSTADDR, c_name, c_addr) < 0 {
		return fmt.Errorf("set dest addr fail")
	}
	return nil
}