inline record type definition

I'm writing some of the builtin path_funcs and I'm running into a problem that we identified a while ago but I don't remember if we came to a conclusion on how to deal with it. When I use the following function as a $path_func for the logging framework it fails because when the rec value is passed in, the first ordinal value is almost always a time field and it tries to turn the time field into a conn_id field which obviously fails. What we need it to do is make rec$id the actual value of the $id field which is normally the third field so it needs to be done by name instead.

function path_with_direction(id: ID, path: string, rec: record {id: conn_id;}): string
  if ( Site::is_local_addr(rec$id$orig_h) )
    return fmt("%s-%s", path, "outbound");
    return fmt("%s-%s", path, "inbound");

Robin, do you recall if we figured out a way to work around this or if I'm doing this wrong?


I was pretty sure that it *is* done by name. Need to take a look.


That's the conclusion that I thought we came to also.


I can't reproduce this. Below is a script which I believe does what
you're describing (in three different ways!), but it runs just fine.

Anything I'm missing?


--------- cut -------------------------------------------------------

type Info: record {
  ts: time &log;
  id: conn_id &log;

function path_with_direction(id: Log::ID, path: string, rec: record {id: conn_id;}): string
      print id, path, rec;
      return path;

redef Log::default_path_func = path_with_direction;

redef enum Log::ID += { MyLog };

event connection_established(c: connection)
  local i: Info = [$ts=network_time(), $id=c$id];
  path_with_direction(HTTP::HTTP, "manual", i);
  Log::write(MyLog, [$ts=network_time(), $id=c$id]);

event bro_init()
  Log::create_stream(MyLog, [$columns=Info]);
  Log::add_filter(MyLog, [$name="default", $path_func=path_with_direction]);