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