⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if_ctl.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/router/if_ctl.c,v 1.2 2001/11/09 21:06:49 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved.  Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** *  Copyright 1994-1997 Epilogue Technology Corporation. *  Copyright 1998 Integrated Systems, Inc. *  All rights reserved. ****************************************************************************//* * $Log: if_ctl.c,v $ * Revision 1.2  2001/11/09 21:06:49  josh * demo router path modification * * Revision 1.1.1.1  2001/11/05 17:49:09  tneale * Tornado shuffle * * Revision 2.7  2001/01/19 22:24:37  paul * Update copyright. * * Revision 2.6  2000/03/17 00:14:18  meister * Update copyright message * * Revision 2.5  1998/03/03 15:24:31  mrf * Clean up short help and add new features to compile-options command. * * Revision 2.4  1998/02/25 04:57:46  sra * Update copyrights. * * Revision 2.3  1997/03/20 06:53:27  sra * DFARS-safe copyright text.  Zap! * * Revision 2.2  1997/02/25 10:58:16  sra * Update copyright notice, dust under the bed. * * Revision 2.1  1996/03/22 10:05:39  sra * Update copyrights prior to Attache 3.2 release. * * Revision 2.0  1995/05/10  22:38:15  sra * Attache release 3.0. * * Revision 1.2  1995/01/06  00:52:48  sra * Update copyright notice for 2.1 release. * * Revision 1.1  1994/12/20  22:42:45  dab * Initial revision * * *//* [clearcase]modification history-------------------01a,19apr05,job  update copyright notices*//* * Commands for poking around the interface list. */#include <stdio.h>#include <stdlib.h>#include <wrn/wm/attache/config.h>#include <wrn/wm/attache/mib.h>#include <wrn/wm/attache/timer.h>#include <wrn/wm/attache/packet.h>#include <wrn/wm/attache/net.h>#include <wrn/wm/attache/glue.h>#include <wrn/wm/attache/route.h>#include <wrn/wm/attache/ip.h>#include <wrn/wm/demo/snarklib.h>enum help_level { help_none, help_short, help_long };extern net_if *If_list;net_if *detached_If_list = 0;	/* net I detach get put here *//* Print stats about each net interface. */boolean_t  cmd_if_stat(struct sty *sty,	      enum help_level help,	      int argc,	      char **argv){  net_if *n;  char buf[80];  int ifIndex;  switch (help) {  case help_short:    sty_puts(sty, "ifstat          print interface statistics\n");    break;  case help_long:    sty_puts(sty, "\Print the status and statistics for each interface in the\n\interface list.\n");    break;  case help_none:    ifIndex = 1;    if (If_list == 0)      sty_puts(sty, "Interface list is empty\n");    else {      for (n = If_list; n; n = n->link) {	/* only prints up/down status right now */	sprintf(buf, "%2d: %10s %4s %10s\n",		ifIndex, n->s_name,		n->flags & NF_DOWN ? "Down" : "Up",		n->flags & NF_DRIVER_DOWN ? "DriverDown" : "DriverUp");	sty_puts(sty, buf);	ifIndex++;      }}    break;  }  return 1;			/* restart command scanner */}/* look up an interface by its name and return a pointer to the * structure or 0 if none is found.  List is the start of the * interface list, usually If_list if we want Attache's interfaces or * detached_If_list if it's an interface we've removed. */static net_if *  if_lookup_by_name(char *name, net_if *if_list){  net_if *n;  for (n = if_list; n; n = n->link)    if (STRCMP(n->s_name, name) == 0)      return n;  return 0;}/* mark an interface down */boolean_t  cmd_if_down(struct sty *sty,	      enum help_level help,	      int argc,	      char **argv){  net_if *n;  switch (help) {  case help_short:    sty_puts(sty, "down            down interface-name\n");    break;  case help_long:    sty_puts(sty, "Mark an interface as down.\n");    break;  case help_none:    if (argc != 2) {      sty_puts(sty, "usage: down interface-name\n");      break;    }    if ((n = if_lookup_by_name(argv[1], If_list)) != 0)      if_down(n);    else {      sty_puts(sty, "No interface called '");      sty_puts(sty, argv[1]);      sty_puts(sty, "'\n");    }    break;  }  return 1;			/* restart command scanner */}/* mark an interface up */boolean_t  cmd_if_up(struct sty *sty,	    enum help_level help,	    int argc,	    char **argv){  net_if *n;  switch (help) {  case help_short:    sty_puts(sty, "up              up interface-name\n");    break;  case help_long:    sty_puts(sty, "Mark an interface as up.\n");    break;  case help_none:    if (argc != 2) {      sty_puts(sty, "usage: up interface-name\n");      break;    }    if ((n = if_lookup_by_name(argv[1], If_list)) != 0)      if_up(n);    else {      sty_puts(sty, "No interface called '");      sty_puts(sty, argv[1]);      sty_puts(sty, "'\n");    }    break;  }  return 1;			/* restart command scanner */}/* Detach this interface.  The interface is placed on a detached list * so it can be re-attached later. */boolean_t  cmd_if_detach(struct sty *sty,		enum help_level help,		int argc,		char **argv){  net_if *n;  switch (help) {  case help_short:    sty_puts(sty, "detach          detach interface-name\n");    break;  case help_long:    sty_puts(sty, "\Remove an interface from Attache's knowledge.  It is\n\placed on a detached list so it can be reattached later.\n");    break;  case help_none:    if (argc != 2) {      sty_puts(sty, "usage: detach interface-name\n");      break;    }    if ((n = if_lookup_by_name(argv[1], If_list)) != 0) {      /* remove the interface from Attache */      if_detach(n);      /* thread the interface onto here so we can reattach it later */      n->link = detached_If_list;      detached_If_list = n;    }    else {      sty_puts(sty, "No interface called '");      sty_puts(sty, argv[1]);      sty_puts(sty, "'\n");    }    break;  }  return 1;			/* restart command scanner */}/* Interfaces that have been detached with the `detach' command can be   reattached with this command. */boolean_t  cmd_if_attach(struct sty *sty,		enum help_level help,		int argc,		char **argv){  net_if *n;  net_if **np;  switch (help) {  case help_short:    sty_puts(sty, "attach          attach interface-name\n");    break;  case help_long:    sty_puts(sty, "\Reattach an interface that was removed with the `detach' command.\n");    break;  case help_none:    if (argc != 2) {      sty_puts(sty, "usage: attach interface-name\n");      if (detached_If_list == 0)	sty_puts(sty, "      No interfaces on detached list\n");      else {	sty_puts(sty, "      One of:");	for (n = detached_If_list; n; n = n->link) {	  sty_puts(sty, "\n       ");	  sty_puts(sty, n->s_name);	}	sty_puts(sty, "\n");      }      break;    }    if ((n = if_lookup_by_name(argv[1], detached_If_list)) != 0) {      /* remove the interface from the detached list */      for (np = &detached_If_list; *np; np = &((*np)->link)) {	if ((*np) == n) {	  *np = (*np)->link;	  break;	}      }      /* tell Attache about it */      if_attach(n);    }    else {      sty_puts(sty, "No detached interface called '");      sty_puts(sty, argv[1]);      sty_puts(sty, "'\n");    }    break;  }  return 1;			/* restart command scanner */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -