static bool inject(unsigned int index, __u32 src_addr, __u16 src_id, __u32 dst_addr, __u16 dst_id) { struct session_entry *entry = &entries[index]; int error; init_src6(&entry->src6.l3, src_addr); entry->src6.l4 = src_id; init_dst6(&entry->dst6.l3, dst_addr); entry->dst6.l4 = dst_id; entry->src4.l3.s_addr = cpu_to_be32(0xcb007100u | src_addr); entry->src4.l4 = src_id; entry->dst4.l3.s_addr = cpu_to_be32(0xc0000200u | dst_addr); entry->dst4.l4 = dst_id; entry->proto = L4PROTO_UDP; entry->state = ESTABLISHED; entry->timer_type = SESSION_TIMER_EST; entry->update_time = jiffies; entry->timeout = UDP_DEFAULT; entry->has_stored = false; error = bib_add_session(db, entry, NULL); if (error) { log_err("Errcode %d on sessiontable_add.", error); return false; } return true; }
static bool inject(unsigned int index, __u32 src_addr, __u16 src_id, __u32 dst_addr, __u16 dst_id) { struct session_entry *entry; int error; entry = &session_instances[index]; sessions[src_addr][src_id][dst_addr][dst_id] = entry; init_src6(&entry->src6, src_addr, src_id); init_dst6(&entry->dst6, dst_addr, dst_id); init_src4(&entry->src4, src_addr, src_id); init_dst4(&entry->dst4, dst_addr, dst_id); entry->proto = L4PROTO_UDP; entry->state = ESTABLISHED; entry->timer_type = SESSION_TIMER_EST; entry->update_time = jiffies; entry->timeout = UDP_DEFAULT; entry->has_stored = false; error = bib_add_session(db, entry, NULL); if (error) { log_err("Errcode %d on sessiontable_add.", error); return false; } return true; }
static bool assert_session(unsigned int la, unsigned int lp, unsigned int ra, unsigned int rp) { struct session_entry session; int expected; init_src6(&session.src6, la, lp); init_dst6(&session.dst6, ra, rp); init_src4(&session.src4, la, lp); init_dst4(&session.dst4, ra, rp); session.proto = PROTO; expected = !!sessions[la][lp][ra][rp]; return ASSERT_INT(expected, session_exists(&session), "session %u %u %u %u lookup", la, lp, ra, rp); }