Changeset 101

Show
Ignore:
Timestamp:
03/23/08 16:09:46 (10 months ago)
Author:
mwhitworth
Message:

Add to various interfaces and structures, add licenses.

Location:
Whitix/trunk/include/net
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • Whitix/trunk/include/net/eth.h

    r1 r101  
     1/*  This file is part of Whitix. 
     2 * 
     3 *  Whitix is free software; you can redistribute it and/or modify 
     4 *  it under the terms of the GNU General Public License as published by 
     5 *  the Free Software Foundation; either version 2 of the License, or 
     6 *  (at your option) any later version. 
     7 * 
     8 *  Whitix is distributed in the hope that it will be useful, 
     9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11 *  GNU General Public License for more details. 
     12 * 
     13 *  You should have received a copy of the GNU General Public License 
     14 *  along with Whitix; if not, write to the Free Software 
     15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     16 * 
     17 */ 
     18 
    119#ifndef ETH_H 
    220#define ETH_H 
  • Whitix/trunk/include/net/ipv4.h

    r1 r101  
     1/*  This file is part of Whitix. 
     2 * 
     3 *  Whitix is free software; you can redistribute it and/or modify 
     4 *  it under the terms of the GNU General Public License as published by 
     5 *  the Free Software Foundation; either version 2 of the License, or 
     6 *  (at your option) any later version. 
     7 * 
     8 *  Whitix is distributed in the hope that it will be useful, 
     9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11 *  GNU General Public License for more details. 
     12 * 
     13 *  You should have received a copy of the GNU General Public License 
     14 *  along with Whitix; if not, write to the Free Software 
     15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     16 * 
     17 */ 
     18 
    119#ifndef IP_H 
    220#define IP_H 
  • Whitix/trunk/include/net/socket.h

    r69 r101  
     1/*  This file is part of Whitix. 
     2 * 
     3 *  Whitix is free software; you can redistribute it and/or modify 
     4 *  it under the terms of the GNU General Public License as published by 
     5 *  the Free Software Foundation; either version 2 of the License, or 
     6 *  (at your option) any later version. 
     7 * 
     8 *  Whitix is distributed in the hope that it will be useful, 
     9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11 *  GNU General Public License for more details. 
     12 * 
     13 *  You should have received a copy of the GNU General Public License 
     14 *  along with Whitix; if not, write to the Free Software 
     15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     16 * 
     17 */ 
     18 
    119#ifndef NET_SOCKET_H 
    220#define NET_SOCKET_H 
     21 
     22#include <llist.h> 
     23 
     24/* Defines */ 
     25#define SOCKET_STATE_FREE               0 
     26#define SOCKET_STATE_BOUND              1 
     27#define SOCKET_STATE_ACCEPTING  2 
     28#define SOCKET_STATE_WAITING    3 /* For server to accept. */ 
     29#define SOCKET_STATE_CONNECTED  4 
     30 
     31#define SOCKET_TYPE_STREAM              0 
     32#define SOCKET_TYPE_SERVER              (1 << 31) 
     33 
     34#define SOCKET_DATA_LENGTH              20 
    335 
    436/* Structures */ 
     
    941}; 
    1042 
     43struct Socket 
     44{ 
     45        int state; 
     46        int family; 
     47        int type; 
     48        struct SocketAddr addr; 
     49        struct SocketOps* socketOps; 
     50 
     51        /* Since a server socket and server's children sockets are used for 
     52         * entirely different purposes, we can optimize structure size by 
     53         * using a union. 
     54         */ 
     55        union { 
     56                struct { 
     57                        struct ListHead recvPackets, sendPackets; 
     58                }; 
     59 
     60                struct ListHead childSocks; 
     61        }; 
     62        struct ListHead next; 
     63        struct Socket* parent; 
     64        void* protoInfo; 
     65}; 
     66 
     67struct SocketBuffer 
     68{ 
     69        int length; 
     70        int read; 
     71        struct ListHead next; 
     72        char data[1]; 
     73}; 
     74 
     75struct SocketOps 
     76{ 
     77        int (*bind)(struct Socket* socket, struct SocketAddr* addr, int length); 
     78        int (*connect)(struct Socket* socket, struct SocketAddr* addr, int length); 
     79        int (*create)(struct Socket* socket); 
     80        int (*close)(struct Socket* socket); 
     81        int (*listen)(struct Socket* socket, int backlog); 
     82        int (*accept)(struct Socket* socket, struct SocketAddr* addr, int* length); 
     83        int (*send)(struct Socket* socket, const void* buffer, int length, int flags); 
     84        int (*receive)(struct Socket* socket, void* buffer, int length, int flags); 
     85}; 
     86 
     87/* Prototypes */ 
     88int SocketRegisterFamily(int family, struct SocketOps* ops); 
     89int SocketInit(); 
     90int SocketClose(struct Socket* socket); 
     91int SocketSetupChild(struct Socket* parent, struct Socket* child); 
     92int SocketDoAccept(struct Socket* server, struct Socket* client, struct Socket** child); 
     93struct SocketBuffer* SocketAllocateBuffer(const void* buffer, int length); 
     94int SocketDestroyBuffer(struct SocketBuffer* sockBuff); 
     95 
    1196/* System calls */ 
    1297int SysSocketCreate(int domain, int type, int protocol); 
     
    1499int SysSocketConnect(int fd, struct SocketAddr* addr, int length); 
    15100int SysSocketListen(int fd, int backlog); 
    16 int SysSocketAccept(int fd, struct SocketAddr* addr, int length); 
     101int SysSocketAccept(int fd, struct SocketAddr* addr, int* length); 
     102int SysSocketSend(int fd, const void* buffer, int length, int flags); 
     103int SysSocketReceive(int fd, void* buffer, int length, int flags); 
     104int SysSocketIoCtl(int fd, unsigned long code, void* data); 
     105int SysSocketClose(int fd); 
    17106 
    18107#endif