Commit 8ead5d0d authored by Marc Ariberti's avatar Marc Ariberti

* As some people asked, I added back code relative to vlanbridge

* added an option in Makefile.options to (de)activate it
parent 95c726e4
......@@ -3,7 +3,6 @@
#==========================#
HEAD
* Removed stuff around the vlanbridge (not necessary anymore)
* Removed all occurences of bzero -> memset
* Solaris Port
* LinkDown Trap support
......
......@@ -69,6 +69,10 @@ ifeq ($(SYS),solaris)
LDLIBS += -lkstat # for the libsnmp ...
endif
ifeq ($(VLB),1)
CFLAGS += -DVLB
endif
ifeq ($(MEM_DBG),1)
CFLAGS += -DMEM_DBG
endif
......@@ -84,6 +88,7 @@ endif
SOURCES = \
server/server.c \
server/connect.c \
server/request_handler.c \
server/poll_switch.c\
server/reinit_switchs.c \
......
......@@ -191,6 +191,6 @@ Difficulty: Easy
Urgency: Wishlist
Description: SRV: Check VLANbridge answers
Check the vlanbridge answer's to connection and route requests
Status: Done, Marcari not useful anymore
Status: Todo
/*****************************************************************************
* common.h
* VideoLAN VLAN operations: definitions of all codes for messages exchange
* between VLANservers and VLANclient
* between VLANserver, VLANclient and VLANbridge
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: common.h,v 1.4 2001/10/24 17:59:18 marcari Exp $
* $Id: common.h,v 1.5 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Regis Duchesne <regis@via.ecp.fr>
* Arnaud Bienvenu <fred@@via.ecp.fr>
......@@ -55,6 +55,13 @@
/* logout (common for all too) */
#define VLAN_BYE 99 /* Logout msg */
/* VLANbridge <> VLANserver msg */
#define VLAN_ROUTE_REQUEST 11 /* <MAC> [IP] <VLAN Dest> [VLAN Src */
#define VLAN_ROUTE_OK 13 /* Route request succesfully completed */
#define VLAN_ROUTE_KO 14 /* Request failed to be processed */
#define VLAN_ROUTE_NOMOVE 18 /* Request not processed:\
client didn't move */
/* VLANserver <> client msg */
#define VLAN_MOVE_REQUEST 21 /* <MAC> [IP] <VLAN Dest> [VLAN Src] */
#define VLAN_MOVE_OK 22 /* Move request succesfully completed */
......
......@@ -3,7 +3,7 @@
* Some configurations defines
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: config.h,v 1.4 2001/10/24 17:59:18 marcari Exp $
* $Id: config.h,v 1.5 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Laurent Rossier <gunther@via.ecp.fr>
*
......@@ -28,9 +28,23 @@
/* Server version pas <3.1 */
#define VERSION "3.1"
/* Time between 2 atempts to contact the VLANbridge */
#define BRIDGE_SLEEPTIME 120
/* default VLANbridge port */
#define DEFAULT_ROUTER_PORT 2000
/* default server port */
#define DEFAULT_PORT 6010
/* number of retries when trying to reconnect to the VLANbridge when unable
* to close the connection */
#define VS_CNX_RETRIES 5
/* timeout before the server stops waiting for VLANbridge's answer when trying
* to log in */
#define VS_VLB_TIMEOUT 30
/* default config file location */
#define CFG_FILE_PATH "../vlanserver.conf"
......
......@@ -3,7 +3,7 @@
* Generate a parser for the config file
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: config.fl,v 1.22 2001/10/24 17:59:18 marcari Exp $
* $Id: config.fl,v 1.23 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
......@@ -169,6 +169,63 @@ nchannels{BL}{INT} {
}
vlanbridge{BL}{DNS} {
if (cfg->vlanbridge!=NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge address defition",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
CFG_yytext[ui1-1]!=' ' && CFG_yytext[ui1-1]!='\t';ui1--);
cfg->vlanbridge=strdup(CFG_yytext+ui1);
}
vlanbridge_login{BL}{NONBLANK}+ {
if (cfg->vlanbridge_login!=NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge login",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
CFG_yytext[ui1-1]!=' ' && CFG_yytext[ui1-1]!='\t';ui1--);
cfg->vlanbridge_login=malloc((CFG_yyleng-ui1+1)*sizeof(char));
if (cfg->vlanbridge_login==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store vlanbridge "\
"login");
return VS_R_MEMORY;
}
memcpy(cfg->vlanbridge_login,CFG_yytext+ui1,CFG_yyleng-ui1);
cfg->vlanbridge_login[CFG_yyleng-ui1]=0;
}
vlanbridge_password{BL}{NONBLANK}+ {
if (cfg->vlanbridge_password!=NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge password",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
CFG_yytext[ui1-1]!=' ' && CFG_yytext[ui1-1]!='\t';ui1--);
cfg->vlanbridge_password=malloc((CFG_yyleng-ui1+1)*sizeof(char));
if (cfg->vlanbridge_password==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store VLB "\
"password");
return VS_R_MEMORY;
}
memcpy(cfg->vlanbridge_password,CFG_yytext+ui1,CFG_yyleng-ui1);
cfg->vlanbridge_password[CFG_yyleng-ui1]=0;
}
channel{BL}{INT}{BL}vlan{BL}{INT}{BL}protection{BL}{INT}{BL} {
......@@ -1098,6 +1155,9 @@ ERR_CODE CFG_init(struct VS_config *cfg,int argc,char *argv[])
cfg->nchannels=0;
cfg->chan_map=NULL;
cfg->switch_types=NULL;
cfg->vlanbridge=NULL;
cfg->vlanbridge_login=NULL;
cfg->vlanbridge_password=NULL;
cfg->zwitches=NULL;
CFG_yyin=fopen(filepath,"r");
if (CFG_yyin!=NULL)
......
......@@ -3,7 +3,7 @@
* Header file for config.c (once generated)
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: config.h,v 1.8 2001/10/24 17:59:18 marcari Exp $
* $Id: config.h,v 1.9 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
......@@ -81,6 +81,9 @@ struct VS_config
channel i */
struct CFG_SWITCH_TYPE *switch_types; /* the list of switch types */
struct CFG_SWITCH *zwitches; /* the list of switches */
char * vlanbridge; /* the DNS address of the vlanbridge */
char *vlanbridge_login; /* the login on the vlanbridge */
char *vlanbridge_password; /* the password on the vlanbridge */
char *logfile; /* the file where we will log */
unsigned char logscreen; /* the log to screen if !=0 */
};
......
......@@ -13,3 +13,7 @@ MEM_DBG=0
# includes symbol tables and DEBUG message
# setting BDG to 1 will automatically remove optims
DBG=0
# vlanbridge
# set it to 1 if you want to you the vlanserver with the vlanbridge
VLB=0
/*****************************************************************************
* connect.c
* Functions to communicate with the vlanbridge
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: connect.c,v 1.14 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <arpa/inet.h> /* types.h */
#include <errno.h> /* EBUSY */
#include <sys/time.h> /* struct time_val */
#include <unistd.h> /* close, sleep */
#include <sys/socket.h> /* bind, socket */
#include <pthread.h> /* pthread_mutex_lock */
#include <stdio.h> /* sprintf */
#include "../types.h"
#include "../logger.h"
#include "../config.h" /* VERSION */
#include "../config/config.h" /* vs->cfg->vlanbridge ... */
#include "../vlanserver.h" /* vs */
#include "../common.h" /* for protocol */
#include "connect.h"
/****************************************************************************
* CNX_cnx_lost
****************************************************************************
* Tries to log on again on the VLANbridge when the connection has been lost
****************************************************************************/
static void CNX_cnx_lost()
{
unsigned int retry_delay;
unsigned int still_sleep;
retry_delay=12;
if(pthread_mutex_trylock(&(vs->cnx_lock))==EBUSY)
return;
if (vs->fdescr)
{
if (!close(vs->fdescr))
vs->fdescr=0;
else
VS_log(LOGERROR, SERVER, "Unable to close socket for communication "
"with the VLANbridge.");
}
while (vs->runlevel<VS_STOP)
{
VS_log(LOGINFO, SERVER, "Reconnection to the VLB trial failed or "
"connection lost, retrying in %u seconds.", retry_delay);
/* this sleeps retry_delay seconds */
for (still_sleep=retry_delay;still_sleep;still_sleep=sleep(still_sleep));
if (!CNX_vlb_login(VERSION))
{
VS_log(LOGINFO, SERVER, "Connection to VLB is up again.");
pthread_mutex_unlock(&(vs->cnx_lock));
return;
}
if (vs->fdescr)
{
if (!close(vs->fdescr))
vs->fdescr=0;
else
VS_log(LOGERROR, SERVER, "Unable to close socket for communication "
"with the VLANbridge.");
}
retry_delay*=2;
}
}
/****************************************************************************
* CNX_vlb_set_vlan
****************************************************************************
* Tells the VLANbridge that a machine has changed vlan
* Returns VS_R_SEND in case of problems
* (in which case CNX_cnx_lost will be called), 0 otherwise
****************************************************************************/
unsigned int CNX_vlb_set_vlan(unsigned int session_id,
char * MAC, char * IP, VS_VLAN VLANdest,
VS_VLAN VLANsrc)
{
unsigned char message[VLAN_MSG_LEN];
size_t j;
int i;
j=sprintf(message,"%u %u %s %s %u %u\n", VLAN_ROUTE_REQUEST, session_id, \
MAC, IP, (unsigned int)VLANdest, (unsigned int)VLANsrc);
i=send(vs->fdescr, message, j, 0);
if (i==j)
{
VS_log(LOGDEBUG, SERVER, "Request (%u) to change %s %s from VS_VLAN %u to"\
" %u successfuly sent to VLANbridge",session_id, IP, MAC,\
(unsigned int)VLANsrc, (unsigned int)VLANdest);
return 0;
}
else
{
if (i==-1)
{
VS_log(LOGERROR, SERVER, "Unable to send the request (%u) to change %s "\
"%s from VS_VLAN %u to %u to the VLANbridge", session_id, IP,\
MAC, (unsigned int)VLANsrc, (unsigned int)VLANdest);
}
else
{
VS_log(LOGERROR, SERVER, "Unable to send the whole request (%u) to "\
"change %s %s from VS_VLAN %u to %u to the VLANbridge",\
session_id, IP, MAC, (unsigned)VLANsrc, (unsigned)VLANdest);
}
CNX_cnx_lost(vs);
return VS_R_SEND;
}
}
/****************************************************************************
* CNX_vlb_login
****************************************************************************
* logs on on the VLANbridge
* returns 0 if everything's ok
****************************************************************************/
unsigned int CNX_vlb_login(char * version)
{
unsigned char message[VLAN_MSG_LEN];
unsigned int i;
unsigned int j;
int k;
fd_set set;
struct timeval tout={VS_VLB_TIMEOUT, 0};
vs->fdescr=0;
VS_log(LOGINFO, SERVER, "Trying to login on VLANbridge");
for (i=0;version[i];i++)
if (version[i]=='.')
break;
if (version[i]=='.')
j=sprintf(message, "%u %s %s %s\n", VLAN_LOGIN_REQUEST, version,\
vs->cfg->vlanbridge_login, vs->cfg->vlanbridge_password);
else
j=sprintf(message, "%u %s.0 %s %s\n", VLAN_LOGIN_REQUEST, version,\
vs->cfg->vlanbridge_login, vs->cfg->vlanbridge_password);
k=socket(AF_INET, SOCK_STREAM, 0);
if (k==-1)
{
VS_log(LOGERROR, SERVER, "Unable to open a stream socket to connect to "\
"VLB");
return VS_R_SOCKET;
}
vs->fdescr=k;
VS_log(LOGDEBUG, SERVER, "Stream socket opened. File descriptor is %u", k);
VS_log(LOGDEBUG, SERVER, "Trying to connect to VLANbridge");
if(connect(k, (struct sockaddr *)&vs->vlb_params,\
sizeof(struct sockaddr))==-1)
{
VS_log(LOGERROR, SERVER, "Unable to connect to VLANbridge");
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the VLB");
return VS_R_CONNECT;
}
VS_log(LOGINFO, SERVER, "Successfuly connected to VLANbridge");
VS_log(LOGDEBUG, SERVER, "Sending string to VLANbridge: %s", message);
i=send(k, message, j, 0);
if (((int)i)==-1)
{
VS_log(LOGERROR, SERVER, "Unable to send anything to the VLB");
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the VLB");
return VS_R_SEND;
}
if (i!=j)
{
VS_log(LOGERROR, SERVER, "Unable to send the whole string to the VLB");
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the VLB");
return VS_R_SEND;
}
VS_log(LOGDEBUG, SERVER, " %u bytes sent",j);
VS_log(LOGDEBUG, SERVER, "Waiting for VLANbridge answer");
FD_ZERO(&set);
FD_SET(k, &set);
i=select(1+k, &set, NULL, NULL, &tout);
if (((int)i)==-1)
{
VS_log(LOGERROR, SERVER, "Unable to select() VLANbridge's file "\
"descriptor");
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the VLB");
return VS_R_SELECT;
}
if (!i)
{
VS_log(LOGERROR, SERVER, "tout(%us): VLB answer not arrived",
VS_VLB_TIMEOUT);
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the"\
" VLANbridge");
return VS_R_TIMEOUT;
}
VS_log(LOGDEBUG, SERVER, "Answer has arrived, reading it");
i=recv(k, message, VLAN_MSG_LEN*sizeof(char), 0);
if (((int)i)==-1)
{
VS_log(LOGERROR, SERVER, "Unable to read the answer");
if (close(k))
VS_log(LOGERROR, SERVER, "Unable to close the socket for the"\
" VLANbridge");
return VS_R_RECV;
}
message[i]=0;
VS_log(LOGINFO, SERVER, "Answer from VLANbridge: %s", message);
return 0;
}
/*****************************************************************************
* connect.h
* Header file for conect.c
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: connect.h,v 1.6 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef __CONNECT_H__
#define __CONNECT_H__
/* Tells the vlanbridge a machine has changed channel. The VLANserver must have
* logged on and its fdescr field must be set */
unsigned int CNX_vlb_set_vlan(unsigned int session_id,\
char *MAC,char *IP,VS_CHANNEL CHANdest,\
VS_CHANNEL CHANsrc);
/* Logs on the VLANbridge. fdescr should point to the fdescr field of the
* VLANserver. Current vlb requires version>=3.1 */
unsigned int CNX_vlb_login(char *version);
#endif
......@@ -3,7 +3,7 @@
* Functions to handle a request from client
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: request_handler.c,v 1.30 2001/10/24 17:59:18 marcari Exp $
* $Id: request_handler.c,v 1.31 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Laurent Rossier <gunther@via.ecp.fr>
*
......@@ -47,6 +47,9 @@
#include "../db/db.h" /* DB_machines_lock */
#include "../config/config.h" /* vs->cfg */
#include "../vlanserver.h" /* vs */
#ifdef VLB
#include "connect.h" /* CNX_vlb_set_vlan */
#endif
#include "server.h" /* struct VS_info_client */
#include "request_handler.h" /* VS_send */
......@@ -56,7 +59,7 @@
* Scan the message from the client
* Send a message to the client
* Lock the machine and the port in the db
* Call the SNMP_set_vlan
* Call the SNMP_set_vlan and the CNX_vlb_set_vlan functions
* Unlock the machine and the port in the db
*****************************************************************************/
ERR_CODE VS_request_handler(struct VS_info_client * info_client)
......@@ -71,7 +74,7 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
unsigned int uType;
int iSocket;
struct sockaddr_in sa_client;
char macaddr[18];
char macaddr_vlb[18];
char* sMessage;
struct DB_machines_elt * machines_elt;
struct SNMP_switch * zwitch;
......@@ -82,7 +85,7 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
struct VS_vlan* vlanLoopEnd;
macaddr_db=0;
macaddr[17] = 0;
macaddr_vlb[17] = 0;
sMessage=malloc(256*sizeof(char));
if(sMessage==NULL)
......@@ -96,16 +99,16 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
*/
VS_log(LOGDEBUG,SERVER,"%s", info_client->mess);
if(sscanf(info_client->mess, "%u %u %u %s", (unsigned *)&channel_dest,\
&version_cl, &date_cl, macaddr)!=4)
&version_cl, &date_cl, macaddr_vlb)!=4)
{
VS_log(LOGERROR,SERVER,"Wrong packet received");
return VS_R_PARSE;
}
VS_log(LOGINFO,SERVER,"IP %s mac %s chandest %hhu version %u sessid %u date"\
"cl %u", info_client->ipaddr, macaddr,\
"cl %u", info_client->ipaddr, macaddr_vlb,\
channel_dest, version_cl, info_client->session_id, date_cl);
if(sscanf(macaddr, "%2x:%2x:%2x:%2x:%2x:%2x", (unsigned *)&macaddr_db,\
if(sscanf(macaddr_vlb, "%2x:%2x:%2x:%2x:%2x:%2x", (unsigned *)&macaddr_db,\
&i1, &i2, &i3, &i4, &i5)!=6)
{
VS_log(LOGERROR,SERVER,"Wrong packet received");
......@@ -376,9 +379,18 @@ ERR_CODE VS_request_handler(struct VS_info_client * info_client)
/* Asking the SNMP to change VLAN */
rc=SNMP_set_vlan(vs->snmp, zwitch, machines_elt->port, vlan_dest,
info_client->vlanType);
if(!rc)
if(!rc)
{
vlanLoop->vlan=(unsigned short int)vlan_dest;
#ifdef VLB
/* Asking the VLB to bridge */
/* TODO We have here to bridge all macs known on the port */
if(info_client->vlanType == NONE)
{
CNX_vlb_set_vlan(3, macaddr_vlb, info_client->ipaddr,\
vlan_dest, vlanLoop->vlan);
}
#endif
vlanLoop->vlan=(unsigned short int)vlan_dest;
vlanLoop->vlanType=info_client->vlanType;
VS_log(LOGDEBUG,SERVER,"The port %u is in:", machines_elt->port);
......
......@@ -3,7 +3,7 @@
* Main part of the server
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: server.c,v 1.47 2001/10/24 17:59:18 marcari Exp $
* $Id: server.c,v 1.48 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Laurent Rossier <gunther@via.ecp.fr>
*
......@@ -50,6 +50,9 @@
#include "../db/db.h" /* DB_switch_insert */
#include "../config/config.h" /* vs-> cfg */
#include "../vlanserver.h" /* vs */
#ifdef VLB
#include "connect.h" /* CNX_vlb_login */
#endif
#include "server.h" /* VS_stop */
#include "poll_switch.h" /* VS_switch_init */
#include "request_handler.h" /* VS_request_handler_thread */
......@@ -73,6 +76,10 @@ ERR_CODE VS_start()
vs->runlevel=VS_INIT;
#ifdef VLB
pthread_mutex_init(&vs->cnx_lock, NULL);
#endif
session_id=malloc(sizeof(unsigned int));
if(session_id==NULL)
{
......@@ -113,7 +120,8 @@ ERR_CODE VS_start()
iSocket=VS_connect(server_client);
if(iSocket == -1)
{
VS_log(LOGERROR,SERVER,"Unable to connect to the bind the socket");
VS_log(LOGERROR,SERVER,"Unable to connect to the vlb or to the bind the "\
"socket");
VS_stop(info_poller);
return VS_R_CONNECT;
}
......@@ -239,18 +247,36 @@ ERR_CODE VS_db_init(struct VS_info_poller * info_poller)
* VS_connect
*****************************************************************************
* Collect information about the server for the client
* Log the server to the vlanbridge
* Initialize and bind the socket for the client
*****************************************************************************/
ERR_CODE VS_connect(struct sockaddr_in server_client)
{
unsigned int rc;
int iSocket;
struct hostent * h;
memset(&server_client, 0, sizeof(struct sockaddr_in));
server_client.sin_family=AF_INET;
server_client.sin_port=htons(DEFAULT_PORT);
server_client.sin_addr.s_addr=INADDR_ANY;
#ifdef VLB
if((h=gethostbyname(vs->cfg->vlanbridge))==NULL)
{
herror("VLANbridge address ");
return VS_R_DNS;
}
VS_log(LOGINFO, SERVER, "VLANbrdige IP : %s",
inet_ntoa(*((struct in_addr *)h->h_addr)));
vs->vlb_params.sin_addr=*((struct in_addr *)h->h_addr);
vs->vlb_params.sin_family=AF_INET;
vs->vlb_params.sin_port=htons(DEFAULT_ROUTER_PORT);
memset(&(vs->vlb_params.sin_zero), '\0', 8);
rc=CNX_vlb_login(VERSION);
VS_log(LOGINFO,SERVER,"vlb login %x", rc);
#endif
iSocket=socket(AF_INET, SOCK_DGRAM, 0);
if(iSocket==-1)
{
......@@ -389,6 +415,7 @@ ERR_CODE VS_stop(struct VS_info_poller * info_poller)
info_poller->runlevel=VS_POLL_STOP;
/* WRNING we do not verify cnx_lost has been initialized because currently,
* we are sure it has been */
pthread_mutex_destroy(&(vs->cnx_lock));
close(info_poller->iSocket);
if(info_poller!=NULL)
{
......
......@@ -3,7 +3,7 @@
* Init of the VLANserver
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: types.c,v 1.25 2001/10/24 17:59:18 marcari Exp $
* $Id: types.c,v 1.26 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
......@@ -54,6 +54,10 @@ unsigned int VS_init(int argc,char *argv[])
signal(SIGINT, VS_finish); /* arrange interrupts to terminate */
#ifdef VLB
grumpf=pthread_mutex_init(&(vs->cnx_lock),NULL);
#endif
/* Initializing the log process */
/* with screen only because we don't know yet the logfile */
LOG_init();
......
......@@ -3,7 +3,7 @@
* Provide the struct VLANserver
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: vlanserver.h,v 1.8 2001/10/24 17:59:18 marcari Exp $
* $Id: vlanserver.h,v 1.9 2001/10/24 20:35:16 marcari Exp $
*
* Authors: Brieuc Jeunhomme <bbp@via.ecp.fr>
*
......@@ -28,10 +28,13 @@
/* VLANserver : global VLANserver variables and their initialization function */
struct VLANserver
{
pthread_mutex_t cnx_lock; /* the mutex used by VS_cnx_lost when the
connexion with the VLANbridge breaks */
struct DB_db *db; /* the database */
struct VS_config *cfg; /* the configuration */
struct SNMP_snmp *snmp; /* the snmp engine */
struct VS_info_poller * info_poller; /* for the server */
struct sockaddr_in vlb_params; /* IP and port for the vlanbridge */
int fdescr; /* the socket descriptor to communicate with the VLANbridge */
enum
{
......
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