static dpeth_t de_table[DE_PORT_NR];
static u16_t eth_ign_proto;
+static char *progname;
/* Configuration */
typedef struct dp_conf
_PROTOTYPE( static void do_init, (message *mp) );
_PROTOTYPE( static void do_int, (dpeth_t *dep) );
_PROTOTYPE( static void do_getstat, (message *mp) );
+_PROTOTYPE( static void do_getname, (message *mp) );
_PROTOTYPE( static void do_stop, (message *mp) );
_PROTOTYPE( static void dp_init, (dpeth_t *dep) );
_PROTOTYPE( static void dp_confaddr, (dpeth_t *dep) );
int main(int argc, char *argv[])
{
message m;
- int i, irq, r;
+ int i, irq, r, tasknr;
dpeth_t *dep;
long v;
+ if (argc < 1)
+ {
+ panic("DP8390",
+ "A head which at this time has no name", NO_NUM);
+ }
+ (progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]);
+
env_setargs(argc, argv);
for (i= 0, dep= de_table; i<DE_PORT_NR; i++, dep++)
(void) env_parse("ETH_IGN_PROTO", "x", 0, &v, 0x0000L, 0xFFFFL);
eth_ign_proto= htons((u16_t) v);
+ /* Try to notify inet that we are present (again) */
+ r = findproc("inet", &tasknr);
+ if (r == OK)
+ notify(tasknr);
+
while (TRUE)
{
if ((r= receive(ANY, &m)) != OK)
case DL_READV: do_vread(&m, TRUE); break;
case DL_INIT: do_init(&m); break;
case DL_GETSTAT: do_getstat(&m); break;
+ case DL_GETNAME: do_getname(&m); break;
case DL_STOP: do_stop(&m); break;
case HARD_INT:
for (i= 0, dep= &de_table[0]; i<DE_PORT_NR; i++, dep++)
reply(dep, OK, FALSE);
}
+/*===========================================================================*
+ * do_getname *
+ *===========================================================================*/
+static void do_getname(mp)
+message *mp;
+{
+ int r;
+
+ strncpy(mp->DL_NAME, progname, sizeof(mp->DL_NAME));
+ mp->DL_NAME[sizeof(mp->DL_NAME)-1]= '\0';
+ mp->m_type= DL_NAME_REPLY;
+ r= send(mp->m_source, mp);
+ if (r != OK)
+ panic("dp8390", "do_getname: send failed: %d\n", r);
+}
+
/*===========================================================================*
* do_stop *
*===========================================================================*/
u8_t inb(port_t port)
{
int r;
- u8_t value;
+ u32_t value;
r= sys_inb(port, &value);
if (r != OK)
*/
extern int errno;
static dpeth_t de_table[DE_PORT_NR];
+static char *progname;
typedef struct dp_conf { /* Configuration description structure */
port_t dpc_port;
static const char TypeErrMsg[] = "illegal message type";
static const char DevName[] = "eth#?";
+static void do_getname(message *mp);
+
/*
** Name: void reply(dpeth_t *dep, int err)
** Function: Fills a DL_TASK_REPLY reply message and sends it.
return;
}
+static void do_getname(mp)
+message *mp;
+{
+ int r;
+
+ strncpy(mp->DL_NAME, progname, sizeof(mp->DL_NAME));
+ mp->DL_NAME[sizeof(mp->DL_NAME)-1]= '\0';
+ mp->m_type= DL_NAME_REPLY;
+ r= send(mp->m_source, mp);
+ if (r != OK)
+ panic("dpeth", "do_getname: send failed: %d\n", r);
+}
+
/*
** Name: void do_stop(message *mp)
** Function: Stops network interface.
{
message m;
dpeth_t *dep;
- int rc, fkeys, sfkeys;
+ int rc, fkeys, sfkeys, tasknr;
+
+ (progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]);
env_setargs(argc, argv);
}
#endif
+ /* Try to notify inet that we are present (again) */
+ rc = findproc("inet", &tasknr);
+ if (rc == OK)
+ notify(tasknr);
+
while (TRUE) {
if ((rc = receive(ANY, &m)) != OK) panic(dep->de_name, RecvErrMsg, rc);
case DL_GETSTAT: /* Get device statistics */
do_getstat(&m);
break;
+ case DL_GETNAME:
+ do_getname(&m);
+ break;
case SYN_ALARM: /* to be defined */
do_watchdog(&m);
break;