Commit b3c5e11e authored by Alessandro Rubini's avatar Alessandro Rubini

config: allow changing config for existing ports

The "port" config word is not creating a new port any more, it locates
an existing port, if any is there.  This allows, for example, to set
diagnostics from the command line:

	    -C  "port eth0; diagnostics 022"
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c3a762b8
......@@ -18,9 +18,18 @@
static struct pp_globals *current_ppg;
static struct pp_instance *current_ppi;
/* A "port" (or "link", for compatibility) line creates a ppi instance */
/* A "port" (or "link", for compatibility) line creates or uses a pp instance */
static int f_port(int lineno, int iarg, char *sarg)
{
int i;
/* First look for an existing port with the same name */
for (i = 0; i < current_ppg->nlinks; i++) {
current_ppi = current_ppg->pp_instances + i;
if (!strcmp(sarg, current_ppi->cfg.port_name))
return 0;
}
/* Allocate a new ppi */
if (current_ppg->nlinks >= current_ppg->max_links) {
pp_printf("config line %i: out of available ports\n",
lineno);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment