1// Copyright 2017 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "device_id.h"
6
7#include <stdio.h>
8#include <string.h>
9
10#include "eff_short_wordlist_1.h"
11
12#define APPEND_WORD(NUM, SEP)         \
13    word = dictionary[(NUM) % 1296];  \
14    memcpy(dest, word, strlen(word)); \
15    dest += strlen(word);             \
16    *dest = SEP;                      \
17    dest++;
18
19void device_id(mac_addr addr, char out[DEVICE_ID_MAX]) {
20    const char* word;
21    char* dest = out;
22    APPEND_WORD(addr.x[0] | ((addr.x[4] << 8) & 0xF00), '-');
23    APPEND_WORD(addr.x[1] | ((addr.x[5] << 8) & 0xF00), '-');
24    APPEND_WORD(addr.x[2] | ((addr.x[4] << 4) & 0xF00), '-');
25    APPEND_WORD(addr.x[3] | ((addr.x[5] << 4) & 0xF00), 0);
26}
27