Commit 0e301a43 authored by Laurent Rossier's avatar Laurent Rossier

Fix a bug when a port is in no vlan which could be possible.

  At the initialisation a warning is logged in this case.

Add a great :) color for the warning log.
parent 6fb369bf
......@@ -3,7 +3,7 @@
* Print a log to a file or to screen
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: logger.c,v 1.21 2001/09/25 16:16:54 gunther Exp $
* $Id: logger.c,v 1.22 2001/10/24 15:03:16 gunther Exp $
*
* Authors: Damien Lucas <nitrox@via.ecp.fr>
* Marc Ariberti <marcari@via.ecp.fr>
......@@ -357,6 +357,9 @@ static void VS_log_Screen(LOG_LEVELS level,
sprintf(HeaderBuff+strlen(HeaderBuff), "info ] ");
break;
case LOGWARNING:
#ifdef LINUX_COLOR
sprintf(HeaderBuff+strlen(HeaderBuff), "\033[40;32;1m");
#endif
sprintf(HeaderBuff+strlen(HeaderBuff), "Warning ] ");
break;
case LOGFATAL:
......
......@@ -3,7 +3,7 @@
* Function to order SNMP init of switches
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: poll_switch.c,v 1.17 2001/10/08 16:37:57 gunther Exp $
* $Id: poll_switch.c,v 1.18 2001/10/24 15:03:16 gunther Exp $
*
* Authors: Laurent Rosier <gunther@via.ecp.fr>
* Damien Lucas <nitrox@via.ecp.fr>
......@@ -77,11 +77,15 @@ ERR_CODE VS_switch_init(struct VS_switches * list_switch)
{
for(k=1;k<list_switch->zwitch[iter]->nb_ports;k++) /* ports loop */
{
if(list_switch->zwitch[iter]->ports[k].vlan_struct == NULL)
{
VS_log(LOGWARNING,SERVER,"The port %u of the switch %u is in no vlan",
k,iter);
}
for(vlanLoop = list_switch->zwitch[iter]->ports[k].vlan_struct;
vlanLoop != NULL;
vlanLoop = vlanLoop->next)
{
VS_log(LOGDEBUG,SERVER," switch %u port %u vlan %u",iter,k,vlanLoop->vlan);
for(l=1;l<MAX_VLAN_NB+1;l++) /* vlans loop */
{
if(vlanLoop->vlan == list_switch->zwitch[iter]->vlanid[l])
......@@ -114,6 +118,11 @@ ERR_CODE VS_switch_init(struct VS_switches * list_switch)
list_switch->zwitch[iter]->badinit=1;
break;
}
else
{
VS_log(LOGDEBUG,SERVER,"Switch %u port %u vlan %u type %i",iter,k,
vlanLoop->vlan,vlanLoop->vlanType);
}
}
}
if(!list_switch->zwitch[iter]->badinit)
......
......@@ -3,7 +3,7 @@
* Functions to handle a request from client
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: request_handler.c,v 1.28 2001/10/08 16:37:57 gunther Exp $
* $Id: request_handler.c,v 1.29 2001/10/24 15:03:16 gunther Exp $
*
* Authors: Laurent Rossier <gunther@via.ecp.fr>
*
......@@ -212,6 +212,7 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
}
}
vlanLoopEnd=NULL;
vlanLoopToChange=NULL;
vlanLoopToChange2=NULL;
for(vlanLoop=zwitch->ports[machines_elt->port].vlan_struct;
......@@ -239,13 +240,41 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
vlanLoopToChange=vlanLoop;
}
}
else if((vlanLoop->vlanType == NONE) && (info_client->vlanType == NONE))
else if((vlanLoop->vlanType == NONE) && (info_client->vlanType ==
NONE))
{
vlanLoopToChange2=vlanLoop;
}
}
if((vlanLoopToChange == NULL) && (vlanLoopToChange2 == NULL))
if(vlanLoopEnd == NULL)
{
vlanLoop=malloc(sizeof(struct VS_vlan));
if(vlanLoop == NULL)
{
VS_log(LOGERROR,SERVER,"Unable to allocate memory");
DB_switchs_port_unlock(vs->db, port);
DB_machines_unlock(vs->db, machines_elt);
/* No need to send a message to the client because it doesn't
* have to know that there is no more memory. By the way this
* possibility won't come a lot ! :) */
if(uType == 0)
{
close(iSocket);
}
free(info_client);
return VS_R_MEMORY;
}
vlanLoop->vlan=2; /* By default the vlan is 2
* We will set it to the right vlan after */
vlanLoop->vlanType=NONE; /* Same thing */
vlanLoop->next=NULL;
vlanLoop->prev=NULL;
}
else if((vlanLoopToChange == NULL) && (vlanLoopToChange2 == NULL))
{
vlanLoopEnd->next=malloc(sizeof(struct VS_vlan));
if(vlanLoopEnd->next == NULL)
......
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