[strongSwan-dev] question about updown_listener.c

Andrew Foss afoss at actmobile.com
Wed Apr 22 20:22:16 CEST 2015


Hello,

I am wanting to get some byte counts when ipsec sessions come up and down.

It looked really easy, thinking I could add two env vars in 
updown_listener.c, so the updown scripts could log the use for the 
sessions, I am working on 5.0.2

looks like it is as simple as adding something like this to 
updown_listener.c:METHOD(listener_t, child_updown, bool, 
private_updown_listener_t *this, ike_sa_t *ike_sa, child_sa_t *child_sa, 
bool up)


         time_t use_in, use_out;
         u_int64_t bytes_in = 0, bytes_out = 0;

         child_sa->get_usestats(child_sa, TRUE, &use_in, &bytes_in);
         child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out);

         /* build the command with all env variables.
          * TODO: PLUTO_PEER_CA and PLUTO_NEXT_HOP are currently missing
          */
         snprintf(command, sizeof(command),
                  "2>&1 "
                 "BYTES_IN='%"PRIu64"' "
                 "BYTES_OUT='%"PRIu64"' "

Issue is this code doesn't seem to run, I tried changing the 
PLUTO_VERSION in this function, just to prove to myself that this was 
indeed running the updown scripts, but those vars don't change in the 
updown scripts.

Seemed so simple, but I am obviously misunderstanding something in the 
system.

Anyone have any suggestions to get me on the right track?

thanks in advance,
andrew


More information about the Dev mailing list