added ListenAddress configuration option

ulab-original
ilsimo 18 years ago
parent 5d29a7127b
commit 6cbc09be53

@ -36,6 +36,11 @@ For any of the following parameter, if it's specified more than one time the las
The options to be specified in the \fB[globals]\fR section are the following:
.br
.TP
\fBListenAddress\fR=\fIip address\fR
Specifies sesman listening address. Default is 0.0.0.0 (all interfaces)
.br
.TP
\fBListenPort\fR=\fIport number\fR
Specifies sesman listening port. Default is 3350
@ -165,6 +170,8 @@ This is an example \fBsesman.ini\fR:
[Globals]
.br
ListenAddress=127.0.0.1
.br
ListenPort=3350
.br
EnableUserWindowManager=1

@ -22,7 +22,7 @@
* @file config.c
* @brief User authentication code
* @author Simone Fedele @< simo [at] esseemme [dot] org @>
*
*
*/
#include "arch.h"
@ -107,6 +107,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
list_clear(param_n);
/* resetting the struct */
cf->listen_address[0] = '\0';
cf->listen_port[0] = '\0';
cf->enable_user_wm = 0;
cf->user_wm[0] = '\0';
@ -132,9 +133,17 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
{
g_strncpy(cf->listen_port, (char*)list_get_item(param_v, i), 15);
}
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ADDRESS))
{
g_strncpy(cf->listen_address, (char*)list_get_item(param_v, i), 31);
}
}
/* checking for missing required parameters */
if ('\0' == cf->listen_address[0])
{
g_strncpy(cf->listen_address, "0.0.0.0", 8);
}
if ('\0' == cf->listen_port[0])
{
g_strncpy(cf->listen_port, "3350", 5);
@ -150,6 +159,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
/* showing read config */
g_printf("sesman config:\r\n");
g_printf("\tListenAddress: %s\r\n", cf->listen_address);
g_printf("\tListenPort: %s\r\n", cf->listen_port);
g_printf("\tEnableUserWindowManager: %i\r\n", cf->enable_user_wm);
g_printf("\tUserWindowManager: %s\r\n", cf->user_wm);
@ -302,7 +312,7 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
se->max_idle_time=0;
se->max_disc_time=0;
se->kill_disconnected=0;
file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v);
for (i = 0; i < param_n->count; i++)
{

@ -22,7 +22,7 @@
* @file config.h
* @brief User authentication definitions
* @author Simone Fedele @< simo [at] esseemme [dot] org @>
*
*
*/
#ifndef CONFIG_H
@ -44,6 +44,7 @@
#define SESMAN_CFG_GLOBALS "Globals"
#define SESMAN_CFG_DEFWM "DefaultWindowManager"
#define SESMAN_CFG_ADDRESS "ListenAddress"
#define SESMAN_CFG_PORT "ListenPort"
#define SESMAN_CFG_ENABLE_USERWM "EnableUserWindowManager"
#define SESMAN_CFG_USERWM "UserWindowManager"
@ -141,6 +142,11 @@ struct config_sessions
*/
struct config_sesman
{
/**
* @var listen_address
* @brief Listening address
*/
char listen_address[32];
/**
* @var listen_port
* @brief Listening port

@ -50,7 +50,7 @@ sesman_main_loop(void)
log_message(LOG_LEVEL_INFO, "listening...");
g_sck = g_tcp_socket();
g_tcp_set_non_blocking(g_sck);
error = g_tcp_bind(g_sck, g_cfg.listen_port);
error = tcp_bind(g_sck, g_cfg.listen_address, g_cfg.listen_port);
if (error == 0)
{
error = g_tcp_listen(g_sck);

@ -21,12 +21,18 @@
*
* @file tcp.c
* @brief Tcp stream funcions
* @author Jay Sorg
*
* @author Jay Sorg, Simone Fedele
*
*/
#include "sesman.h"
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
/*****************************************************************************/
int DEFAULT_CC
tcp_force_recv(int sck, char* data, int len)
@ -124,3 +130,16 @@ tcp_force_send(int sck, char* data, int len)
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
tcp_bind(int sck, char* addr, char* port)
{
struct sockaddr_in s;
memset(&s, 0, sizeof(struct sockaddr_in));
s.sin_family = AF_INET;
s.sin_port = htons(atoi(port));
s.sin_addr.s_addr = inet_addr(addr);
return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in));
}

@ -18,10 +18,10 @@
*/
/**
*
*
* @file tcp.h
* @brief Tcp stream functions declarations
* @author Jay Sorg
* @author Jay Sorg, Simone Fedele
*
*/
@ -35,7 +35,7 @@
* @param data Data buffer
* @param len Data buffer size
* @return 0 on success, 1 on error
*
*
*/
int DEFAULT_CC
tcp_force_recv(int sck, char* data, int len);
@ -47,9 +47,21 @@ tcp_force_recv(int sck, char* data, int len);
* @param data Data buffer
* @param len Data buffer size
* @return 0 on success, 1 on error
*
*
*/
int DEFAULT_CC
tcp_force_send(int sck, char* data, int len);
/**
*
* @brief Binds the listening socket
* @param sck Listening socket
* @param addr Listening address
* @param port Listening port
* @return 0 on success, -1 on error
*
*/
int DEFAULT_CC
tcp_bind(int sck, char* addr, char* port);
#endif

Loading…
Cancel
Save