2010-04-08 15:41:35 +02:00
|
|
|
/* This file contains device independent network device driver interface.
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* Apr 01, 2010 Created (Cristiano Giuffrida)
|
|
|
|
*
|
|
|
|
* The file contains the following entry points:
|
|
|
|
*
|
|
|
|
* netdriver_announce: called by a network driver to announce it is up
|
|
|
|
* netdriver_receive: receive() interface for network drivers
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <minix/drivers.h>
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#include <minix/netdriver.h>
|
|
|
|
#include <minix/ds.h>
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static int conf_expected = TRUE;
|
2010-04-08 15:41:35 +02:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* netdriver_announce *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void netdriver_announce()
|
2010-04-08 15:41:35 +02:00
|
|
|
{
|
|
|
|
/* Announce we are up after a fresh start or restart. */
|
|
|
|
int r;
|
|
|
|
char key[DS_MAX_KEYLEN];
|
|
|
|
char label[DS_MAX_KEYLEN];
|
|
|
|
char *driver_prefix = "drv.net.";
|
|
|
|
|
|
|
|
/* Publish a driver up event. */
|
|
|
|
r = ds_retrieve_label_name(label, getprocnr());
|
|
|
|
if (r != OK) {
|
|
|
|
panic("driver_announce: unable to get own label: %d\n", r);
|
|
|
|
}
|
|
|
|
snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
|
|
|
|
r = ds_publish_u32(key, DS_DRIVER_UP, DSF_OVERWRITE);
|
|
|
|
if (r != OK) {
|
|
|
|
panic("driver_announce: unable to publish driver up event: %d\n", r);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf_expected = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* netdriver_receive *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int netdriver_receive(src, m_ptr, status_ptr)
|
2010-04-08 15:41:35 +02:00
|
|
|
endpoint_t src;
|
|
|
|
message *m_ptr;
|
|
|
|
int *status_ptr;
|
|
|
|
{
|
|
|
|
/* receive() interface for drivers. */
|
|
|
|
int r;
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
/* Wait for a request. */
|
|
|
|
r = sef_receive_status(src, m_ptr, status_ptr);
|
|
|
|
if (r != OK) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-08-18 12:04:25 +02:00
|
|
|
/* Let non-datalink requests through regardless. */
|
|
|
|
if (!IS_DL_RQ(m_ptr->m_type)) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-04-08 15:41:35 +02:00
|
|
|
/* See if only DL_CONF is to be expected. */
|
|
|
|
if(conf_expected) {
|
|
|
|
if(m_ptr->m_type == DL_CONF) {
|
|
|
|
conf_expected = FALSE;
|
|
|
|
}
|
2010-05-18 00:22:53 +02:00
|
|
|
else {
|
2010-04-08 15:41:35 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|