mipagentconfig.c revision 5c0b7edee9bd9fad49038456b16972ff28fa4187
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999-2002 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* This program is used to manipulate configuration files for mobile ip.
* It is used as follows (for more info on usage, check the man page(s):
*
* foo$ mipagentconfig add address 192.168.168.10 SPI 7
*
* The parameters are: Command, destination, [values . . . ]
*
* For each command/destination, an entry is looked up in a function table, and
* the appropriate function is called with the rest of the command line as
* parameters.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <libintl.h>
#include <locale.h>
#include "mipagentconfig.h"
#include "utils.h"
#include "general.h"
#include "gsp.h"
#include "advertisements.h"
#include "spi.h"
#include "pool.h"
#include "addr.h"
/*
* This is the string - to - enum table for command codes.
*/
CommandTable Commands[] = {
{ "add", Add },
{ "change", Change },
{ "delete", Delete },
{ "get", Get },
};
/*
* Function Notes:
*
* The first parameter passed to all functions is the command. This
* is to allow the same function to be used for all commands, add
* change, delete or get.
*
* You do not have to support all commands. For any unsupported command,
* just use NULL.
*/
/* Lable or tag, Section, SectionLabel, ADD, CHANGE, DELETE, GET */
/* From general.h */
ynFunc },
/* from gsp.h */
{ "maxClockSkew", "GlobalSecurityParameters", "maxClockSkew",
{ "keyDistribution", "GlobalSecurityParameters", "keyDistribution",
};
#define USAGE "%s: [ -f configfile ] command dest [parameters . . .] \n"
#define CONFIG_FILE "/etc/inet/mipagent.conf"
int
{
extern char *optarg;
extern int optind;
int c;
char *configFile = CONFIG_FILE;
int argsLeft;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'f' : /* Change the config file */
configFile = optarg;
break;
case '?':
case 'h': /* print usage */
return (0);
}
} /* while . . . getopt */
if (argsLeft < 2) {
gettext("Error: Not enough arguments.\n"));
return (-1);
}
/* Now, Check the command */
if (command < 0) {
return (-1);
}
/* Finally, look up our functions and call them based on the dest */
if (funcEntry) {
/* Now check the particular function we need. */
switch (command) {
case Add:
break;
case Change:
break;
case Delete:
break;
case Get:
break;
}
} else {
gettext("Error: <%s> is not valid for <%s>\n"),
return (-1);
}
if (!function) {
gettext("Error: %s does not support '%s'.\n"),
return (-1);
}
/* And finally, call function */
} /* main */