* Implemented a basic infrastructure for a netstat command.
* Started a netstat command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19560 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,10 +11,10 @@
|
||||
|
||||
|
||||
// level flags to pass to control()
|
||||
#define LEVEL_SET_OPTION 0x10000000
|
||||
#define LEVEL_GET_OPTION 0x20000000
|
||||
#define LEVEL_DRIVER_IOCTL 0x0f000000
|
||||
#define LEVEL_MASK 0x0fffffff
|
||||
#define LEVEL_SET_OPTION 0x10000000
|
||||
#define LEVEL_GET_OPTION 0x20000000
|
||||
#define LEVEL_DRIVER_IOCTL 0x0f000000
|
||||
#define LEVEL_MASK 0x0fffffff
|
||||
|
||||
typedef struct net_protocol {
|
||||
struct net_protocol *next;
|
||||
|
||||
@@ -68,6 +68,8 @@ struct net_socket_module_info {
|
||||
status_t (*receive_data)(net_socket *socket, size_t length, uint32 flags,
|
||||
net_buffer **_buffer);
|
||||
|
||||
status_t (*get_next_stat)(uint32 *cookie, int family, struct net_stat *stat);
|
||||
|
||||
// connections
|
||||
status_t (*spawn_pending_socket)(net_socket *parent, net_socket **_socket);
|
||||
void (*delete_socket)(net_socket *socket);
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
#define NET_STACK_DRIVER_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
#include <net_stat.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
// Forward declaration
|
||||
@@ -26,8 +25,8 @@ enum {
|
||||
NET_STACK_SOCKET = NET_STACK_IOCTL_BASE, // socket_args *
|
||||
NET_STACK_GET_COOKIE, // void **
|
||||
NET_STACK_CONTROL_NET_MODULE, // control_net_module_args *
|
||||
NET_STACK_SYSCTL, // sysctl_args *
|
||||
|
||||
NET_STACK_GET_NEXT_STAT, // get_next_stat_args *
|
||||
|
||||
// ops acting on an existing socket
|
||||
NET_STACK_BIND, // sockaddr_args *
|
||||
NET_STACK_RECVFROM, // struct msghdr *
|
||||
@@ -43,13 +42,9 @@ enum {
|
||||
NET_STACK_GETSOCKNAME, // sockaddr_args *
|
||||
NET_STACK_GETPEERNAME, // sockaddr_args *
|
||||
NET_STACK_SOCKETPAIR, // socketpair_args *
|
||||
|
||||
// TODO: remove R5 select() emulation
|
||||
NET_STACK_SELECT, // select_args *
|
||||
NET_STACK_DESELECT, // select_args *
|
||||
|
||||
|
||||
NET_STACK_NOTIFY_SOCKET_EVENT, // notify_socket_event_args * (userland stack only)
|
||||
|
||||
|
||||
NET_STACK_IOCTL_MAX
|
||||
};
|
||||
|
||||
@@ -89,13 +84,10 @@ struct accept_args { // used by NET_STACK_ACCEPT
|
||||
socklen_t address_length;
|
||||
};
|
||||
|
||||
struct sysctl_args { // used by NET_STACK_SYSCTL
|
||||
int *name;
|
||||
uint namelen;
|
||||
void *oldp;
|
||||
size_t *oldlenp;
|
||||
void *newp;
|
||||
size_t newlen;
|
||||
struct get_next_stat_args { // used by NET_STACK_GET_NEXT_STAT
|
||||
uint32 cookie;
|
||||
int family;
|
||||
struct net_stat stat;
|
||||
};
|
||||
|
||||
struct control_net_module_args { // used by NET_STACK_CONTROL_NET_MODULE
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef NET_STAT_H
|
||||
#define NET_STAT_H
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#define NET_STAT_SOCKET 1
|
||||
#define NET_STAT_PROTOCOL 2
|
||||
|
||||
|
||||
typedef struct net_stat {
|
||||
int family;
|
||||
int type;
|
||||
int protocol;
|
||||
char state[B_OS_NAME_LENGTH];
|
||||
team_id owner;
|
||||
struct sockaddr_storage address;
|
||||
struct sockaddr_storage peer;
|
||||
} net_stat;
|
||||
|
||||
#endif // NET_STAT_H
|
||||
Reference in New Issue
Block a user