Ejemplo n.º 1
0
ConnState::ConnState (LinkConnectClientPtr c, eibaddr_t addr)
  : L_Busmonitor_CallBack(c->t->name), SubDriver (c)
{
  t->setAuxName(FormatEIBAddr(addr));
  timeout.set <ConnState,&ConnState::timeout_cb> (this);
  sendtimeout.set <ConnState,&ConnState::sendtimeout_cb> (this);
  send_trigger.set<ConnState,&ConnState::send_trigger_cb>(this);
  send_trigger.start();
  timeout.start(CONNECTION_ALIVE_TIME, 0);
  this->addr = addr;
  TRACEPRINTF (t, 9, "has %s", FormatEIBAddr (addr));
}
Ejemplo n.º 2
0
bool LLlog::checkSysAddress(eibaddr_t addr)
{
  bool x = master->checkSysAddress(addr);
  tr()->TracePrintf (0, "Known Addr %s: %s",
      FormatEIBAddr(addr), x ? "yes" : "no");
  return x;
}
Ejemplo n.º 3
0
void
LogFilter::addAddress (eibaddr_t addr)
{
  Filter::addAddress(addr);
  if (log_addr)
    t->TracePrintf (0, "Add Addr %s", FormatEIBAddr(addr));
}
Ejemplo n.º 4
0
bool
  Layer3::registerIndividualCallBack (L_Data_CallBack * c,
				      Individual_Lock lock, eibaddr_t src,
				      eibaddr_t dest)
{
  unsigned i;
  TRACEPRINTF (t, 3, this, "registerIndividual %08X %d from %s to %s", c, lock, FormatEIBAddr(src)(), FormatEIBAddr(dest)());
  if (mode == 1)
    return 0;
  for (i = 0; i < individual (); i++)
    if (lock == Individual_Lock_Connection &&
	individual[i].src == src &&
	individual[i].lock == Individual_Lock_Connection)
      {
	TRACEPRINTF (t, 3, this, "registerIndividual locked %04X %04X",
		     individual[i].src, individual[i].dest);
	return 0;
      }

  for (i = 0; i < individual (); i++)
    {
      if (individual[i].dest == dest)
	break;
    }
  if (i == individual () && dest)
    for (int i = 0; i < layer2 (); i++)
      layer2[i].l2->addAddress (dest);
  individual.resize (individual () + 1);
  individual[individual () - 1].cb = c;
  individual[individual () - 1].dest = dest;
  individual[individual () - 1].src = src;
  individual[individual () - 1].lock = lock;
  TRACEPRINTF (t, 3, this, "registerIndividual %08X = 1", c);
  return 1;
}
Ejemplo n.º 5
0
bool
LogFilter::checkAddress (eibaddr_t addr)
{
  bool res = Filter::checkAddress(addr);
  if (log_addr)
    t->TracePrintf (0, "Addr Check %s: %s",
        FormatEIBAddr(addr), res ? "yes" : "no");
  return res;
}
Ejemplo n.º 6
0
static void
recv_me (EIBNetIPPacket *p1)
{
  EIBnet_DescriptionResponse resp;
  if (parseEIBnet_DescriptionResponse (*p1, resp))
    die ("Invalid description response");
  printf ("Medium: %d\nState: %d\nAddr: %s\nInstallID: %d\nSerial:",
          resp.KNXmedium, resp.devicestatus,
          FormatEIBAddr (resp.individual_addr).c_str(), resp.installid);
  HexDump (resp.serial, sizeof (resp.serial));
  printf ("Multicast-Addr: %s\nMAC:", inet_ntoa (resp.multicastaddr));
  HexDump (resp.MAC, sizeof (resp.MAC));
  printf ("Name: %s\n", resp.name);
  printf ("Optional: ");
  HexDump (resp.optional.data(), resp.optional.size());
  ITER(i, resp.services)
    printf ("Service %d Version %d\n", i->family, i->version);
  ev_break(EV_DEFAULT_ EVBREAK_ALL);
}
Ejemplo n.º 7
0
GroupCacheEntry
  GroupCache::Read (eibaddr_t addr, unsigned Timeout, uint16_t age)
{
  TRACEPRINTF (t, 4, this, "GroupCacheRead %s %d %d",
	       FormatGroupAddr (addr)(), Timeout, age);
  bool rm = false;
  GroupCacheEntry *c;
  if (!enable)
    {
      GroupCacheEntry f;
      f.src = 0;
      f.dst = 0;
      TRACEPRINTF (t, 4, this, "GroupCache not enabled");
      return f;
    }

  c = find (addr);
  if (c && age && c->recvtime + age < time (0))
    rm = true;

  if (c && !rm)
    {
      TRACEPRINTF (t, 4, this, "GroupCache found: %s",
		   FormatEIBAddr (c->src)());
      return *c;
    }

  if (!Timeout)
    {
      GroupCacheEntry f;
      f.src = 0;
      f.dst = addr;
      TRACEPRINTF (t, 4, this, "GroupCache no entry");
      return f;
    }

  A_GroupValue_Read_PDU apdu;
  T_DATA_XXX_REQ_PDU tpdu;
  L_Data_PDU *l;
  pth_event_t timeout = pth_event (PTH_EVENT_RTIME, pth_time (Timeout, 0));

  tpdu.data = apdu.ToPacket ();
  l = new L_Data_PDU (FakeL2);
  l->data = tpdu.ToPacket ();
  l->source = 0;
  l->dest = addr;
  l->AddrType = GroupAddress;
  layer3->send_L_Data (l);

  do
    {
      c = find (addr);
      rm = false;
      if (c && age && c->recvtime + age < time (0))
	rm = true;

      if (c && !rm)
	{
	  TRACEPRINTF (t, 4, this, "GroupCache found: %s",
		       FormatEIBAddr (c->src)());
	  pth_event_free (timeout, PTH_FREE_THIS);
	  return *c;
	}

      if (pth_event_status (timeout) == PTH_STATUS_OCCURRED && c)
	{
	  GroupCacheEntry gc;
	  gc.src = 0;
	  gc.dst = addr;
	  TRACEPRINTF (t, 4, this, "GroupCache reread timeout");
	  pth_event_free (timeout, PTH_FREE_THIS);
	  return gc;
	}

      if (pth_event_status (timeout) == PTH_STATUS_OCCURRED)
	{
	  c = new GroupCacheEntry;
	  c->src = 0;
	  c->dst = addr;
	  c->recvtime = time (0);
	  add (c);
	  TRACEPRINTF (t, 4, this, "GroupCache timeout");
	  pth_event_free (timeout, PTH_FREE_THIS);
	  return *c;
	}

      pth_mutex_acquire (&mutex, 0, 0);
      pth_cond_await (&cond, &mutex, timeout);
      pth_mutex_release (&mutex);
    }
  while (1);
}