text:
(function() {
  "use strict";

  pitana.util = {
    //@msg - Message to be logged
    //@param: {String} msg - message to be logged
    log: function() {
      if (pitana.settings.debug === true && pitana.settings.isConsoleAvailable === true) {
        console.log.apply(console, arguments);
      }
    },
    //@msg - Error Message to be logged
    //pitana.util.logError(), can be used to log error messages to console.
    logError: function() {
      if (pitana.settings.debug === true && pitana.settings.isConsoleAvailable === true) {
        console.error.apply(console, arguments);
      }
    },
    //Replacement for _.each over Objects
    for: function(Obj, callback) {
      for (var i in Obj) {
        if (Obj.hasOwnProperty(i) === true) {
          callback(Obj[i], i);
        }
      }
    },
    addProperty: function(obj, prop, getCallback, setCallback) {
      var v;
      //var v = obj[prop]; //Initialise with Old Property Value
      Object.defineProperty(obj, prop, {
        enumerable: true,
        configurable: true,
        get: function() {
          getCallback(v);
          return v;
        },
        set: function(value) {
          v = value;
          setCallback(v);
        }
      });

    }
  };

})();


text:
const expect = require('chai').expect;
const bearerToken = require('./');
const cookie = require('cookie-signature');

describe('bearerToken', function () {
  var token = 'test-token';
  var secret = 'SUPER_SECRET';

  it('finds a bearer token in post body under "access_token" and sets it to req.token', function (done) {
    var req = {body:{access_token:token}};
    bearerToken('secret')(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in query string under "access_token" and sets it to req.token', function (done) {
    var req = {query:{access_token:token}};
    bearerToken()(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in headers under "authorization: bearer" and sets it to req.token', function (done) {
    var req = {headers:{authorization:'Bearer '+token}};
    bearerToken()(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in post body under an arbitrary key and sets it to req.token', function (done) {
    var req = {body:{test:token}};
    bearerToken({bodyKey:'test'})(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in query string under "access_token" and sets it to req.token', function (done) {
    var req = {query:{test:token}};
    bearerToken({queryKey:'test'})(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in headers under "authorization: <anykey>" and sets it to req.token', function (done) {
    var req = {headers:{authorization:'test '+token}};
    bearerToken({headerKey:'test'})(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in header SIGNED cookies[<anykey>] and sets it to req.token', function (done) {
    // simulate the res.cookie signed prefix 's:'
    var signedCookie = encodeURI('s:' + cookie.sign(token, secret));
    var req = { headers: { cookie: 'test=' + signedCookie + '; ' } };
    bearerToken({ cookie: { key:'test', signed: true, secret: secret } })(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token in header NON SIGNED cookies[<anykey>] and sets it to req.token', function (done) {
    var req = {headers:{cookie: 'test='+token+'; '}};
    bearerToken({cookie:{key: 'test'}})(req, {}, function () {
      expect(req.token).to.equal(token);
      done();
    });
  });

  it('finds a bearer token and sets it to req[<anykey>]', function (done) {
    var req = {body:{access_token:token}};
    var reqKey = 'test';
    bearerToken({reqKey:reqKey})(req, {}, function() {
      expect(req[reqKey]).to.equal(token);
      done();
    });
  });

  it('aborts with 400 if token is provided in more than one location', function (done) {
    var req = {
      query: {
        access_token: 'query-token'
      },
      body: {
        access_token: 'query-token'
      },
      headers: {
        authorization: 'bearer header-token',
        cookies: 'access_token=cookie-token;'
      },
    };
    var res = {
      status: function (code) {
        res.code = code;
        return res;
      },
      send: function () {
        expect(res.code).to.equal(400);
        done();
      }
    }
    bearerToken()(req, res);
  });

});

redpajama_set_name: RedPajamaGithub


text:
using namespace de::njsm::netsi;

static Packet g_packet;
static IPv4_Address g_next_hop;
static std::uint16_t g_port;

void g_send(Packet a_packet, IPv4_Address a_next_hop, std::uint16_t a_port){
    g_packet = std::move(a_packet);
    g_next_hop = a_next_hop;
    g_port = a_port;
}

TEST(IP_Module_Test, constructor_sets_correctly){
    IP_Module l_uut(1, g_send);
    IPv4_Address l_add("10.0.0.1");

    EXPECT_EQ(30, l_uut.get_ttl());
    l_uut.set_ip_address(l_add, 0);
    EXPECT_EQ(l_add, l_uut.get_ip_address(0));

    EXPECT_THROW(l_uut.get_routing_unit(), std::runtime_error);
    EXPECT_FALSE(l_uut.has_packet());
    IPv4_Address l_dummy;
    IPv4_Header::Protocol l_protocol;
    EXPECT_THROW(l_uut.receive_packet(&l_dummy, &l_protocol), std::runtime_error);
}

TEST(IP_Module_Test, getter_and_setter_work){
    IPv4_Address l_ip_1(1);
    IPv4_Address l_ip_2(2);
    IPv4_Address l_ip_3(3);
    IPv4_Address l_ip_4(4);
    IP_Module l_uut(4, g_send);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));

    l_uut.set_routing_unit(l_routing);
    auto l_uut_routing = dynamic_cast<Default_Route_State&>(l_uut.get_routing_unit());

    EXPECT_EQ(IPv4_Address(), l_uut_routing.get_gateway_ip());
    EXPECT_EQ(0, l_uut_routing.get_gateway_port());

    l_uut.set_ip_address(l_ip_1, 0);
    l_uut.set_ip_address(l_ip_2, 1);
    l_uut.set_ip_address(l_ip_3, 2);
    l_uut.set_ip_address(l_ip_4, 3);

    EXPECT_EQ(l_ip_1, l_uut.get_ip_address(0));
    EXPECT_EQ(l_ip_2, l_uut.get_ip_address(1));
    EXPECT_EQ(l_ip_3, l_uut.get_ip_address(2));
    EXPECT_EQ(l_ip_4, l_uut.get_ip_address(3));

    l_uut.set_ttl(40);
    EXPECT_EQ(40, l_uut.get_ttl());
}

TEST(IP_Module_Test, interface_changed_forwarded){
    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Mock_Routing_Unit> l_routing(new Mock_Routing_Unit());
    l_uut.set_routing_unit(l_routing);

    l_uut.interface_changed(3);

    EXPECT_TRUE(l_routing->m_interface_changed_called);
    EXPECT_EQ(3, l_routing->m_interface);
}

TEST(IP_Module_Test, forwarding_works){

    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.2"));
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);
    // IP_Module forwards the packet, so it must be in our globals now

    ASSERT_EQ(l_packet.get_length(), g_packet.get_length());
    EXPECT_EQ(0, std::memcmp(l_packet.get_content() + 20,
                             g_packet.get_content() + 20, 100));
    EXPECT_EQ(29, IPv4_Header(g_packet.get_content()).get_time_to_live());
    EXPECT_TRUE(IPv4_Header(g_packet.get_content()).check_header_checksum());

}

TEST(IP_Module_Test, packet_processing_works){
    IP_Module l_uut(4, g_send);
    IPv4_Address l_source("192.168.178.3");
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(l_source);
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);

    ASSERT_TRUE(l_uut.has_packet());
    IPv4_Address l_source_stated;
    IPv4_Header::Protocol l_protocol;
    Packet l_received(l_uut.receive_packet(&l_source_stated, &l_protocol));

    ASSERT_EQ(l_packet.get_length() - 20, l_received.get_length());
    EXPECT_EQ(0, std::memcmp(l_received.get_content(),
                             l_packet.get_content() + 20,
                             100));
    EXPECT_EQ(l_source, l_source_stated);
    EXPECT_EQ(IPv4_Header::Protocol::TCP, l_protocol);
}

TEST(IP_Module_Test, UPD_packets_are_tested){
    IP_Module l_uut(4, g_send);
    IPv4_Address l_source("192.168.178.3");
    IPv4_Address l_dest("192.168.178.1");
    l_uut.set_ip_address(l_dest, 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());
    UDP_Header l_udp(l_packet.get_content() + 20);

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::UDP);
    l_header.set_source_address(l_source);
    l_header.set_destination_address(l_dest);
    l_udp.set_length(100);
    l_udp.set_source_port(80);
    l_udp.set_destination_port(80);
    l_udp.compute_checksum(l_source, l_dest);
    l_udp.set_source_port(l_udp.get_source_port() - (std::uint16_t) 1u);
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);

    ASSERT_FALSE(l_uut.has_packet());

}

TEST(IP_Module_Test, discarding_malformed_packets){
    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();
    l_header.set_identification(1);

    l_uut.proceed_packet(l_packet, 0);
    EXPECT_FALSE(l_uut.has_packet());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(0);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();
    l_header.set_identification(1);

    l_uut.proceed_packet(l_packet, 0);
    EXPECT_FALSE(l_uut.has_packet());
}

TEST(IP_Module_Test, discarding_old_packets){
    IP_Module l_uut(4, g_send);
    IPv4_Address l_source("192.168.178.3");
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(0);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(l_source);
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);

    ASSERT_FALSE(l_uut.has_packet());

}

