n->name, n->hostname);
}
+ if(experimental && OPTION_VERSION(n->options) >= 2)
+ n->status.sptps = true;
+
/* TODO: only clear status.validkey if node is unreachable? */
n->status.validkey = false;
if(!n->status.reachable) {
update_node_udp(n, NULL);
} else if(n->connection) {
- if(experimental && OPTION_VERSION(n->options) >= 2) {
+ if(n->status.sptps) {
if(n->connection->outgoing)
send_req_key(n);
} else {
printf(" reachable");
if(status.indirect)
printf(" indirect");
+ if(status.sptps)
+ printf(" sptps");
printf("\n");
printf("Options: ");
if(options & OPTION_INDIRECT)
}
static bool try_mac(node_t *n, const vpn_packet_t *inpkt) {
- if(experimental && OPTION_VERSION(n->options) >= 2)
+ if(n->status.sptps)
return sptps_verify_datagram(&n->sptps, (char *)inpkt->data - 4, inpkt->len);
if(!digest_active(&n->indigest) || inpkt->len < sizeof inpkt->seqno + digest_length(&n->indigest))
vpn_packet_t *outpkt = pkt[0];
size_t outlen;
- if(experimental && OPTION_VERSION(n->options) >= 2) {
+ if(n->status.sptps) {
sptps_receive_data(&n->sptps, (char *)inpkt->data - 4, inpkt->len);
return;
}
return;
}
- if(experimental && OPTION_VERSION(n->options) >= 2) {
+ if(n->status.sptps) {
uint8_t type = 0;
if(!(inpkt->data[12] | inpkt->data[13]))
type = PKT_PROBE;
myself->nexthop = myself;
myself->via = myself;
myself->status.reachable = true;
+ myself->status.sptps = experimental;
node_add(myself);
graph();
unsigned int visited:1; /* 1 if this node has been visited by one of the graph algorithms */
unsigned int reachable:1; /* 1 if this node is reachable in the graph */
unsigned int indirect:1; /* 1 if this node is not directly reachable by us */
- unsigned int unused:26;
+ unsigned int sptps:1; /* 1 if this node supports SPTPS */
+ unsigned int unused:25;
} node_status_t;
typedef struct node_t {
get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight);
- return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (PROT_MINOR << 24));
+ return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0));
}
static void send_everything(connection_t *c) {
for(node = connection_tree->head; node; node = node->next) {
c = node->data;
if(c->status.active && c->node && c->node->status.reachable) {
- if(!experimental || OPTION_VERSION(c->node->options) < 2)
+ if(!c->node->status.sptps)
send_ans_key(c->node);
}
}
if(experimental) {
for(node = node_tree->head; node; node = node->next) {
node_t *n = node->data;
- if(n->status.reachable && n->status.validkey && OPTION_VERSION(n->options) >= 2)
+ if(n->status.reachable && n->status.validkey && n->status.sptps)
sptps_force_kex(&n->sptps);
}
}
return true;
}
- if(OPTION_VERSION(n->options) < 2) {
+ if(!n->status.sptps) {
n->status.validkey = false;
n->last_req_key = 0;
}
}
bool send_req_key(node_t *to) {
- if(experimental && OPTION_VERSION(to->options) >= 2) {
+ if(to->status.sptps) {
if(!node_read_ecdsa_public_key(to)) {
logger(DEBUG_ALWAYS, LOG_DEBUG, "No ECDSA key known for %s (%s)", to->name, to->hostname);
send_request(to->nexthop->connection, "%d %s %s %d", REQ_KEY, myself->name, to->name, REQ_PUBKEY);
/* Check if this key request is for us */
- if(to == myself) { /* Yes, send our own key back */
+ if(to == myself) { /* Yes */
+ /* Is this an extended REQ_KEY message? */
if(experimental && reqno)
return req_key_ext_h(c, request, from, reqno);
+ /* No, just send our key back */
send_ans_key(from);
} else {
if(tunnelserver)
}
bool send_ans_key(node_t *to) {
- if(experimental && OPTION_VERSION(to->options) >= 2)
+ if(to->status.sptps)
abort();
size_t keylen = cipher_keylength(&myself->incipher);
/* SPTPS or old-style key exchange? */
- if(experimental && OPTION_VERSION(from->options) >= 2) {
+ if(from->status.sptps) {
char buf[strlen(key)];
int len = b64decode(key, buf, strlen(key));