Commit a29a2e15 authored by Benoit Steiner's avatar Benoit Steiner

Pas grand chose, si ce n'est de la typo (wrapping a 80 colonnes,

messages d'erreurs plus clairs) et la mise a jour du fichier Notes.

Benny
parent e15af4d4
......@@ -21,7 +21,7 @@ CFLAGS += -g
# Compiler parameters style
CFLAGS += -Wall
#CFLAGS += -O6
#CFLAGS += -static
CFLAGS += -static
# To generate the dependencies
DFLAGS += -MM
......@@ -74,7 +74,7 @@ DEP := $(OBJ:%.o=dep/%.d)
all: VLANbridge
VLANbridge: $(OBJ)
$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS) $(CFLAGS)
$(CC) -o $@ $(OBJ) $(LDFLAGS) $(CFLAGS) $(LIB)
chmod 755 $@
$(DEP): dep/%.d: %.c
......
#Fichier de configuration pour le bridge
#La section Bridge ne sert a rien pour le moment
#Fichier de configuration pour le VLANbridge
BEGIN Globals # Config generale du bridge
......
......@@ -45,10 +45,10 @@ struct s_Command ascCommand[] =
"[cmd]",
"[string] " },
{
"essai", "", Essai,
"Essai a 2 balles du parseur",
"<toto> [tutu] [-opt {ta mere}]",
"<string> [int] [-opt {ip}] " },
"status", "", ServerStatus,
"Display the system status",
"",
" " },
{
"logout", "", Logout,
"Exit the current session",
......@@ -59,8 +59,6 @@ struct s_Command ascCommand[] =
};
/***************************************************************************/
/* Convert the value of an arg stored as a string into the given type */
/* We assume the initial string is pointed out by the uVal.strValue member */
......
......@@ -14,9 +14,13 @@ parce que la base est pas lockee */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <sys/sysinfo.h>
#include "debug.h"
#include "vlanbridge.h"
#include "network.h"
#include "admin.h"
......@@ -39,8 +43,6 @@ int Help(int iSockFd, int iArgCount, struct s_Argument* asaArg)
{
int iIndex = 0;
// printf("In help function: %d\n", iArgCount);
if (iArgCount == 0)
{
/* Display a list of available command */
......@@ -73,11 +75,50 @@ int Help(int iSockFd, int iArgCount, struct s_Argument* asaArg)
}
SendResult(iSockFd, "\n\r");
return 0;
}
/***************************************************************************/
/* */
/***************************************************************************/
int ServerStatus(int iSockFd, int iArgCount, struct s_Argument* asaArg)
{
int iRc = 0;
struct sysinfo siStatus;
int iDaysUptime, iHoursUptime, iMinUptime;
iRc = sysinfo(&siStatus);
if(!iRc)
{
/* Convert the date given in seconds to days/hours/minutes */
iDaysUptime = siStatus.uptime/86400;
siStatus.uptime -= iDaysUptime*86400;
iHoursUptime = siStatus.uptime/3600;
siStatus.uptime -= iHoursUptime*3600;
iMinUptime = siStatus.uptime/60;
/* Extract interessting info from the siStatus struct */
SendResult(iSockFd,
"VLANbridge version " VERSION " (built " __DATE__ ")\n\r"
" Uptime: %u days, %u hours, %u min\n\r"
" Free mem: %lu - Load: %lu\n\r",
iDaysUptime, iHoursUptime, iMinUptime,
siStatus.freeram, siStatus.loads[0]);
}
else
{
/* Return the error description */
SendResult(iSockFd, "Could not get system stats: %s", strerror(errno));
}
SendResult(iSockFd, "\n\r");
return iRc;
}
/***************************************************************************/
/* */
/***************************************************************************/
......
......@@ -8,9 +8,4 @@
int Help(int iSockFd, int i, struct s_Argument* asaArg);
int Logout(int iSockFd, int i, struct s_Argument* asaArg);
int Essai(int iSockFd, int i, struct s_Argument* asaArg)
{
printf("In essai\n");
return 0;
};
int ServerStatus(int iSockFd, int iArgCount, struct s_Argument* asaArg);
......@@ -3,9 +3,10 @@
* Benoit Steiner, ECP, <benny@via.ecp.fr>
*
* TO DO: Check whether incoming conections come from VLANserver
Refaire la sequence de login (trop mauvaise, password pas checkes, etc...)
Repousser l'identification, parce que si quelqu'un se loggue et ne fait rien,
il bloque tout jusuqu'au timeout
Refaire la sequence de login (trop mauvaise, password pas checkes,
etc...)
Repousser l'identification, parce que si quelqu'un se loggue et ne
fait rien, il bloque tout jusuqu'au timeout
*/
#include <sys/types.h>
......@@ -214,7 +215,7 @@ int OpenWaitingSocket (const char* strWaitPort)
}
}
/* allow to re-bind() a busy port */
/* Allow to re-use the port */
if (!iRc)
{
if (setsockopt(iWaitSockFd, SOL_SOCKET, SO_REUSEADDR, &iWaitSockOpt, sizeof(iWaitSockOpt)) < 0)
......
......@@ -86,7 +86,7 @@ int FifoPush(struct s_Fifo* psfFifo, struct s_Request* psrToStore)
{
// printf ("fifo Size: %d\n", psfFifo->iSize);
if (!iRc && psfFifo->iSize <= FIFO_SIZE)
if (psfFifo->iSize < FIFO_SIZE)
{
/* Add the element: no lock is needed, for readed data are not the ones we write */
*(psfFifo->psrWhereToPush) = psrToStore;
......
......@@ -30,7 +30,7 @@ void InitDescriptor(struct sockaddr_in* psaDescriptor)
ASSERT(psaDescriptor);
/* fill it with zero */
bzero(psaDescriptor, sizeof(*psaDescriptor));
memset(psaDescriptor, 0, sizeof(*psaDescriptor));
/* set the protocol family */
psaDescriptor->sin_family = AF_INET;
......@@ -80,7 +80,7 @@ int SetHost(struct sockaddr_in* psaDescriptor, const char* strHost)
if ((inaddr = inet_addr(strHost)) != -1)
{
/* it's dotted-decimal */
bcopy(&inaddr, &psaDescriptor->sin_addr, sizeof(inaddr));
memcpy(&psaDescriptor->sin_addr, &inaddr, sizeof(inaddr));
}
else
{
......@@ -92,7 +92,7 @@ int SetHost(struct sockaddr_in* psaDescriptor, const char* strHost)
return -1;
}
else
bcopy(hp->h_addr, &psaDescriptor->sin_addr, hp->h_length);
memcpy(&psaDescriptor->sin_addr, hp->h_addr, hp->h_length);
}
return 0;
}
......
......@@ -679,11 +679,12 @@ void* PerformerThread (void* pvArg)
/***************************************************************************/
int RunPerformer (struct s_Request* psrPerfId)
{
/* Create the thread */
int iRc = pthread_create (&psrPerfId->ptId, NULL, PerformerThread, psrPerfId);
int iRc;
ASSERT(psrPerfId);
/* Create the thread */
iRc = pthread_create (&psrPerfId->ptId, NULL, PerformerThread, psrPerfId);
if (iRc)
Log (LOG_ERROR, MOD_NAME, "Unable to create performer thread: error %s",
strerror(iRc));
......
......@@ -20,9 +20,9 @@
#define DEFAULT_CFG "VLANbridge.cfg"
/* Software version */
#define VERSION "1.0"
#define VERSION "1.1"
/* */
int StopBridge(int iRc);
#endif
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