Commit 87f39d05 authored by Antonin Décimo's avatar Antonin Décimo Committed by Juliusz Chroboczek

Rename MAC functions and constants to match the spec.

s/crypto seqno/pc/g
s/challenge response/challenge reply/g
s/challenge req/challenge request/g
parent 02b14e38
......@@ -232,7 +232,7 @@ add_hmac(struct buffered *buf, struct interface *ifp,
buf->buf + i + 2);
if(hmaclen < 0)
return -1;
buf->buf[i++] = MESSAGE_HMAC;
buf->buf[i++] = MESSAGE_MAC;
buf->buf[i++] = hmaclen;
i += hmaclen;
return i;
......@@ -268,7 +268,7 @@ check_hmac(const unsigned char *packet, int packetlen, int bodylen,
break;
}
len = packet[i + 1];
if(packet[i] == MESSAGE_HMAC) {
if(packet[i] == MESSAGE_MAC) {
int ok;
if(i + len + 2 > packetlen) {
fprintf(stderr, "Received truncated message.\n");
......
......@@ -475,7 +475,7 @@ preparse_packet(const unsigned char *packet, int bodylen,
fprintf(stderr, "Received truncated message.\n");
break;
}
if(type == MESSAGE_CRYPTO_SEQNO) {
if(type == MESSAGE_PC) {
if(len < 4) {
fprintf(stderr, "Received truncated PC TLV.\n");
break;
......@@ -490,8 +490,8 @@ preparse_packet(const unsigned char *packet, int bodylen,
index_len = len - 4;
memcpy(index, message + 6, len - 4);
have_index = 1;
} else if(type == MESSAGE_CHALLENGE_RESPONSE) {
debugf("Received challenge response from %s.\n",
} else if(type == MESSAGE_CHALLENGE_REPLY) {
debugf("Received challenge reply from %s.\n",
format_address(neigh->address));
gettime(&now);
if(len == sizeof(neigh->nonce) &&
......@@ -530,7 +530,7 @@ preparse_packet(const unsigned char *packet, int bodylen,
neigh->have_index = 1;
return 1;
} else {
send_challenge_req(neigh);
send_challenge_request(neigh);
return 0;
}
}
......@@ -982,9 +982,9 @@ parse_packet(const unsigned char *from, struct interface *ifp,
format_eui64(message + 8), seqno);
handle_request(neigh, prefix, plen, src_prefix, src_plen,
message[6], seqno, message + 8);
} else if(type == MESSAGE_CRYPTO_SEQNO ||
} else if(type == MESSAGE_PC ||
type == MESSAGE_CHALLENGE_REQUEST ||
type == MESSAGE_CHALLENGE_RESPONSE) {
type == MESSAGE_CHALLENGE_REPLY) {
/* We're dealing with these in preparse_packet. */
} else {
debugf("Received unknown packet type %d from %s on %s.\n",
......@@ -1073,7 +1073,7 @@ flushbuf(struct buffered *buf, struct interface *ifp)
if(buf->len > 0) {
if(ifp->key != NULL && ifp->key->type != AUTH_TYPE_NONE)
send_crypto_seqno(buf, ifp);
send_pc(buf, ifp);
debugf(" (flushing %d buffered bytes)\n", buf->len);
DO_HTONS(packet_header + 2, buf->len);
fill_rtt_message(buf, ifp);
......@@ -1181,7 +1181,7 @@ accumulate_bytes(struct buffered *buf,
}
int
send_crypto_seqno(struct buffered *buf, struct interface *ifp)
send_pc(struct buffered *buf, struct interface *ifp)
{
if(ifp->pc == 0) {
int rc;
......@@ -1189,10 +1189,10 @@ send_crypto_seqno(struct buffered *buf, struct interface *ifp)
if(rc < INDEX_LEN)
return -1;
}
start_message(buf, ifp, MESSAGE_CRYPTO_SEQNO, 4 + INDEX_LEN);
start_message(buf, ifp, MESSAGE_PC, 4 + INDEX_LEN);
accumulate_int(buf, ifp->pc);
accumulate_bytes(buf, ifp->index, INDEX_LEN);
end_message(buf, MESSAGE_CRYPTO_SEQNO, 4 + INDEX_LEN);
end_message(buf, MESSAGE_PC, 4 + INDEX_LEN);
ifp->pc++;
return 1;
}
......@@ -1210,7 +1210,7 @@ send_ack(struct neighbour *neigh, unsigned short nonce, unsigned short interval)
}
int
send_challenge_req(struct neighbour *neigh)
send_challenge_request(struct neighbour *neigh)
{
int rc;
debugf("Sending challenge request to %s on %s.\n",
......@@ -1233,9 +1233,9 @@ send_challenge_reply(struct neighbour *neigh, const unsigned char *crypto_nonce,
{
debugf("Sending challenge reply to %s on %s.\n",
format_address(neigh->address), neigh->ifp->name);
start_message(&neigh->buf, neigh->ifp, MESSAGE_CHALLENGE_RESPONSE, len);
start_message(&neigh->buf, neigh->ifp, MESSAGE_CHALLENGE_REPLY, len);
accumulate_bytes(&neigh->buf, crypto_nonce, len);
end_message(&neigh->buf, MESSAGE_CHALLENGE_RESPONSE, len);
end_message(&neigh->buf, MESSAGE_CHALLENGE_REPLY, len);
schedule_flush_now(&neigh->buf);
}
......
......@@ -35,10 +35,10 @@ THE SOFTWARE.
#define MESSAGE_REQUEST 9
#define MESSAGE_MH_REQUEST 10
#define MESSAGE_HMAC 16
#define MESSAGE_CRYPTO_SEQNO 17
#define MESSAGE_MAC 16
#define MESSAGE_PC 17
#define MESSAGE_CHALLENGE_REQUEST 18
#define MESSAGE_CHALLENGE_RESPONSE 19
#define MESSAGE_CHALLENGE_REPLY 19
/* Protocol extension through sub-TLVs. */
#define SUBTLV_PAD1 0
......@@ -60,10 +60,10 @@ void parse_packet(const unsigned char *from, struct interface *ifp,
const unsigned char *to);
void flushbuf(struct buffered *buf, struct interface *ifp);
void flushupdates(struct interface *ifp);
int send_crypto_seqno(struct buffered *buf, struct interface *ifp);
int send_pc(struct buffered *buf, struct interface *ifp);
void send_ack(struct neighbour *neigh, unsigned short nonce,
unsigned short interval);
int send_challenge_req(struct neighbour *neigh);
int send_challenge_request(struct neighbour *neigh);
void send_challenge_reply(struct neighbour *neigh,
const unsigned char *crypto_nonce, int len);
void send_multicast_hello(struct interface *ifp, unsigned interval, int force);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment