net_cfg.c revision cee0fb94c0d4227de0a00efc162fb2739844b641
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>
#include "mms_list.h"
#include "mms_parser.h"
#include "mms_network.h"
#include "mms_cfg.h"
#include <mms_trace.h>
#define MMS_OK 0
#define MMS_ERROR -1
/*
* mms_build_net_cfg()
*
* Parameters:
* net Ptr to mms_network_cfg structure that is to be populated from
* the network configuration file
* cfg Ptr to arse tree of network configuration file
*
* Globals:
* None
*
* Obtain a module's network configuration information from the parse tree.
* The information is then stored in the mms_network_cfg structure to be used
* to connect to MM
*
* Return Values:
* MMS_OK: Able to obtain all network information correctly.
* MMS_ERROR: Unable to obtain all network information.
*
*/
static int
{
char *kw;
/* configuration */
/* network configuration */
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
MMS_PN_KEYWORD, NULL)) {
}
return (MMS_OK);
"Missing keyword - %s in config "
return (MMS_ERROR);
}
/*
* mms_net_cfg_read()
*
* Parameters:
* net Ptr to module's mms_network_cfg, which is a generic strcture
* used by mms_mmconnect to connect to the MM. This routine
* passes this to mms_build_net_cfg() to actually populate the
* structure
* cfgfn Path and name of the network configuration file that is to
* be parsed
*
* Globals:
* None
*
* Read network configuration for a module and then parses the contents of
* the file and then populates the mms_network_cfg structure. This structure
* is then passed to mms_mmconnect() to do the actual connect to MM on behalf
* of the module.
*
* Return Values:
* MMS_OK: If the configuration file parses cleanly.
* MMS_ERROR: If the configuration file contained errors.
*
*/
int
{
char *buf;
int rc;
int fd;
"Unable to open config file %s\n",
return (MMS_ERROR);
}
/* Allocate a buffer to read in the entire config file */
"Unable to stat config file %s\n",
return (MMS_ERROR);
}
"Unable to alloc buf for config file %s\n",
return (MMS_ERROR);
}
/* Read in config file */
"Unable to read config file %s\n",
return (MMS_ERROR);
}
/* Parse the config file */
"line %d, col %d, near token \"%s\", "
"err code %d, %s",
}
return (MMS_ERROR);
}
"network config structure from config file %s\n",
}
return (rc);
}
void
{
}
}