示例#1
0
int
HandleNetoidFind(Command *comm, int argc, char **argv)
{
     char *serNo;
     unsigned long port;
     NetoidInfoEntry *netInfo;
     NetoidSNKey key;
     
     log(LOG_DEBUG, 0, "Entering Netoid Find with argc=%d\n", argc);

     if (argc < 2)
     {
	 /* Here we prompt the user for the rest of the 
	  * information
	  */
	 HandleCommandUsage(comm, argc, argv);
	 return -xleInsuffArgs;
     }

     /* Registration No */
     serNo = argv[0];
     log(LOG_DEBUG, 0, "Ser No is %s\n", serNo);
     
     port = atoi(argv[1]);

     strncpy(key.regid, serNo, REG_ID_LEN);
     key.uport = port;

     if (OpenDatabases((DefCommandData *)comm->data) < 0)
     {
	return -xleOpNoPerm;
     }

     netInfo = DbFindInfoEntry(GDBMF(comm->data, DB_eNetoids), 
				(char *)&key, sizeof(key));
     if (!netInfo)
     {
	 CLIPRINTF((stdout, "No entry (%s, %lu) found\n", serNo, port));
     }
     else
     {
	 PrintDbInfoEntry(stdout, netInfo);
	 CLIPRINTF((stdout, "\n\n"));
	 free(netInfo);
     }

     CloseDatabases((DefCommandData *)comm->data);

     return xleOk;
}
示例#2
0
MDBManager::~MDBManager()
{
    CloseDatabases();

    if (m_connCount != 0 || m_schedCon || m_DDCon)
    {
        LOG(VB_GENERAL, LOG_CRIT,
            "MDBManager exiting with connections still open");
    }
#if 0 /* some post logStop() debugging... */
    cout<<"m_connCount: "<<m_connCount<<endl;
    cout<<"m_schedCon: "<<m_schedCon<<endl;
    cout<<"m_DDCon: "<<m_DDCon<<endl;
#endif
}
示例#3
0
int
HandleNetoidEdit(Command *comm, int argc, char **argv)
{
   	char *serNo, *ports, *temps,*ptrptr, *tok;
    unsigned long port = 0, portH = 0;
    char *vpnId;
    NetoidInfoEntry *netInfo = 0;
	CacheTableInfo cacheInfoEntry;
	ClientAttribs *clAttribs = 0;
    NetoidSNKey key = { 0 };
	VpnEntry vpnKey = { 0 }, *vpnEntry = NULL;
	char storeb[1024], oldrealmname[REALM_NAME_LEN];
	long portsState = ~CL_REGISTERED, portsStateOr = 0;
	int rc = xleOk, obtainedRegid = 0;
	char	ch;

    if (argc <= 2)
    {
		/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
		
	 	NetoidEditHelp(comm, argc, argv);
	 	//HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }

    /* Registration No */
    serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

    argc -= 2;
    argv += 2;

    strncpy(key.regid, serNo, REG_ID_LEN);

    while (port <= portH)
    {
	 	key.uport = port;

		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, 
				sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

	 	if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 	{
			return -xleOpNoPerm;
	 	}

	 	clAttribs = DbFindAttrEntry(GDBMF(comm->data, DB_eAttribs),
			(char *)&key, sizeof(key));

	 	if (netInfo)
	 	{
			strcpy(vpnKey.vpnName, netInfo->vpnName);
	 	}

	 	if (strlen(vpnKey.vpnName))
	 	{
	 		vpnEntry = DbFindVpnEntry(GDBMF(comm->data, DB_eVpns),
						(char *)&vpnKey, sizeof(VpnKey));
	 	}

	 	CloseDatabases((DefCommandData *)comm->data);

	 	if (netInfo == 0)
	 	{
			CLIPRINTF((stdout, "iedge Not found in Cache/Database\n"));
			return -xleNoEntry;
	 	}

	 	if (clAttribs == 0)
	 	{
			/* Attributes not found */
			clAttribs = (ClientAttribs *)malloc(sizeof(ClientAttribs));
			memset(clAttribs, 0, sizeof(ClientAttribs));
	 	}

		nx_strlcpy(oldrealmname, netInfo->realmName, REALM_NAME_LEN);

	 	if (argc > 0)
	 	{
			GetNetoidAttrPairs(comm->name, &argc, &argv, 
				netInfo, clAttribs);
			goto _storedb;	
	 	}

	 	if (cliLibFlags == 0) 
		{
			/* we should not be getting here... */
			NETERROR(MCLI, ("Invalid arguments passed from jserver\n"));
			rc = -xleInvalArgs;
			goto _error;
	 	}

		CLIPRINTF((stdout, "Map ISDN Code Code [%s]: ", 
			(netInfo->ecaps1&ECAPS1_MAPISDNCC)?"enable":"disable"));
		GetInput(stdin, storeb, 10);
		if (strlen(storeb) > 0) 
		{
			if(!strcmp(storeb, "enable"))
			{
				netInfo->ecaps1 |= ECAPS1_MAPISDNCC;
			}
			else
			{
				netInfo->ecaps1 &= ~ECAPS1_MAPISDNCC;
			}
		}

	_storedb:
		// Flags must be adjusted, if ip address was deleted
		if (!BIT_TEST(netInfo->sflags, ISSET_IPADDRESS))
		{
			netInfo->stateFlags &= ~CL_ACTIVE;
			portsState &= ~CL_ACTIVE;
		}

		netInfo->stateFlags &= ~CL_REGISTERED;
		netInfo->mTime = time(0);
	
		if (strcmp(oldrealmname, netInfo->realmName))
		{
			netInfo->realmId = realmNameToRealmId(netInfo->realmName);
		}

		if (UpdateNetoidInCache(netInfo) < 0)
		{
			rc = -xleExists;
			goto _error;
		}
	
		if (IsSGatekeeper(netInfo))
		{
			// Sgatekeepers no longer allowed to be marked
			// static
			netInfo->stateFlags &= ~CL_STATIC;
		}

		/* reflect the static bit */
		if (netInfo->stateFlags & CL_STATIC)
		{
			portsStateOr |= CL_STATIC;
		}
		else
		{
			portsState &= ~CL_STATIC;
		}

		if (netInfo->stateFlags & CL_STATIC)
		{
			UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, 
				&portsStateOr, 
				netInfo->ipaddress.l?&netInfo->ipaddress.l:NULL);
		}
		else
		{
			UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, 
				&portsStateOr, NULL);
		}


		UpdateNetoidDatabase(netInfo);
	
		UpdateNetoidAttrDatabase((NetoidSNKey*)netInfo, clAttribs);
	
	_continue:	 
	_error:
		port ++;
	
	    netInfo = NULL;
		free(clAttribs); clAttribs = NULL;
	
		if (rc < 0)
		{
			return rc;
		}
     }
  
     if (argc > 0)
     {
		/* All arguments not exhausted... */
		CLIPRINTF((stdout, "%s: Error: Insufficient Arguments \n", comm->name));
		return -xleInvalArgs;
     }

	return xleOk;
}     
示例#4
0
int
HandleNetoidAdd(Command *comm, int argc, char **argv)
{
   	char *serNo, *ports, *temps, *ptrptr, *tok;
   	unsigned long port = 0, portH = 0;
   	char *vpnName;
   	VpnEntry vpnEntry;
   	NetoidInfoEntry *netInfo, entry, *tmp;
	int shmId;
	void *addr;
	int rc = 0;
	long portsState = ~CL_REGISTERED;
   	if (argc < 2)
   	{
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
   	}

   	/* Registration No */
   	serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
   		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

   	argc -= 2;
   	argv += 2;

   	netInfo = &entry;

   	while (port <= portH)
   	{
     	InitNetoidInfoEntry(netInfo);

		// Get a random crid here
		netInfo->crId = lrand48();

   	 	strncpy(netInfo->regid, serNo, REG_ID_LEN);
   	 	netInfo->uport = port;

	 	if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 	{
			return -xleOpNoPerm;
	 	}

   	 	if (tmp = DbFindInfoEntry(GDBMF(comm->data, DB_eNetoids), 
				(char *)netInfo, sizeof(NetoidSNKey)))
	 	{
	 		CLIPRINTF((stdout, 
			"entry (%s, %lu) already exists\n", serNo, port));
			argc -=1;
	     		argv +=1;

			free(tmp);

	 		port ++;
	 		CloseDatabases((DefCommandData *)comm->data);
			return -xleExists;
	 	}

	 	CloseDatabases((DefCommandData *)comm->data);

   	 	BIT_SET(netInfo->sflags, ISSET_REGID);
   	 	BIT_SET(netInfo->sflags, ISSET_UPORT);
		netInfo->ecaps1 |= ECAPS1_NOCONNH245;

	 	netInfo->iTime = netInfo->mTime = netInfo->rTime = time(0);

#if 0
	 	if (license_allocate(1))
	 	{
		 	CLIPRINTF((stdout,"could not obtain license\n"));
		 	return -xleNoLicense;
	 	}
#endif

		/* Check to see if there are other ports of this iedge */
		InheritIedgeGlobals(netInfo);

	 	/* Update the iedge in cache */
	 	if (UpdateNetoidInCache(netInfo) < 0)
	 	{
			return -xleExists;
	 	}

		UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, NULL, NULL);

		UpdateNetoidDatabase(netInfo);

	 	port ++;
    }

    return xleOk;
}
示例#5
0
int
HandleNetoidList(Command *comm, int argc, char **argv)
{
     long serNo;
     NetoidInfoEntry *netInfo;
	 ClientAttribs *clAttribs;
     NetoidSNKey *key, *okey;
     int n = 0;
	char ttypname[2*_POSIX_PATH_MAX];

	if (ttyname_r(1, ttypname, 2*_POSIX_PATH_MAX) != ENOTTY)
	{
		CLIPRINTF((stdout, "Please redirect output to a file\n"));
		return 0;
	}

     log(LOG_DEBUG, 0, "Entering Netoid List with argc=%d\n", argc);

     if (argc != 0)
     {
	 /* Here we prompt the user for the rest of the 
	  * information
	  */
	 HandleCommandUsage(comm, argc, argv);
	 return -xleInsuffArgs;
     }

     if (OpenDatabases((DefCommandData *)comm->data) < 0)
     {
	return -xleOpNoPerm;
     }

     for (key = (NetoidSNKey *)DbGetFirstInfoKey(GDBMF(comm->data, 
						DB_eNetoids)); key != 0; 
	 key = (NetoidSNKey *)DbGetNextInfoKey(GDBMF(comm->data, 
						DB_eNetoids),
						(char *)key, 
						sizeof(NetoidSNKey)),
	      					free(okey))
     {
	 netInfo = DbFindInfoEntry(GDBMF(comm->data, DB_eNetoids), 
					(char *)key, sizeof(NetoidSNKey));
	 clAttribs = DbFindAttrEntry(GDBMF(comm->data, DB_eAttribs), 
					(char *)key, sizeof(NetoidSNKey));
	 PrintInfoEntry(stdout, netInfo);
	 PrintDbAttrEntry(stdout, clAttribs);
	 free(netInfo);
	 if (clAttribs)
	 {
		free(clAttribs);
	 }
	 CLIPRINTF((stdout, "\n\n"));
	 okey = key;
	 n ++;
     }

     CloseDatabases((DefCommandData *)comm->data);

	CLIPRINTF((stdout, "%d Endpoints\n\n", n));

     return xleOk;
}
示例#6
0
int
HandleNetoidVpns(Command *comm, int argc, char **argv)
{
    char fn[] = "HandleNetoidVpns():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
    unsigned long port = 0, portH = 0;
    char *vpnName;
    NetoidSNKey key;
    NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	VpnEntry vpnKey = { 0 }, *vpnEntry = NULL;
	int shmId;
	void *addr;
	long portsState = ~CL_REGISTERED;
	int rc = xleOk, obtainedRegid = 0;
    if (argc < 2)
    {
	 	/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }

    /* Registration No */
    serNo = argv[0];

	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

    argc -= 2;
    argv += 2;

 	strncpy(key.regid, serNo, REG_ID_LEN);

    while ((port <= portH) && (argc > 0))
    {
	 	key.uport = port;

		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

	 	if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 	{
			return -xleOpNoPerm;
	 	}

	 	/* This port has a specified vpn */
	 	vpnName = argv[0];

	 	if (strlen(vpnName))
	 	{
			strcpy(vpnKey.vpnName, vpnName);
	 		vpnEntry = DbFindVpnEntry(GDBMF(comm->data, DB_eVpns),
						(char *)&vpnKey, sizeof(VpnKey));
	 	}

	 	CloseDatabases((DefCommandData *)comm->data);

        if (!netInfo)
        {
     	   	CLIPRINTF((stdout, "%s: Unable to find the iedge %s\n", 
				fn, serNo));
	      	rc = -xleNoEntry;
			goto _error;
        }

		strcpy(netInfo->vpnName, vpnName);

		AssignIedgePhone(netInfo, vpnEntry);

		netInfo->stateFlags &= ~CL_REGISTERED;
		netInfo->mTime = time(0);

        if (UpdateNetoidInCache(netInfo) < 0)
		{
			rc = -xleExists;
			goto _error;
		}

	 	UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, NULL, NULL);

		UpdateNetoidDatabase(netInfo);

		netInfo = NULL;

	 	if (vpnEntry)
	 	{
			free(vpnEntry);
			vpnEntry = NULL;
	 	}

		port ++;
	}

     return xleOk;

