Changeset 639 for Whitix/branches

Show
Ignore:
Timestamp:
06/24/08 14:02:21 (5 months ago)
Author:
mwhitworth
Message:

Add to net device API, add NetDeviceSend function.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Whitix/branches/network/net/device.c

    r316 r639  
    2121#include <init.h> 
    2222#include <net/network.h> 
     23#include <net/socket.h> 
    2324#include <slab.h> 
    2425 
     
    3334{ 
    3435        return (struct NetDevice*)MemCacheAlloc(netDeviceCache); 
     36} 
     37 
     38/* Public API */ 
     39 
     40int NetDeviceSend(struct NetDevice* device, struct SocketBuffer* buffer) 
     41{ 
     42        if (!device->ops || !device->ops->send) 
     43                return -ENOTIMPL; 
     44 
     45        if (device-> state & NET_DEVICE_QUEUE_RUNNING) 
     46                return device->ops->send(device, buffer); 
     47        else{ 
     48                /* Add the packet onto the queue, and wait for the device to pick 
     49                 * it up once it has finished an event like a send interrupt. 
     50                 */ 
     51                ListAddTail(&buffer->next, &device->sendList); 
     52        } 
    3553} 
    3654 
     
    6684 
    6785        DevAddDevice(buf, NETWORK_MAJOR, 0, DEVICE_CHAR, &netFileOps); 
     86        INIT_LIST_HEAD(&device->sendList); 
     87        device->state = NET_DEVICE_UP | NET_DEVICE_QUEUE_RUNNING; 
    6888 
    6989        return 0;