1 /****************************************************************************** 2 * 3 * Copyright (C) 2003-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * BD address services. 22 * 23 ******************************************************************************/ 24 25 #include "data_types.h" 26 #include "bd.h" 27 28 /***************************************************************************** 29 ** Constants 30 *****************************************************************************/ 31 32 /* global constant for "any" bd addr */ 33 const BD_ADDR bd_addr_any = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 34 const BD_ADDR bd_addr_null= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 35 36 /***************************************************************************** 37 ** Functions 38 *****************************************************************************/ 39 40 /******************************************************************************* 41 ** 42 ** Function bdcpy 43 ** 44 ** Description Copy bd addr b to a. 45 ** 46 ** 47 ** Returns void 48 ** 49 *******************************************************************************/ 50 void bdcpy(BD_ADDR a, const BD_ADDR b) 51 { 52 int i; 53 54 for (i = BD_ADDR_LEN; i != 0; i--) 55 { 56 *a++ = *b++; 57 } 58 } 59 60 /******************************************************************************* 61 ** 62 ** Function bdcmp 63 ** 64 ** Description Compare bd addr b to a. 65 ** 66 ** 67 ** Returns Zero if b==a, nonzero otherwise (like memcmp). 68 ** 69 *******************************************************************************/ 70 int bdcmp(const BD_ADDR a, const BD_ADDR b) 71 { 72 int i; 73 74 for (i = BD_ADDR_LEN; i != 0; i--) 75 { 76 if (*a++ != *b++) 77 { 78 return -1; 79 } 80 } 81 return 0; 82 } 83 84 /******************************************************************************* 85 ** 86 ** Function bdcmpany 87 ** 88 ** Description Compare bd addr to "any" bd addr. 89 ** 90 ** 91 ** Returns Zero if a equals bd_addr_any. 92 ** 93 *******************************************************************************/ 94 int bdcmpany(const BD_ADDR a) 95 { 96 return bdcmp(a, bd_addr_any); 97 } 98 99 /******************************************************************************* 100 ** 101 ** Function bdsetany 102 ** 103 ** Description Set bd addr to "any" bd addr. 104 ** 105 ** 106 ** Returns void 107 ** 108 *******************************************************************************/ 109 void bdsetany(BD_ADDR a) 110 { 111 bdcpy(a, bd_addr_any); 112 } 113