Update of /cvsroot/linux-decnet/latd
In directory sc8-pr-cvs1:/tmp/cvs-serv24550
Modified Files:
latcp.cc latcp.h localport.cc server.cc server.h services.cc
services.h utils.h
Log Message:
(finally) add Dmitri Popov's code to better cope with servers that do not
send service broadcasts.
Index: latcp.cc
===================================================================
RCS file: /cvsroot/linux-decnet/latd/latcp.cc,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** latcp.cc 26 May 2003 11:19:57 -0000 1.40
--- latcp.cc 4 Jan 2004 15:49:04 -0000 1.41
***************
*** 1,4 ****
/******************************************************************************
! (c) 2000-2003 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,5 ----
/******************************************************************************
! (c) 2000-2004 Patrick Caulfield pa...@de...
! (c) 2003 Dmitri Popov
This program is free software; you can redistribute it and/or modify
***************
*** 212,219 ****
signed char opt;
bool show_services = false;
if (!open_socket(false)) return;
! while ((opt=getopt(argc,argv,"lv")) != EOF)
{
switch(opt)
--- 213,221 ----
signed char opt;
bool show_services = false;
+ bool show_nodes = false;
if (!open_socket(false)) return;
! while ((opt=getopt(argc,argv,"lvd")) != EOF)
{
switch(opt)
***************
*** 227,230 ****
--- 229,236 ----
break;
+ case 'd':
+ show_nodes = true;
+ break;
+
default:
fprintf(stderr, "only -v or -l valid with -d flag\n");
***************
*** 233,236 ****
--- 239,256 ----
}
+ if (show_nodes)
+ {
+ send_msg(latcp_socket, LATCP_SHOWNODES, verboseflag, 1);
+ unsigned char *result;
+ int len;
+ int cmd;
+ if (!read_reply(latcp_socket, cmd, result, len))
+ {
+ cout << result;
+
+ delete[] result;
+ }
+ return;
+ }
if (show_services)
***************
*** 246,254 ****
int len;
int cmd;
- read_reply(latcp_socket, cmd, result, len);
! cout << result;
! delete[] result;
}
--- 266,276 ----
int len;
int cmd;
! if (!read_reply(latcp_socket, cmd, result, len))
! {
! cout << result;
! delete[] result;
! }
}
***************
*** 951,956 ****
// Send our version
send_msg(latcp_socket, LATCP_VERSION, VERSION, strlen(VERSION)+1);
! read_reply(latcp_socket, cmd, result, len); // Read version number back
! delete[] result;
return true;
--- 973,979 ----
// Send our version
send_msg(latcp_socket, LATCP_VERSION, VERSION, strlen(VERSION)+1);
!
! if (!read_reply(latcp_socket, cmd, result, len)) // Read version number back
! delete[] result;
return true;
Index: latcp.h
===================================================================
RCS file: /cvsroot/linux-decnet/latd/latcp.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** latcp.h 10 Feb 2001 12:22:49 -0000 1.7
--- latcp.h 4 Jan 2004 15:49:04 -0000 1.8
***************
*** 1,4 ****
/******************************************************************************
! (c) 2000 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,4 ----
/******************************************************************************
! (c) 2000-2004 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
***************
*** 40,43 ****
--- 40,44 ----
const int LATCP_UNSETUSERGROUPS = 25;
const int LATCP_TERMINALSESSION = 26;
+ const int LATCP_SHOWNODES = 27;
const int LATCP_ERRORMSG = 99; // Fatal
Index: localport.cc
===================================================================
RCS file: /cvsroot/linux-decnet/latd/localport.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** localport.cc 28 May 2003 15:56:08 -0000 1.11
--- localport.cc 4 Jan 2004 15:49:04 -0000 1.12
***************
*** 1,4 ****
/******************************************************************************
! (c) 2001 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,4 ----
/******************************************************************************
! (c) 2001-2004 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
***************
*** 84,89 ****
// send a request for the service if we are queued so that
// by the time the user comes to use this port, we know about it.
if (service == "")
! LATServer::Instance()->send_enq((unsigned char *)remnode.c_str());
// Set terminal characteristics
--- 84,96 ----
// send a request for the service if we are queued so that
// by the time the user comes to use this port, we know about it.
+ if (service == "")
+ {
+ debuglog(("Dummy service NODE: %s\n", remnode.c_str()));
+ LATServer::Instance()->add_slave_node(remnode.c_str());
+ // PJC ??? wot's this ?? LATServer::Instance()->send_enq(remnode.c_str());
+ }
+
if (service == "")
! LATServer::Instance()->send_enq(remnode.c_str());
// Set terminal characteristics
Index: server.cc
===================================================================
RCS file: /cvsroot/linux-decnet/latd/server.cc,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -r1.74 -r1.75
*** server.cc 28 May 2003 15:56:08 -0000 1.74
--- server.cc 4 Jan 2004 15:49:04 -0000 1.75
***************
*** 1,4 ****
/******************************************************************************
! (c) 2001-2003 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,5 ----
/******************************************************************************
! (c) 2001-2004 Patrick Caulfield pa...@de...
! (c) 2003 Dmitri Popov
This program is free software; you can redistribute it and/or modify
***************
*** 118,124 ****
return local_name;
}
void LATServer::alarm_signal(int sig)
{
! Instance()->send_service_announcement(sig);
}
--- 119,130 ----
return local_name;
}
+
void LATServer::alarm_signal(int sig)
{
! if (Instance()->alarm_mode == 0)
! {
! Instance()->send_service_announcement(sig);
! }
! Instance()->send_solicit_messages(sig);
}
***************
*** 127,131 ****
// Send ENQUIRY for a node - mainly needed for DS90L servers that
// don't advertise.
! void LATServer::send_enq(unsigned char *node)
{
unsigned char packet[1600];
--- 133,137 ----
// Send ENQUIRY for a node - mainly needed for DS90L servers that
// don't advertise.
! void LATServer::send_enq(const char *node)
{
unsigned char packet[1600];
***************
*** 144,148 ****
enqmsg->retrans_timer = 75; // * 10ms - give it more time to respond
! add_string(packet, &ptr, node);
packet[ptr++] = 1; /* Length of group data */
packet[ptr++] = 1; /* Group mask */
--- 150,154 ----
enqmsg->retrans_timer = 75; // * 10ms - give it more time to respond
! add_string(packet, &ptr, (const unsigned char *)node);
packet[ptr++] = 1; /* Length of group data */
packet[ptr++] = 1; /* Group mask */
***************
*** 157,164 ****
--- 163,173 ----
static unsigned char addr[6] = { 0x09, 0x00, 0x2b, 0x00, 0x00, 0x0f };
+ debuglog(("send_enq : node: %s, local_name: %s\n", node, local_name));
+
for (int i=0; i<num_interfaces;i++)
{
if (iface->send_packet(interface_num[i], addr, packet, ptr) < 0)
{
+ debuglog(("Error send packet\n"));
interface_error(interface_num[i], errno);
}
***************
*** 168,171 ****
--- 177,197 ----
}
}
+
+ LATServices::Instance()->touch_dummy_node_respond_counter(node);
+ }
+
+ void LATServer::add_slave_node(const char *node_name)
+ {
+ sig_blk_t _block(SIGALRM);
+ for (std::list<std::string>::iterator iter = slave_nodes.begin();
+ iter != slave_nodes.end();
+ iter++)
+ {
+ if (*iter == node_name) {
+ // do not duplicate nodes
+ return;
+ }
+ }
+ slave_nodes.push_front(node_name);
}
***************
*** 308,311 ****
--- 334,395 ----
}
+ // Send solicit messages to slave nodes
+ void LATServer::send_solicit_messages(int sig)
+ {
+ static int counter = 0;
+ static int last_list_size = 0;
+ if (alarm_mode == 0)
+ {
+ counter = 0;
+ alarm_mode = 1;
+ debuglog(("set alarm_mode to 1\n"));
+
+ if (!known_slave_nodes.empty())
+ {
+ std::string known_node = known_slave_nodes.front();
+ known_slave_nodes.pop_front();
+ slave_nodes.push_back(known_node);
+ debuglog(("known(%d) => slave(%d) : %s\n", known_slave_nodes.size(),
+ slave_nodes.size(), known_node.c_str()));
+ if (slave_nodes.size() == 1)
+ {
+ alarm_mode = 0;
+ debuglog(("set alarm_mode to 0 - one slave\n"));
+ send_enq(slave_nodes.front().c_str());
+ // alarm() is already charged by send_service_announcement()
+ return;
+ }
+ }
+ }
+ else
+ {
+ if (slave_nodes.size() < last_list_size)
+ {
+ counter -= last_list_size - slave_nodes.size();
+ }
+ }
+
+ if (slave_nodes.size() > counter && !slave_nodes.empty())
+ {
+ std::string node_name = slave_nodes.front();
+ slave_nodes.pop_front();
+ slave_nodes.push_back(node_name);
+
+ send_enq(node_name.c_str());
+
+ alarm(1);
+ counter++;
+ last_list_size = slave_nodes.size();
+ }
+ else
+ {
+ alarm_mode = 0;
+
+ //well, it's not quite correct, I know...
+ alarm(counter >= multicast_timer ? 1 : multicast_timer - counter);
+ debuglog(("set alarm_mode to 0, timer %d\n", counter >= multicast_timer ? 1 : multicast_timer - counter));
+ }
+ }
+
// Log an error against an interface. If we get three of these
// then we remove it.
***************
*** 1061,1079 ****
void LATServer::got_enqreply(unsigned char *buf, int len, int interface, unsigned char *macaddr)
{
! int ptr = 23;
! // Don't know the format of this packet before this...
! ptr += buf[ptr++]; /* Skip group codes; */
! unsigned char nodename[32];
! get_string(buf, &ptr, nodename);
// Add it to the dummy service.
! LATServices::Instance()->add_service(std::string((char*)nodename),
! std::string((char*)""), // Dummy service name
! std::string((char*)"Dummy Service for DS90L servers"),
0,
! interface, macaddr);
}
--- 1145,1213 ----
void LATServer::got_enqreply(unsigned char *buf, int len, int interface, unsigned char *macaddr)
{
! int off = 14;
! unsigned char node_addr[6];
! char node_description[256];
! char node_name[256];
! memset(node_addr, 0x00, sizeof(node_addr));
! if (0 == memcmp(node_addr, buf + off, sizeof(node_addr)))
! {
! return;
! }
!
! memset(node_addr, 0xFF, sizeof(node_addr));
! if (0 == memcmp(node_addr, buf + off, sizeof(node_addr)))
! {
! return;
! }
! // Node MAC address
! memcpy(node_addr, buf + off, sizeof(node_addr));
! // Skip destination node name
! off = 22;
! off += buf[off] + 1;
!
! // Skip node groups
! off += buf[off] + 1;
!
! get_string(buf, &off, (unsigned char*)node_name);
! get_string(buf, &off, (unsigned char*)node_description);
!
! #if defined(debuglog)
! if (memcmp(node_addr, macaddr, sizeof(node_addr))) {
! debuglog(("got_enqreply : macaddr is different : %02hhX-%02hhX-%02hhX-%02hhX-%02hhX-%02hhX\n",
! macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]));
! }
! #endif
// Add it to the dummy service.
! debuglog(("got_enqreply : node: '%s' : %02hhX-%02hhX-%02hhX-%02hhX-%02hhX-%02hhX\n",
! node_name,
! node_addr[0], node_addr[1], node_addr[2], node_addr[3], node_addr[4], node_addr[5]));
! LATServices::Instance()->add_service(std::string(node_name),
! std::string(""), // Dummy service name
! std::string(node_description),
0,
! interface, node_addr);
!
! {
! sig_blk_t _block(SIGALRM);
! std::list<std::string>::iterator sl_iter;
! sl_iter = find(slave_nodes.begin(), slave_nodes.end(), node_name);
! if (sl_iter != slave_nodes.end()) {
! debuglog(("got_enqreply : to remove from slave(%d), node: '%s'\n",
! slave_nodes.size(), sl_iter->c_str()));
! slave_nodes.erase(sl_iter);
! }
!
! sl_iter = find(known_slave_nodes.begin(), known_slave_nodes.end(), node_name);
! if (sl_iter == known_slave_nodes.end()) {
! known_slave_nodes.push_back(node_name);
! debuglog(("got_enqreply : added to known(%d), node: '%s'\n",
! known_slave_nodes.size(),
! node_name));
! }
! }
}
***************
*** 1142,1146 ****
int ptr = sizeof(LAT_ServiceAnnounce);
unsigned char service_groups[32];
! unsigned char nodename[32];
unsigned char greeting[255];
unsigned char service[255];
--- 1276,1280 ----
int ptr = sizeof(LAT_ServiceAnnounce);
unsigned char service_groups[32];
! unsigned char nodename[256];
unsigned char greeting[255];
unsigned char service[255];
***************
*** 1303,1306 ****
--- 1437,1444 ----
connections[dsl.get_conn()]->remove_session(dsl.get_id());
break;
+
+ default:
+ debuglog(("Unknown LAT message: %d, 0x%X\n", header->cmd, header->cmd));
+ break;
}
}
***************
*** 1536,1539 ****
--- 1674,1678 ----
void LATServer::unlock()
{
+ sig_blk_t _block(SIGALRM);
locked = false;
alarm_signal(SIGALRM);
***************
*** 1555,1558 ****
--- 1694,1698 ----
if (node[0] == '\0')
{
+ debuglog(("make_connection : no node, use highest\n"));
if (!LATServices::Instance()->get_highest(std::string((char*)service),
servicenode, macaddr,
***************
*** 1566,1569 ****
--- 1706,1710 ----
else
{
+ debuglog(("make_connection : node : %s\n", node));
// Try to find the node
if (!LATServices::Instance()->get_node(std::string((char*)service),
***************
*** 1633,1636 ****
--- 1774,1779 ----
int ret;
int connid;
+ debuglog(("LATServer::make_port_connection : fd %d, lport '0x%X', service '%s', rnode '%s', port '%s', localport '%s', pwd '%s'\n",
+ fd, lport, service, rnode, port, localport, password));
connid = make_connection(fd, service, rnode, port, localport, password, queued);
***************
*** 1748,1751 ****
--- 1891,1899 ----
return true;
+ }
+
+ bool LATServer::show_nodes(bool verbose, std::ostrstream &output)
+ {
+ return LATServices::Instance()->list_dummy_nodes(verbose, output);
}
Index: server.h
===================================================================
RCS file: /cvsroot/linux-decnet/latd/server.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** server.h 27 May 2003 15:48:15 -0000 1.43
--- server.h 4 Jan 2004 15:49:04 -0000 1.44
***************
*** 54,58 ****
const unsigned char *get_user_groups() { return user_groups; }
int find_connection_by_node(const char *node);
! void send_enq(unsigned char *);
static unsigned char greeting[255];
--- 54,59 ----
const unsigned char *get_user_groups() { return user_groups; }
int find_connection_by_node(const char *node);
! void send_enq(const char *);
! void add_slave_node(const char *);
static unsigned char greeting[255];
***************
*** 67,70 ****
--- 68,72 ----
static_rating(false),
rating(12),
+ alarm_mode(0),
num_interfaces(0),
multicast_incarnation(0),
***************
*** 85,88 ****
--- 87,92 ----
int rating;
+ int alarm_mode; // For slave solicit .. PJC investigate
+
unsigned char local_name[256]; // Node name
int interface_num[MAX_INTERFACES];
***************
*** 106,109 ****
--- 110,114 ----
void forward_status_messages(unsigned char *inbuf, int len);
void send_service_announcement(int sig);
+ void send_solicit_messages(int sig);
int make_new_connection(unsigned char *buf, int len, int interface,
LAT_Header *header, unsigned char *macaddr);
***************
*** 261,264 ****
--- 266,273 ----
std::list<LocalPort> portlist;
+ // Slave Nodes or Dummy Nodes. Well, no-self-advertised nodes
+ std::list<std::string> slave_nodes;
+ std::list<std::string> known_slave_nodes;
+
// Connections indexed by ID
LATConnection *connections[MAX_CONNECTIONS];
***************
*** 292,295 ****
--- 301,305 ----
void unlock();
bool show_characteristics(bool verbose, std::ostrstream &output);
+ bool show_nodes(bool verbose, std::ostrstream &output);
int create_local_port(unsigned char *, unsigned char *,
unsigned char *, unsigned char *, bool, bool,
Index: services.cc
===================================================================
RCS file: /cvsroot/linux-decnet/latd/services.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** services.cc 19 Dec 2003 20:23:09 -0000 1.15
--- services.cc 4 Jan 2004 15:49:04 -0000 1.16
***************
*** 1,4 ****
/******************************************************************************
! (c) 2000-2003 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,5 ----
/******************************************************************************
! (c) 2000-2004 Patrick Caulfield pa...@de...
! (c) 2003 Dmitri Popov
This program is free software; you can redistribute it and/or modify
***************
*** 99,106 ****
--- 100,122 ----
{
std::map<std::string, serviceinfo, std::less<std::string> >::iterator test = servicelist.find(service);
+ std::map<std::string, serviceinfo, std::less<std::string> >::iterator c =
+ servicelist.begin();
+ int i =0;
+ for(;c != servicelist.end();c++) {
+ i++;
+ debuglog(("LATServices::get_node : service %2d '%s' \n",
+ i, c->first.c_str()));
+ }
+
if (test != servicelist.end())
{
+ // std::map<std::string, serviceinfo, std::less<std::string> >::iterator c = test;
+ // int i =0;
+ // for(;c != servicelist.end();c++) { i++; };
+ debuglog(("LATServices::get_node : service found '%s', number: %d \n", service.c_str(), i));
return servicelist[test->first].get_node(node, macaddr, interface);
}
+ debuglog(("LATServices::get_node : no service '%s' \n", service.c_str()));
+
return false; // Not found
}
***************
*** 111,114 ****
--- 127,144 ----
{
std::map<std::string, nodeinfo, std::less<std::string> >::iterator test = nodes.find(node);
+
+ std::map<std::string, nodeinfo, std::less<std::string> >::iterator c =
+ nodes.begin();
+ int i =0;
+ for(;c != nodes.end();c++) {
+ i++;
+ debuglog(("LATServices::serinfo::get_node :node %2d '%s' \n",
+ i, c->first.c_str()));
+ }
+
+ debuglog(("LATServices::serinfo::get_node looking for '%s' \n",
+ node.c_str()));
+
+
if (test != nodes.end())
{
***************
*** 119,122 ****
--- 149,153 ----
else
{
+ debuglog(("LATServices::serviceinfo::get_node : no node '%s' \n", node.c_str()));
return false;
}
***************
*** 210,213 ****
--- 241,321 ----
}
}
+
+ void LATServices::serviceinfo::list_nodes(std::ostrstream &output)
+ {
+ std::map<std::string, nodeinfo, std::less<std::string> >::iterator n(nodes.begin());
+ const unsigned char *addr = NULL;
+
+ output << "Node Name Status Address Identification" << std::endl;
+ for (; n != nodes.end(); n++)
+ {
+ addr = n->second.get_macaddr();
+ output.width(17);
+ output.setf(std::ios::left, std::ios::adjustfield);
+ output << n->first.c_str() <<
+ (n->second.check_respond_counter()?"Reachable ":"Unreachable") << " ";
+
+ output.setf(std::ios::hex, std::ios::basefield);
+
+ output << setiosflags(std::ios::right | std::ios::uppercase) << std::setfill('0')
+ << std::setw(2) << (int)addr[0] << '-'
+ << std::setw(2) << (int)addr[1] << '-'
+ << std::setw(2) << (int)addr[2] << '-'
+ << std::setw(2) << (int)addr[3] << '-'
+ << std::setw(2) << (int)addr[4] << '-'
+ << std::setw(2) << (int)addr[5]
+ << resetiosflags(std::ios::right | std::ios::uppercase) << std::setfill(' ');
+
+ output.setf(std::ios::right, std::ios::adjustfield);
+ output << " " << n->second.get_ident() << std::endl;
+ }
+ }
+
+ bool LATServices::list_dummy_nodes(bool verbose, std::ostrstream &output)
+ {
+ std::map<std::string, serviceinfo, std::less<std::string> >::iterator dummies =
+ servicelist.find("");
+
+ if ( dummies == servicelist.end()) {
+ output << "No dummy nodes available." << std::endl;
+ return true;
+ }
+
+ output << std::endl;
+ output << "Service Name: " << "Slave nodes" << std::endl;
+ output << "Service Status: " << (servicelist[dummies->first].is_available()?"Available ":"Unavailable") << " " << std::endl;
+ output << "Service Ident: " << servicelist[dummies->first].get_ident() << std::endl << std::endl;
+ dummies->second.list_nodes(output);
+ output << "--------------------------------------------------------------------------------" << std::endl;
+
+
+ return true;
+ }
+
+ bool LATServices::touch_dummy_node_respond_counter(const std::string &str_name)
+ {
+ std::map<std::string, serviceinfo, std::less<std::string> >::iterator dummies =
+ servicelist.find("");
+
+ if ( dummies == servicelist.end()) {
+ return false; // no node
+ }
+
+ return dummies->second.touch_dummy_node_respond_counter(str_name);
+ }
+
+ bool LATServices::serviceinfo::touch_dummy_node_respond_counter(const std::string &str_name)
+ {
+ std::map<std::string, nodeinfo, std::less<std::string> >::iterator n = nodes.find(str_name);
+
+ if (n == nodes.end()) {
+ return false; // no node
+ }
+
+ debuglog(("touch_respond() : node: %s ", n->first.c_str()));
+ n->second.touch_respond_counter();
+ return true;
+ }
+
// List all known services
Index: services.h
===================================================================
RCS file: /cvsroot/linux-decnet/latd/services.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** services.h 14 Oct 2002 14:45:15 -0000 1.9
--- services.h 4 Jan 2004 15:49:04 -0000 1.10
***************
*** 1,4 ****
/******************************************************************************
! (c) 2000 Patrick Caulfield pa...@de...
This program is free software; you can redistribute it and/or modify
--- 1,5 ----
/******************************************************************************
! (c) 2000-2004 Patrick Caulfield pa...@de...
! (c) 2003 Dmitri Popov
This program is free software; you can redistribute it and/or modify
***************
*** 42,45 ****
--- 43,49 ----
void purge() {servicelist.clear(); }
void expire_nodes();
+ bool list_dummy_nodes(bool verbose, std::ostrstream &output);
+ bool touch_dummy_node_respond_counter(const std::string &str_name);
+
private:
***************
*** 67,77 ****
nodes[node] = nodeinfo(macaddr, rating, ident, interface);
}
! bool get_highest(std::string &node, unsigned char *macaddr, int *interface);
! bool get_node(const std::string &node, unsigned char *macaddr, int *interface);
const std::string get_ident() { return ident; }
! bool is_available();
! bool remove_node(const std::string &node);
! void serviceinfo::list_service(std::ostrstream &output);
! void expire_nodes(time_t);
private:
--- 71,83 ----
nodes[node] = nodeinfo(macaddr, rating, ident, interface);
}
! bool get_highest(std::string &node, unsigned char *macaddr, int *interface);
! bool get_node(const std::string &node, unsigned char *macaddr, int *interface);
const std::string get_ident() { return ident; }
! bool is_available();
! bool remove_node(const std::string &node);
! void serviceinfo::list_service(std::ostrstream &output);
! void expire_nodes(time_t);
! void list_nodes(std::ostrstream &output);
! bool touch_dummy_node_respond_counter(const std::string &str_name);
private:
***************
*** 83,87 ****
rating(_rating),
interface(_interface),
! available(true)
{
memcpy(macaddr, _macaddr, 6);
--- 89,94 ----
rating(_rating),
interface(_interface),
! available(true),
! slave_reachable(5) // if it doesn't respond five times...
{
memcpy(macaddr, _macaddr, 6);
***************
*** 101,104 ****
--- 108,123 ----
std::string get_ident() { return ident; }
+ int touch_respond_counter()
+ {
+ if (slave_reachable > 0)
+ {
+ slave_reachable--;
+ }
+ debuglog(("touch_respond_counter() %d\n", slave_reachable));
+ return slave_reachable;
+ }
+
+ bool check_respond_counter() { return slave_reachable > 0; }
+
private:
unsigned char macaddr[6];
***************
*** 108,111 ****
--- 127,133 ----
std::string ident;
time_t updated;
+
+ // for slave nodes
+ int slave_reachable;
};// class LATServices::service::nodeinfo
Index: utils.h
===================================================================
RCS file: /cvsroot/linux-decnet/latd/utils.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** utils.h 21 Feb 2003 15:18:54 -0000 1.7
--- utils.h 4 Jan 2004 15:49:04 -0000 1.8
***************
*** 48,57 ****
#endif
#ifdef VERBOSE_DEBUG
#define debuglog(x) pjc_debuglog x
! #include <stdarg.h>
! extern void pjc_debuglog(char *,...);
#else
#define debuglog(x)
#endif
--- 48,83 ----
#endif
+ #if defined(VERBOSE_DEBUG)
+ #include <stdarg.h>
+ extern void pjc_debuglog(char *,...);
+ #endif
+
#ifdef VERBOSE_DEBUG
#define debuglog(x) pjc_debuglog x
! //#include <stdarg.h>
! //extern void pjc_debuglog(char *,...);
#else
#define debuglog(x)
#endif
+
+ #include <signal.h>
+
+ class sig_blk_t {
+ public:
+ sig_blk_t(int sig_num)
+ {
+ sigset_t new_set;
+
+ sigemptyset(&new_set);
+ sigaddset(&new_set, sig_num);
+ sigprocmask(SIG_BLOCK, &new_set, &saved_set);
+ }
+ virtual ~sig_blk_t()
+ {
+ sigprocmask(SIG_SETMASK, &saved_set, NULL);
+ }
+
+ private:
+ sigset_t saved_set;
+ };
|