+// pre v5 heartbeat session structure
+struct oldsession {
+ sessionidt next;
+ sessionidt far;
+ tunnelidt tunnel;
+ in_addr_t ip;
+ int ip_pool_index;
+ unsigned long unique_id;
+ uint16_t nr;
+ uint16_t ns;
+ uint32_t magic;
+ uint32_t cin, cout;
+ uint32_t pin, pout;
+ uint32_t total_cin;
+ uint32_t total_cout;
+ uint32_t id;
+ uint16_t throttle_in;
+ uint16_t throttle_out;
+ clockt opened;
+ clockt die;
+ time_t last_packet;
+ in_addr_t dns1, dns2;
+ routet route[MAXROUTE];
+ uint16_t radius;
+ uint16_t mru;
+ uint16_t tbf_in;
+ uint16_t tbf_out;
+ uint8_t l2tp_flags;
+ uint8_t reserved_old_snoop;
+ uint8_t walled_garden;
+ uint8_t flags1;
+ char random_vector[MAXTEL];
+ int random_vector_length;
+ char user[129];
+ char called[MAXTEL];
+ char calling[MAXTEL];
+ uint32_t tx_connect_speed;
+ uint32_t rx_connect_speed;
+ uint32_t flags;
+#define SF_IPCP_ACKED 1 // Has this session seen an IPCP Ack?
+#define SF_LCP_ACKED 2 // LCP negotiated
+#define SF_CCP_ACKED 4 // CCP negotiated
+ in_addr_t snoop_ip;
+ uint16_t snoop_port;
+ uint16_t sid;
+ uint8_t filter_in;
+ uint8_t filter_out;
+ char reserved[18];
+};
+
+static uint8_t *convert_session(struct oldsession *old)
+{
+ static sessiont new;
+ int i;
+
+ memset(&new, 0, sizeof(new));
+
+ new.next = old->next;
+ new.far = old->far;
+ new.tunnel = old->tunnel;
+ new.flags = old->l2tp_flags;
+ new.ip = old->ip;
+ new.ip_pool_index = old->ip_pool_index;
+ new.unique_id = old->unique_id;
+ new.magic = old->magic;
+ new.pin = old->pin;
+ new.pout = old->pout;
+ new.cin = old->total_cin;
+ new.cout = old->total_cout;
+ new.cin_delta = old->cin;
+ new.cout_delta = old->cout;
+ new.throttle_in = old->throttle_in;
+ new.throttle_out = old->throttle_out;
+ new.filter_in = old->filter_in;
+ new.filter_out = old->filter_out;
+ new.mru = old->mru;
+ new.opened = old->opened;
+ new.die = old->die;
+ new.last_packet = old->last_packet;
+ new.dns1 = old->dns1;
+ new.dns2 = old->dns2;
+ new.tbf_in = old->tbf_in;
+ new.tbf_out = old->tbf_out;
+ new.random_vector_length = old->random_vector_length;
+ new.tx_connect_speed = old->tx_connect_speed;
+ new.rx_connect_speed = old->rx_connect_speed;
+ new.snoop_ip = old->snoop_ip;
+ new.snoop_port = old->snoop_port;
+ new.walled_garden = old->walled_garden;
+
+ memcpy(new.random_vector, old->random_vector, sizeof(new.random_vector));
+ memcpy(new.user, old->user, sizeof(new.user));
+ memcpy(new.called, old->called, sizeof(new.called));
+ memcpy(new.calling, old->calling, sizeof(new.calling));
+
+ for (i = 0; i < MAXROUTE; i++)
+ memcpy(&new.route[i], &old->route[i], sizeof(new.route[i]));
+
+ if (new.opened)
+ {
+ new.ppp.phase = Establish;
+ if (old->flags & (SF_IPCP_ACKED|SF_LCP_ACKED))
+ {
+ new.ppp.phase = Network;
+ new.ppp.lcp = Opened;
+ new.ppp.ipcp = (old->flags & SF_IPCP_ACKED) ? Opened : Starting;
+ new.ppp.ccp = (old->flags & SF_CCP_ACKED) ? Opened : Stopped;
+ }
+
+ // no PPPv6 in old session
+ new.ppp.ipv6cp = Stopped;
+ }
+
+ return (uint8_t *) &new;
+}
+