network/tun: Style fixes; no functional change
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Haiku, Inc. All Rights Reserved.
|
* Copyright 2008-2019, Haiku, Inc. All Rights Reserved.
|
||||||
* This file may be used under the terms of the MIT License.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef NET_TUN_H
|
#ifndef NET_TUN_H
|
||||||
#define NET_TUN_H
|
#define NET_TUN_H
|
||||||
|
|||||||
@@ -7,6 +7,3 @@ UsePrivateHeaders net ;
|
|||||||
KernelAddon tun_config :
|
KernelAddon tun_config :
|
||||||
driver.c
|
driver.c
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* /dev/config/tun network tunnel driver for BeOS
|
||||||
|
* (c) 2003, mmu_man, [email protected]
|
||||||
|
* licenced under MIT licence.
|
||||||
|
*/
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
#include <KernelExport.h>
|
#include <KernelExport.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
@@ -10,14 +15,8 @@
|
|||||||
#include <fsproto.h>
|
#include <fsproto.h>
|
||||||
#include "bone_tun.h"
|
#include "bone_tun.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* /dev/config/tun network tunnel driver for BeOS
|
|
||||||
* (c) 2003, mmu_man, [email protected]
|
|
||||||
* licenced under MIT licence.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
const char * device_names[] = {TUN_DRIVER_NAME, NULL};
|
||||||
const char * device_names[]={TUN_DRIVER_NAME, NULL};
|
|
||||||
extern device_hooks tun_hooks;
|
extern device_hooks tun_hooks;
|
||||||
|
|
||||||
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
int32 api_version = B_CUR_DRIVER_API_VERSION;
|
||||||
@@ -26,30 +25,48 @@ vint32 if_mod_ref_count = 0;
|
|||||||
bone_tun_interface_info_t *gIfaceModule = NULL;
|
bone_tun_interface_info_t *gIfaceModule = NULL;
|
||||||
bone_util_info_t *gUtil = NULL;
|
bone_util_info_t *gUtil = NULL;
|
||||||
|
|
||||||
status_t init_hardware(void) {
|
|
||||||
|
status_t
|
||||||
|
init_hardware(void)
|
||||||
|
{
|
||||||
dprintf("tun:init_hardware()\n");
|
dprintf("tun:init_hardware()\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t init_driver(void) {
|
|
||||||
|
status_t
|
||||||
|
init_driver(void)
|
||||||
|
{
|
||||||
dprintf("tun:init_driver()\n");
|
dprintf("tun:init_driver()\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninit_driver(void) {
|
|
||||||
|
void
|
||||||
|
uninit_driver(void)
|
||||||
|
{
|
||||||
dprintf("tun:uninit_driver()\n");
|
dprintf("tun:uninit_driver()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char **publish_devices() {
|
|
||||||
|
const char**
|
||||||
|
publish_devices()
|
||||||
|
{
|
||||||
return device_names;
|
return device_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_hooks *find_device(const char *name) {
|
|
||||||
|
device_hooks*
|
||||||
|
find_device(const char *name)
|
||||||
|
{
|
||||||
(void)name;
|
(void)name;
|
||||||
return &tun_hooks;
|
return &tun_hooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_open(const char *name, uint32 flags, cookie_t **cookie) {
|
|
||||||
|
status_t
|
||||||
|
tun_open(const char *name, uint32 flags, cookie_t **cookie)
|
||||||
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
(void)name; (void)flags;
|
(void)name; (void)flags;
|
||||||
/* XXX: add O_NONBLOCK + FIONBIO */
|
/* XXX: add O_NONBLOCK + FIONBIO */
|
||||||
@@ -88,12 +105,18 @@ err0:
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_close(void *cookie) {
|
|
||||||
|
status_t
|
||||||
|
tun_close(void *cookie)
|
||||||
|
{
|
||||||
(void)cookie;
|
(void)cookie;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_free(cookie_t *cookie) {
|
|
||||||
|
status_t
|
||||||
|
tun_free(cookie_t *cookie)
|
||||||
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
#if DEBUG > 1
|
#if DEBUG > 1
|
||||||
dprintf("tun_close()\n");
|
dprintf("tun_close()\n");
|
||||||
@@ -107,7 +130,10 @@ status_t tun_free(cookie_t *cookie) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_ioctl(cookie_t *cookie, uint32 op, void *data, size_t len) {
|
|
||||||
|
status_t
|
||||||
|
tun_ioctl(cookie_t *cookie, uint32 op, void *data, size_t len)
|
||||||
|
{
|
||||||
ifreq_t *ifr;
|
ifreq_t *ifr;
|
||||||
bone_tun_if_interface_t *iface;
|
bone_tun_if_interface_t *iface;
|
||||||
(void)cookie; (void)op; (void)data; (void)len;
|
(void)cookie; (void)op; (void)data; (void)len;
|
||||||
@@ -165,7 +191,10 @@ status_t tun_ioctl(cookie_t *cookie, uint32 op, void *data, size_t len) {
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_read(cookie_t *cookie, off_t position, void *data, size_t *numbytes) {
|
|
||||||
|
status_t
|
||||||
|
tun_read(cookie_t *cookie, off_t position, void *data, size_t *numbytes)
|
||||||
|
{
|
||||||
bone_data_t *bdata;
|
bone_data_t *bdata;
|
||||||
uint32 got;
|
uint32 got;
|
||||||
ssize_t pktsize;
|
ssize_t pktsize;
|
||||||
@@ -201,7 +230,10 @@ ERROR_EOF:
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_write(cookie_t *cookie, off_t position, const void *data, size_t *numbytes) {
|
|
||||||
|
status_t
|
||||||
|
tun_write(cookie_t *cookie, off_t position, const void *data, size_t *numbytes)
|
||||||
|
{
|
||||||
bone_data_t *bdata = NULL;
|
bone_data_t *bdata = NULL;
|
||||||
void *buf;
|
void *buf;
|
||||||
status_t err = B_NO_MEMORY;
|
status_t err = B_NO_MEMORY;
|
||||||
@@ -233,7 +265,9 @@ ERROR_1:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t tun_select(cookie_t *cookie, uint8 event, uint32 ref, selectsync *sync)
|
|
||||||
|
status_t
|
||||||
|
tun_select(cookie_t *cookie, uint8 event, uint32 ref, selectsync *sync)
|
||||||
{
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
#if DEBUG > 1
|
#if DEBUG > 1
|
||||||
@@ -291,7 +325,10 @@ status_t tun_select(cookie_t *cookie, uint8 event, uint32 ref, selectsync *sync)
|
|||||||
/* iface UNLOCKED */
|
/* iface UNLOCKED */
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
status_t tun_deselect(cookie_t *cookie, uint8 event, selectsync *sync)
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
tun_deselect(cookie_t *cookie, uint8 event, selectsync *sync)
|
||||||
{
|
{
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
#if DEBUG > 1
|
#if DEBUG > 1
|
||||||
@@ -310,18 +347,25 @@ status_t tun_deselect(cookie_t *cookie, uint8 event, selectsync *sync)
|
|||||||
/* iface LOCKED */
|
/* iface LOCKED */
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
status_t tun_readv(cookie_t *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes)
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
tun_readv(cookie_t *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes)
|
||||||
{
|
{
|
||||||
dprintf("tun: readv(, %Ld, , %ld)\n", position, count);
|
dprintf("tun: readv(, %Ld, , %ld)\n", position, count);
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
status_t tun_writev(cookie_t *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes)
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
tun_writev(cookie_t *cookie, off_t position, const iovec *vec, size_t count, size_t *numBytes)
|
||||||
{
|
{
|
||||||
dprintf("tun: writev(, %Ld, , %ld)\n", position, count);
|
dprintf("tun: writev(, %Ld, , %ld)\n", position, count);
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
device_hooks tun_hooks={
|
|
||||||
|
device_hooks tun_hooks = {
|
||||||
(device_open_hook)tun_open,
|
(device_open_hook)tun_open,
|
||||||
tun_close,
|
tun_close,
|
||||||
(device_free_hook)tun_free,
|
(device_free_hook)tun_free,
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct net_buffer_module_info *gBufferModule;
|
struct net_buffer_module_info* gBufferModule;
|
||||||
static struct net_stack_module_info *sStackModule;
|
static struct net_stack_module_info* sStackModule;
|
||||||
|
|
||||||
//static mutex sListLock;
|
//static mutex sListLock;
|
||||||
//static DoublyLinkedList<ethernet_device> sCheckList;
|
//static DoublyLinkedList<ethernet_device> sCheckList;
|
||||||
@@ -34,9 +34,9 @@ static struct net_stack_module_info *sStackModule;
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_init(const char *name, net_device **_device)
|
tun_init(const char* name, net_device** _device)
|
||||||
{
|
{
|
||||||
tun_device *device;
|
tun_device* device;
|
||||||
|
|
||||||
if (strncmp(name, "tun", 3)
|
if (strncmp(name, "tun", 3)
|
||||||
&& strncmp(name, "tap", 3)
|
&& strncmp(name, "tap", 3)
|
||||||
@@ -62,9 +62,9 @@ tun_init(const char *name, net_device **_device)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_uninit(net_device *_device)
|
tun_uninit(net_device* _device)
|
||||||
{
|
{
|
||||||
tun_device *device = (tun_device *)_device;
|
tun_device* device = (tun_device*)_device;
|
||||||
|
|
||||||
put_module(NET_STACK_MODULE_NAME);
|
put_module(NET_STACK_MODULE_NAME);
|
||||||
put_module(NET_BUFFER_MODULE_NAME);
|
put_module(NET_BUFFER_MODULE_NAME);
|
||||||
@@ -75,20 +75,20 @@ tun_uninit(net_device *_device)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_up(net_device *device)
|
tun_up(net_device* device)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tun_down(net_device *device)
|
tun_down(net_device* device)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_control(net_device *device, int32 op, void *argument,
|
tun_control(net_device* device, int32 op, void* argument,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -96,14 +96,14 @@ tun_control(net_device *device, int32 op, void *argument,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_send_data(net_device *device, net_buffer *buffer)
|
tun_send_data(net_device* device, net_buffer* buffer)
|
||||||
{
|
{
|
||||||
return sStackModule->device_enqueue_buffer(device, buffer);
|
return sStackModule->device_enqueue_buffer(device, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_set_mtu(net_device *device, size_t mtu)
|
tun_set_mtu(net_device* device, size_t mtu)
|
||||||
{
|
{
|
||||||
if (mtu > 65536 || mtu < 16)
|
if (mtu > 65536 || mtu < 16)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -114,28 +114,28 @@ tun_set_mtu(net_device *device, size_t mtu)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_set_promiscuous(net_device *device, bool promiscuous)
|
tun_set_promiscuous(net_device* device, bool promiscuous)
|
||||||
{
|
{
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_set_media(net_device *device, uint32 media)
|
tun_set_media(net_device* device, uint32 media)
|
||||||
{
|
{
|
||||||
return EOPNOTSUPP;
|
return EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_add_multicast(net_device *device, const sockaddr *address)
|
tun_add_multicast(net_device* device, const sockaddr* address)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
tun_remove_multicast(net_device *device, const sockaddr *address)
|
tun_remove_multicast(net_device* device, const sockaddr* address)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -148,11 +148,11 @@ tun_std_ops(int32 op, ...)
|
|||||||
case B_MODULE_INIT:
|
case B_MODULE_INIT:
|
||||||
{
|
{
|
||||||
status_t status = get_module(NET_STACK_MODULE_NAME,
|
status_t status = get_module(NET_STACK_MODULE_NAME,
|
||||||
(module_info **)&sStackModule);
|
(module_info**)&sStackModule);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
status = get_module(NET_BUFFER_MODULE_NAME,
|
status = get_module(NET_BUFFER_MODULE_NAME,
|
||||||
(module_info **)&gBufferModule);
|
(module_info**)&gBufferModule);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
put_module(NET_STACK_MODULE_NAME);
|
put_module(NET_STACK_MODULE_NAME);
|
||||||
return status;
|
return status;
|
||||||
@@ -190,7 +190,7 @@ net_device_module_info sLoopbackModule = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module_info *modules[] = {
|
module_info* modules[] = {
|
||||||
(module_info *)&sLoopbackModule,
|
(module_info*)&sLoopbackModule,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user