net_data -> net_buffer update.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3325 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5a52a89c28
commit
82238517b4
@ -84,9 +84,9 @@ status_t down(ifnet_t *iface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t send(ifnet_t *iface, net_data *data)
|
status_t send(ifnet_t *iface, net_buffer *buffer)
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!buffer)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// TODO!
|
// TODO!
|
||||||
@ -94,10 +94,10 @@ status_t send(ifnet_t *iface, net_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t receive(ifnet_t *iface, net_data **data)
|
status_t receive(ifnet_t *iface, net_buffer **received_buffer)
|
||||||
{
|
{
|
||||||
ethernet_interface *ei = (ethernet_interface *) iface;
|
ethernet_interface *ei = (ethernet_interface *) iface;
|
||||||
net_data *nd;
|
net_buffer *buffer;
|
||||||
void *frame;
|
void *frame;
|
||||||
size_t len;
|
size_t len;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
@ -107,21 +107,21 @@ status_t receive(ifnet_t *iface, net_data **data)
|
|||||||
if (!frame)
|
if (!frame)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
nd = g_stack->new_data();
|
buffer = g_stack->new_buffer();
|
||||||
if (!nd) {
|
if (!buffer) {
|
||||||
free(frame);
|
free(frame);
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
};
|
};
|
||||||
|
|
||||||
sz = read(ei->fd, frame, len);
|
sz = read(ei->fd, frame, len);
|
||||||
if (sz >= B_OK) {
|
if (sz >= B_OK) {
|
||||||
g_stack->append_data(nd, frame, sz, (data_node_free_func) free);
|
g_stack->add_to_buffer(buffer, 0, frame, sz, (buffer_chunk_free_func) free);
|
||||||
*data = nd;
|
*received_buffer = buffer;
|
||||||
return sz;
|
return sz;
|
||||||
};
|
};
|
||||||
|
|
||||||
free(frame);
|
free(frame);
|
||||||
g_stack->delete_data(nd, false);
|
g_stack->delete_buffer(buffer, false);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
typedef struct loopback_interface {
|
typedef struct loopback_interface {
|
||||||
ifnet_t ifnet;
|
ifnet_t ifnet;
|
||||||
net_data_queue *queue;
|
net_buffer_queue *queue;
|
||||||
} loopback_interface;
|
} loopback_interface;
|
||||||
|
|
||||||
|
|
||||||
@ -32,12 +32,12 @@ status_t init(void * params)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
// create loopback fifo queue, to keep packets *sent*
|
// create loopback fifo queue, to keep packets *sent*
|
||||||
li->queue = g_stack->new_data_queue(64*LOOPBACK_MTU);
|
li->queue = g_stack->new_buffer_queue(64*LOOPBACK_MTU);
|
||||||
|
|
||||||
|
|
||||||
iface = &li->ifnet;
|
iface = &li->ifnet;
|
||||||
iface->if_name = "loopback";
|
iface->if_name = "loopback";
|
||||||
iface->if_flags = (IFF_LOOPBACK | IFF_MULTICAST);
|
iface->if_flags = (IFF_LOOPBACK | IFF_NOARP);
|
||||||
iface->if_type = 0x10; //IFT_LOOP
|
iface->if_type = 0x10; //IFT_LOOP
|
||||||
iface->if_mtu = LOOPBACK_MTU;
|
iface->if_mtu = LOOPBACK_MTU;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ status_t uninit(ifnet_t *iface)
|
|||||||
loopback_interface *li = (loopback_interface *) iface;
|
loopback_interface *li = (loopback_interface *) iface;
|
||||||
|
|
||||||
printf("loopback: uniniting %s interface\n", iface->if_name);
|
printf("loopback: uniniting %s interface\n", iface->if_name);
|
||||||
return g_stack->delete_data_queue(li->queue);
|
return g_stack->delete_buffer_queue(li->queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t up(ifnet_t *iface)
|
status_t up(ifnet_t *iface)
|
||||||
@ -67,22 +67,22 @@ status_t down(ifnet_t *iface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t send(ifnet_t *iface, net_data *data)
|
status_t send(ifnet_t *iface, net_buffer *buffer)
|
||||||
{
|
{
|
||||||
loopback_interface *li = (loopback_interface *) iface;
|
loopback_interface *li = (loopback_interface *) iface;
|
||||||
|
|
||||||
if (!data)
|
if (!buffer)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
return g_stack->enqueue_data(li->queue, data);
|
return g_stack->enqueue_buffer(li->queue, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t receive(ifnet_t *iface, net_data **data)
|
status_t receive(ifnet_t *iface, net_buffer **buffer)
|
||||||
{
|
{
|
||||||
loopback_interface *li = (loopback_interface *) iface;
|
loopback_interface *li = (loopback_interface *) iface;
|
||||||
|
|
||||||
return g_stack->dequeue_data(li->queue, data, B_INFINITE_TIMEOUT, false);
|
return g_stack->dequeue_buffer(li->queue, buffer, B_INFINITE_TIMEOUT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user