TEST(IP_Module_Test, activating_reassembly_works){
    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_content(200);
    Packet l_packet(120);
    l_packet.set_content(l_content.get_content(), 100, 20);
    IPv4_Header l_header(l_packet.get_content());

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(true);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);

    ASSERT_FALSE(l_uut.has_packet());

    // setup IP header
    l_packet.set_content(l_content.get_content() + 100, 100, 20);
    l_header.set_version(0x04);
    l_header.set_header_length(20);
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(100);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.1"));
    l_header.set_header_checksum();

    l_uut.proceed_packet(l_packet, 0);

    ASSERT_TRUE(l_uut.has_packet());
    IPv4_Address l_ip;
    IPv4_Header::Protocol l_protocol;
    Packet l_received(l_uut.receive_packet(&l_ip, &l_protocol));

    EXPECT_EQ(l_content, l_received);

}

TEST(IP_Module_Test, udp_checksums_are_set){
    IP_Module l_uut(4, g_send);
    IPv4_Address l_source("192.168.178.3");
    IPv4_Address l_dest("192.168.178.1");
    l_uut.set_ip_address(l_source, 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(100);
    UDP_Header l_udp(l_packet.get_content());

    // setup IP header
    l_udp.set_length(100);
    l_udp.set_source_port(0xefef);
    l_udp.set_destination_port(0xabab);

    l_uut.send_packet(l_packet, l_dest, IPv4_Header::Protocol::UDP);
}

TEST(IP_Module_Test, simple_identification_works){
    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(100);

    for (std::uint16_t i = 0; i < 100; i++) {
        l_uut.send_packet(l_packet,
                          IPv4_Address("10.0.0.1"),
                          IPv4_Header::Protocol::TCP);

        IPv4_Header l_header(g_packet.get_content());
        EXPECT_EQ(i, l_header.get_identification());
    }
}

TEST(IP_Module_Test, advanced_identification_works_5s){

    IP_Module l_uut(4, g_send);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    Packet l_packet(100);

    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    l_uut.set_identification_threshold(5);
    l_uut.set_routing_unit(l_routing);

    EXPECT_EQ(5, l_uut.get_identification_threshold());

    // Putting module into advanced mode
    for (std::uint64_t i = 0; l_uut.is_simple_identification(); i++) {
        l_uut.send_packet(l_packet,
                          IPv4_Address("10.0.0.1"),
                          IPv4_Header::Protocol::TCP);
    }

    // now m_counter % 2048 == 0

    for (std::uint32_t i = 0; i < 20; i++){
        l_uut.send_packet(l_packet,
                          IPv4_Address(i),
                          IPv4_Header::Protocol::TCP);
        EXPECT_EQ(0, IPv4_Header(g_packet.get_content()).get_identification());
        l_uut.send_packet(l_packet,
                          IPv4_Address(i),
                          IPv4_Header::Protocol::TCP);
        EXPECT_EQ(1, IPv4_Header(g_packet.get_content()).get_identification());

    }

    // now m_counter % 2048 == 40

    l_uut.switch_to_simple_identification(true);

    for (std::uint32_t i = 0; i < 20; i++){
        l_uut.send_packet(l_packet,
                          IPv4_Address(42),             // magic ip address
                          IPv4_Header::Protocol::TCP);
        EXPECT_EQ(40 + i, IPv4_Header(g_packet.get_content()).get_identification() & 0x07ff);

    }
}

TEST(IP_Module_Test, options_are_processed){
    IP_Module l_uut(4, g_send);
    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    std::shared_ptr<Routing_State> l_routing(new Default_Route_State(IPv4_Address(), 0));
    l_uut.set_routing_unit(l_routing);

    Packet l_packet(120);
    IPv4_Header l_header(l_packet.get_content());
    g_packet = Packet(1);

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length((std::uint8_t) 20 + Timestamp_Option::compute_length(0, 1));
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.2"));
    l_header.create_timestamp_option(1, 0);
    l_header.set_header_checksum();
    l_uut.proceed_packet(l_packet, 0);

    IPv4_Header l_received(g_packet.get_content());
    ASSERT_TRUE(l_received.has_internet_timestamp());
    EXPECT_NE(0, l_received.get_timestamp_option().get_timestamp(0, nullptr));

    g_packet = Packet(1);

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length((std::uint8_t) 20 + Timestamp_Option::compute_length(0, 0));
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.2"));
    l_header.create_timestamp_option(0, 0);
    *(l_packet.get_content() + 23) |= 0xf0; // Set the overflow field to max
    l_header.set_header_checksum();
    l_uut.proceed_packet(l_packet, 0);

    EXPECT_EQ(1, g_packet.get_length());

    g_packet = Packet(1);

    // setup IP header
    l_header.set_version(0x04);
    l_header.set_header_length((std::uint8_t) 20 + Route_Record_Option::compute_length(1));
    l_header.set_type_of_service(0x00);
    l_header.set_total_length(l_packet.get_length());
    l_header.set_identification(0);
    l_header.set_dont_fragment(false);
    l_header.set_more_fragments(false);
    l_header.set_fragment_offset(0);
    l_header.set_time_to_live(30);
    l_header.set_protocol(IPv4_Header::Protocol::TCP);
    l_header.set_source_address(IPv4_Address("192.168.178.3"));
    l_header.set_destination_address(IPv4_Address("192.168.178.2"));
    l_header.create_route_record_option(1);
    l_header.set_header_checksum();
    l_uut.proceed_packet(l_packet, 0);

    l_received = IPv4_Header(g_packet.get_content());
    ASSERT_TRUE(l_received.has_route_record_option());
    auto l_option = l_received.get_route_record_option();
    EXPECT_EQ(IPv4_Address("192.168.178.1"), l_option.get_address(0));

}

TEST(IP_Module_Test, update_periodic_works){
    IP_Module l_uut(4, g_send);
    std::shared_ptr<Mock_Routing_Unit> l_routing(new Mock_Routing_Unit());
    Packet l_packet(100);

    l_uut.set_ip_address(IPv4_Address("192.168.178.1"), 0);
    l_uut.set_routing_unit(l_routing);
    l_uut.switch_to_simple_identification(false);
    l_uut.set_ttl(0);

    for (std::uint32_t i = 0; i < 20; i++){
        l_uut.send_packet(l_packet,
                          IPv4_Address(i),
                          IPv4_Header::Protocol::TCP);
        EXPECT_EQ(0, IPv4_Header(g_packet.get_content()).get_identification());
        l_uut.send_packet(l_packet,
                          IPv4_Address(i),
                          IPv4_Header::Protocol::TCP);
        EXPECT_EQ(1, IPv4_Header(g_packet.get_content()).get_identification());

    }

    l_uut.update_periodic();
    EXPECT_TRUE(l_routing->m_update_periodic_called);
    l_routing->reset();

    l_uut.set_ttl(1);
    l_uut.update_periodic();

    EXPECT_TRUE(l_routing->m_update_periodic_called);
}


text:
#define _GNU_SOURCE

#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <sys/file.h>
#include <sys/mount.h>

#include "util/message.h"
#include "util/util.h"
#include "util/file.h"
#include "util/registry.h"
#include "util/config_parser.h"
#include "util/fork.h"
#include "util/privilege.h"

#ifndef LOCALSTATEDIR
#error LOCALSTATEDIR not defined
#endif

int singularity_sessiondir(void) {
    char *sessiondir = NULL;
    char *sessiondir_size_str = NULL;
    long int sessiondir_size = 0;
    int sessiondir_size_str_len;
    int sessiondir_size_str_usd;

    singularity_message(DEBUG, "Setting sessiondir\n");
    sessiondir = joinpath(LOCALSTATEDIR, "/singularity/mnt/session");
    singularity_message(VERBOSE, "Using session directory: %s\n", sessiondir);

    singularity_message(DEBUG, "Checking for session directory: %s\n", sessiondir);
    if ( is_dir(sessiondir) != 0 ) {
        singularity_message(ERROR, "Session directory does not exist: %s\n", sessiondir);
        ABORT(255);
    }

    singularity_message(DEBUG, "Obtaining the default sessiondir size\n");
    if ( str2int(singularity_config_get_value(SESSIONDIR_MAXSIZE), &sessiondir_size) < 0 ) {
        singularity_message(ERROR, "Failed converting sessiondir size to integer, check config file\n");
        ABORT(255);
    }
    singularity_message(DEBUG, "Converted sessiondir size to: %ld\n", sessiondir_size);

    singularity_message(DEBUG, "Creating the sessiondir size mount option length\n");
    sessiondir_size_str_len = intlen(sessiondir_size) + 7;

    singularity_message(DEBUG, "Got size length of: %d\n", sessiondir_size_str_len);
    sessiondir_size_str = (char *) malloc(sessiondir_size_str_len);

    singularity_message(DEBUG, "Creating the sessiondir size mount option string\n");
    sessiondir_size_str_usd = snprintf(sessiondir_size_str, sessiondir_size_str_len, "size=%ldm", sessiondir_size);

    singularity_message(DEBUG, "Checking to make sure the string was allocated correctly\n");
    if ( sessiondir_size_str_usd + 1 !=  sessiondir_size_str_len ) {
        singularity_message(ERROR, "Failed to allocate string for sessiondir size string (%s): %d + 1 != %d\n", sessiondir_size_str, sessiondir_size_str_usd, sessiondir_size_str_len);
        ABORT(255);
    }

    singularity_priv_escalate();
    singularity_message(DEBUG, "Mounting sessiondir tmpfs: %s\n", sessiondir);
    if ( mount("tmpfs", sessiondir, "tmpfs", MS_NOSUID, sessiondir_size_str) < 0 ){
        singularity_message(ERROR, "Failed to mount sessiondir tmpfs %s: %s\n", sessiondir, strerror(errno));
        ABORT(255);
    }
    singularity_priv_drop();

    singularity_registry_set("SESSIONDIR", sessiondir);

    return(0);
}


text:
using Newtonsoft.Json;

namespace ShippingEasy.Responses
{
    public class CancelOrderResponse : ApiResponse
    {
        [JsonProperty]
        public Order Order { get; private set; }
    }
}


text:
package com.barbarysoftware.watchservice;

import java.io.IOException;

/**
 * An object that may be registered with a watch service so that it can be
 * watched for changes and events.
 *
 *
 This interface defines the {@link #register register} method to register
 * the object with a {@link WatchService} returning a {@link WatchKey} to
 * represent the registration. An object may be registered with more than one
 * watch service. Registration with a watch service is cancelled by invoking the
 * key's {@link WatchKey#cancel cancel} method.
 *
 * @since 1.7
 *
 * @see WatchableFile#register
 */

public interface Watchable {

    /**
     * Registers an object with a watch service.
     *
     *
 If the file system object identified by this object is currently
     * registered with the watch service then the watch key, representing that
     * registration, is returned after changing the event set or modifiers to
     * those specified by the {@code events} and {@code modifiers} parameters.
     * Changing the event set does not cause pending events for the object to be
     * discarded. Objects are automatically registered for the {@link
     * StandardWatchEventKind#OVERFLOW OVERFLOW} event. This event is not
     * required to be present in the array of events.
     *
     *
 Otherwise the file system object has not yet been registered with the
     * given watch service, so it is registered and the resulting new key is
     * returned.
     *
     *
 Implementations of this interface should specify the events they
     * support.
     *
     * @param   watcher
     *          the watch service to which this object is to be registered
     * @param   events
     *          the events for which this object should be registered
     * @param   modifiers
     *          the modifiers, if any, that modify how the object is registered
     *
     * @return  a key representing the registration of this object with the
     *          given watch service
     *
     * @throws  UnsupportedOperationException
     *          if unsupported events or modifiers are specified
     * @throws  IllegalArgumentException
     *          if an invalid of combination of events are modifiers are specified
     * @throws  ClosedWatchServiceException
     *          if the watch service is closed
     * @throws  IOException
     *          if an I/O error occurs
     * @throws  SecurityException
     *          if a security manager is installed and it denies an unspecified
     *          permission required to monitor this object. Implementations of
     *          this interface should specify the permission checks.
     */
    WatchKey register(WatchService watcher,
                      WatchEvent.Kind<?>[] events,
                      WatchEvent.Modifier... modifiers)
        throws IOException;

    /**
     * Registers an object with a watch service.
     *
     *
 An invocation of this method behaves in exactly the same way as the
     * invocation
     *

     *     watchable.{@link #register(WatchService, com.barbarysoftware.watchservice.WatchEvent.Kind[], com.barbarysoftware.watchservice.WatchEvent.Modifier...)}  register}(watcher, events, new WatchEvent.Modifier[0]);
     *

     *
     * @param   watcher
     *          the watch service to which this object is to be registered
     * @param   events
     *          the events for which this object should be registered
     *
     * @return  a key representing the registration of this object with the
     *          given watch service
     *
     * @throws  UnsupportedOperationException
     *          if unsupported events are specified
     * @throws  IllegalArgumentException
     *          if an invalid of combination of events are specified
     * @throws  ClosedWatchServiceException
     *          if the watch service is closed
     * @throws  IOException
     *          if an I/O error occurs
     * @throws  SecurityException
     *          if a security manager is installed and it denies an unspecified
     *          permission required to monitor this object. Implementations of
     *          this interface should specify the permission checks.
     */
    WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events)
        throws IOException;
}