<commit_before>/* 6LoWPAN MAC - layer 2 implementations */

#include "sixlowmac.h"
#include "drivers/cc110x/cc1100.h"
#include <stdio.h>
#include <stdint.h>

static void init_msba2_mac(mac_addr addr){
    addr.oui1 = MSBA2_OUI >> 8;
    addr.oui2 = 0x0 | MSBA2_OUI;
    addr.ext_ident = MSBA2_R8BIT;
    addr.ext_ident = cc1100_get_address();
}

static void init_mac_address(mac_addr addr){
    
#ifdef SIXLOWPAN_MSBA2
    init_msba2_mac(addr);
#endif    
}<commit_msg>created addressing methods(link local/multicast)<commit_after>/* 6LoWPAN MAC - layer 2 implementations */

#include "sixlowmac.h"
#include "sixlownd.h"
#include "sixlowip.h"
#include "drivers/cc110x/cc1100.h"
#include "radio/radio.h"

#define IP_BUFFER ((struct ipv6_hdr*)&buffer[LL_HEADER_LENGTH])

#define PRINTF(...) printf(__VA_ARGS__) 
#define PRINT6ADDR(addr) PRINTF("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])


#include <stdio.h>

void boot_6ln(void){
//    uint8_t ipv6_ext_hdr_len = 0;
    /* create link-local address based on eui-64 */
    create_link_local_prefix(&IP_BUFFER->srcaddr);
    set_eui64(&IP_BUFFER->srcaddr);
    PRINT6ADDR(&IP_BUFFER->srcaddr);
    /* send router solicitation */
    send_rs();
}


void create_link_local_prefix(ipv6_addr *ipaddr){
    ipaddr->uint16[0] = HTONS(0xfe80);
    ipaddr->uint16[1] = 0;
    ipaddr->uint16[2] = 0;
    ipaddr->uint16[3] = 0;
}

/* cc1100 - eui-64 init fuction */
void set_eui64(ipv6_addr *ipaddr){
    uint16_t radio_driver_addr = cc1100_get_address();

    ipaddr->uint8[8] = ((uint8_t) (OUI >> 16)) | 0x2 ;
    ipaddr->uint8[9] = (uint8_t) (OUI >> 8);
    ipaddr->uint8[10] = (uint8_t) OUI;
    ipaddr->uint8[11] = 0xFF;
    ipaddr->uint8[12] = 0xFE; 
    ipaddr->uint8[13] = R8BIT;
    ipaddr->uint8[14] = (uint8_t) (radio_driver_addr >> 8);
    ipaddr->uint8[15] = (uint8_t) radio_driver_addr;
}

void create_all_routers_mcast_addr(ipv6_addr *ipaddr){
    ipaddr->uint16[0] = HTONS(0xff02);
    ipaddr->uint16[1] = 0;
    ipaddr->uint16[2] = 0;
    ipaddr->uint16[3] = 0;
    ipaddr->uint16[4] = 0;
    ipaddr->uint16[5] = 0;
    ipaddr->uint16[6] = 0;
    ipaddr->uint16[7] = HTONS(0x0002);
}

void get_link_layer_addr_from_ipaddr(ipv6_addr *ipaddr, link_layer_addr *lla){
    lla->uint8[0] = ipaddr->uint8[8];
    lla->uint8[1] = ipaddr->uint8[9];
    lla->uint8[2] = ipaddr->uint8[10];
    lla->uint8[3] = ipaddr->uint8[11];
    lla->uint8[4] = ipaddr->uint8[12];
    lla->uint8[5] = ipaddr->uint8[13];
    lla->uint8[6] = ipaddr->uint8[14];
    lla->uint8[7] = ipaddr->uint8[15];
}
{'fraction_non_alphanumeric': 0.1958904109589041, 'fraction_numerical': 0.09006849315068494, 'mean_word_length': 4.4906015037593985, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5299132', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1274, 'n_words': 203}