+// pre v6 heartbeat session structure
+struct oldsession {
+ sessionidt next;
+ sessionidt far;
+ tunnelidt tunnel;
+ uint8_t flags;
+ struct {
+ uint8_t phase;
+ uint8_t lcp:4;
+ uint8_t ipcp:4;
+ uint8_t ipv6cp:4;
+ uint8_t ccp:4;
+ } ppp;
+ char reserved_1[2];
+ in_addr_t ip;
+ int ip_pool_index;
+ uint32_t unique_id;
+ char reserved_2[4];
+ uint32_t magic;
+ uint32_t pin, pout;
+ uint32_t cin, cout;
+ uint32_t cin_wrap, cout_wrap;
+ uint32_t cin_delta, cout_delta;
+ uint16_t throttle_in;
+ uint16_t throttle_out;
+ uint8_t filter_in;
+ uint8_t filter_out;
+ uint16_t mru;
+ clockt opened;
+ clockt die;
+ uint32_t session_timeout;
+ uint32_t idle_timeout;
+ time_t last_packet;
+ time_t last_data;
+ in_addr_t dns1, dns2;
+ routet route[MAXROUTE];
+ uint16_t tbf_in;
+ uint16_t tbf_out;
+ int random_vector_length;
+ uint8_t random_vector[MAXTEL];
+ char user[MAXUSER];
+ char called[MAXTEL];
+ char calling[MAXTEL];
+ uint32_t tx_connect_speed;
+ uint32_t rx_connect_speed;
+ clockt timeout;
+ uint32_t mrru;
+ uint8_t mssf;
+ epdist epdis;
+ bundleidt bundle;
+ in_addr_t snoop_ip;
+ uint16_t snoop_port;
+ uint8_t walled_garden;
+ uint8_t ipv6prefixlen;
+ struct in6_addr ipv6route;
+ char reserved_3[11];
+};
+
+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->flags;
+ new.ppp.phase = old->ppp.phase;
+ new.ppp.lcp = old->ppp.lcp;
+ new.ppp.ipcp = old->ppp.ipcp;
+ new.ppp.ipv6cp = old->ppp.ipv6cp;
+ new.ppp.ccp = old->ppp.ccp;
+ 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->cin;
+ new.cout = old->cout;
+ new.cin_wrap = old->cin_wrap;
+ new.cout_wrap = old->cout_wrap;
+ new.cin_delta = old->cin_delta;
+ new.cout_delta = old->cout_delta;
+ 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.session_timeout = old->session_timeout;
+ new.idle_timeout = old->idle_timeout;
+ new.last_packet = old->last_packet;
+ new.last_data = old->last_data;
+ 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.timeout = old->timeout;
+ new.mrru = old->mrru;
+ new.mssf = old->mssf;
+ new.epdis = old->epdis;
+ new.bundle = old->bundle;
+ new.snoop_ip = old->snoop_ip;
+ new.snoop_port = old->snoop_port;
+ new.walled_garden = old->walled_garden;
+ new.ipv6prefixlen = old->ipv6prefixlen;
+ new.ipv6route = old->ipv6route;
+
+ 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]));
+
+ return (uint8_t *) &new;
+}
+