_error:
	if (netInfo)
	{
		free(netInfo);
	}
		
	if (vpnEntry)
	{
		free(vpnEntry);
	}
	return(rc);
}
示例#7
0
int
HandleNetoidZone(Command *comm, int argc, char **argv)
{
     char fn[] = "HandleNetoidZone():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
     unsigned long port = 0, portH = 0;
     NetoidSNKey key;
     NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	int rc = xleOk, obtainedRegid = 0;
     log(LOG_DEBUG, 0, "Entering Netoid Zone with argc=%d\n", argc);

     if (argc < 2)
     {
	 /* Here we prompt the user for the rest of the 
	  * information
	  */
	 HandleCommandUsage(comm, argc, argv);
	 return -xleInsuffArgs;
     }


     /* Registration No */
     serNo = argv[0];
     log(LOG_DEBUG, 0, "Ser No is %s\n", serNo);
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

     log(LOG_DEBUG, 0, "Ports is (%d..%d)\n", port, portH);

     argc -= 2;
     argv += 2;

	 strncpy(key.regid, serNo, REG_ID_LEN);

     while (port <= portH)
     {
	 	key.uport = port;
	 
		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

          if (!netInfo)
          {
     	      log(LOG_DEBUG, 0, "%s: Unable to find the iedge %s\n", 
				fn, serNo);
	      return -xleNoEntry;
          }

	 if (argc -- > 0)
	 {
	      /* This port has a specified zone num */
	      log(LOG_DEBUG, 0, "Zone is %s\n", argv[0]);
	      
	      strncpy(netInfo->zone, argv[0], ZONE_LEN);
	      argv ++;
	 }

	 netInfo->mTime = time(0);

	 if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 {
		return -xleOpNoPerm;
	 }

	 /* Read the Vpn information here */
	 if (DbStoreInfoEntry(GDBMF(comm->data, DB_eNetoids), netInfo, 
			      (char *)netInfo, sizeof(NetoidSNKey)) < 0)
	 {
	      log(LOG_ERR, errno, "database store error \n");
	 }

	 CloseDatabases((DefCommandData *)comm->data);

	 /* If this netoid is in the cache, delete it */
	 UpdateNetoidInCache(netInfo);

	 port ++;
     }

     return xleOk;
}
示例#8
0
int
HandleNetoidEmail(Command *comm, int argc, char **argv)
{
	char fn[] = "HandleNetoidEmail():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
	unsigned long port = 0, portH = 0;
	NetoidSNKey key;
	NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	int rc = xleOk, obtainedRegid = 0;
	if (argc < 2)
    {
	 	/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }


    /* Registration No */
    serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

    argc -= 2;
    argv += 2;

	strncpy(key.regid, serNo, REG_ID_LEN);

    while (port <= portH)
    {
	 	key.uport = port;
	 
		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

        if (!netInfo)
        {
     	    CLIPRINTF((stdout, "%s: Unable to find the iedge %s\n", 
					fn, serNo));
	      	return -xleNoEntry;
        }

	 	if (argc -- > 0)
	 	{
	      	/* This port has a specified phone num */
	      
	      	strncpy(netInfo->email, argv[0], EMAIL_LEN);
			if (strlen(netInfo->email))
			{
	      		BIT_SET(netInfo->sflags, ISSET_EMAIL);
			}
			else
			{
	      		BIT_RESET(netInfo->sflags, ISSET_EMAIL);
			}

	      	argv ++;
	 	}

	 	netInfo->stateFlags &= ~CL_REGISTERED;
	 	netInfo->mTime = time(0);

	 	/* If this netoid is in the cache, delete it */
	 	if (UpdateNetoidInCache(netInfo) < 0)
		{
			rc = -xleExists;
			goto _error;
		}

	 	if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 	{
			return -xleOpNoPerm;
	 	}

	 	/* Read the Vpn information here */
	 	if (DbStoreInfoEntry(GDBMF(comm->data, DB_eNetoids), netInfo, 
			      (char *)netInfo, sizeof(NetoidSNKey)) < 0)
	 	{
	      NETERROR(MCLI, ("database store error\n"));
	 	}

	 	CloseDatabases((DefCommandData *)comm->data);

_error:
	 	netInfo = NULL;
	 	port ++;
	 	if (rc < 0)
	 	{
			return rc;
	 	}
     }

     return rc;
}
示例#9
0
int
HandleNetoidPhones(Command *comm, int argc, char **argv)
{
    char fn[] = "HandleNetoidPhones():";
   	char *serNo, *ports, *temps,*ptrptr, *tok;
    unsigned long port = 0, portH = 0;
    NetoidSNKey key;
    NetoidInfoEntry *netInfo = NULL;
	CacheTableInfo cacheInfoEntry;
	VpnEntry vpnKey = { 0 }, *vpnEntry = NULL;
	int rc = xleOk, obtainedRegid = 0;
	long portsState = ~CL_REGISTERED;
     
    if (argc < 2)
    {
	 	/* Here we prompt the user for the rest of the 
	  	* information
	  	*/
	 	HandleCommandUsage(comm, argc, argv);
	 	return -xleInsuffArgs;
    }

     /* Registration No */
     serNo = argv[0];
     
	ports = temps = strdup(argv[1]);
   	tok = strtok_r(temps, "-", &ptrptr);
   	if (tok)
   	{
		port = atoi(tok);
		tok = strtok_r(NULL, "-", &ptrptr);
		if(tok){
	 	portH = atoi(tok);
	}
   		else{
	 	portH = port;
   	}
	}
	free(ports);

     argc -= 2;
     argv += 2;

	 strncpy(key.regid, serNo, REG_ID_LEN);

     while (port <= portH)
     {
	 	key.uport = port;
	 
		CacheAttach();

		if (!obtainedRegid)
		{
			CliGetRegid(serNo, key.regid);
			obtainedRegid = 1;
		}

		// Look up the entry in the cache
		if (CacheFind(regCache, &key, &cacheInfoEntry, sizeof(cacheInfoEntry)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}
		else if (ExtractIedge ((char *)&key, &cacheInfoEntry.data, 
										sizeof(cacheInfoEntry.data)) > 0)
		{
			netInfo = &cacheInfoEntry.data;
		}

		CacheDetach();

	 if (OpenDatabases((DefCommandData *)comm->data) < 0)
	 {
		return -xleOpNoPerm;
	 }

	 if (netInfo)
	 {
		strcpy(vpnKey.vpnName, netInfo->vpnName);
	 }

	 if (strlen(vpnKey.vpnName))
	 {
	 	vpnEntry = DbFindVpnEntry(GDBMF(comm->data, DB_eVpns),
						(char *)&vpnKey, sizeof(VpnKey));
	 }

	 CloseDatabases((DefCommandData *)comm->data);

     if (!netInfo)
     {
		/* vpn entry exists only if netInfo existed!! */
	 	return -xleNoEntry;
     }

	 if (argc -- > 0)
	 {
	    strcpy(netInfo->vpnPhone, argv[0]);

		if (strlen(netInfo->vpnPhone))
		{
	      		BIT_SET(netInfo->sflags, ISSET_VPNPHONE);
				netInfo->vpnExtLen = strlen(netInfo->vpnPhone);
		}
		else
		{
	      		BIT_RESET(netInfo->sflags, ISSET_VPNPHONE);
				netInfo->vpnExtLen = 0;
		}

		AssignIedgePhone(netInfo, vpnEntry);

	    argv ++;
	 }

	 netInfo->stateFlags &= ~CL_REGISTERED;
	 netInfo->mTime = time(0);

	 /* If this netoid is in the cache, delete it */
	 if (UpdateNetoidInCache(netInfo) < 0)
	 {
		rc = -xleExists;
		goto _error;
	 }

	 UpdateNetoidPorts(serNo, UpdateNetoidState, &portsState, NULL, NULL);

	 UpdateNetoidDatabase(netInfo);

	 netInfo = NULL;
	 if (vpnEntry)
	 {
		free(vpnEntry);
		vpnEntry = NULL;
	 }

	 port ++;
     }

     return xleOk;

_error:
	if (netInfo)
	{
		free(netInfo);
	}
		
	if (vpnEntry)
	{
		free(vpnEntry);
	}

	return rc;
}