Lines Matching full:rx
108 static u64_t msg_hash(struct bt_mesh_net_rx *rx, struct os_mbuf *pdu) in msg_hash() argument
113 hash1 = (BT_MESH_NET_IVI_RX(rx) << 8) | pdu->om_data[2]; in msg_hash()
121 static bool msg_cache_match(struct bt_mesh_net_rx *rx, in msg_cache_match() argument
124 u64_t hash = msg_hash(rx, pdu); in msg_cache_match()
983 size_t data_len, struct bt_mesh_net_rx *rx, in net_decrypt() argument
989 rx->old_iv = (IVI(data) != (bt_mesh.iv_index & 0x01)); in net_decrypt()
994 if (bt_mesh_net_obfuscate(buf->om_data, BT_MESH_NET_IVI_RX(rx), priv)) { in net_decrypt()
998 if (rx->net_if == BT_MESH_NET_IF_ADV && msg_cache_match(rx, buf)) { in net_decrypt()
1003 rx->ctx.addr = SRC(buf->om_data); in net_decrypt()
1004 if (!BT_MESH_ADDR_IS_UNICAST(rx->ctx.addr)) { in net_decrypt()
1005 BT_WARN("Ignoring non-unicast src addr 0x%04x", rx->ctx.addr); in net_decrypt()
1009 BT_DBG("src 0x%04x", rx->ctx.addr); in net_decrypt()
1012 rx->net_if == BT_MESH_NET_IF_PROXY_CFG) { in net_decrypt()
1013 return bt_mesh_net_decrypt(enc, buf, BT_MESH_NET_IVI_RX(rx), in net_decrypt()
1017 return bt_mesh_net_decrypt(enc, buf, BT_MESH_NET_IVI_RX(rx), false); in net_decrypt()
1023 size_t data_len, struct bt_mesh_net_rx *rx, in friend_decrypt() argument
1039 data, data_len, rx, buf)) { in friend_decrypt()
1049 data, data_len, rx, buf)) { in friend_decrypt()
1050 rx->new_key = 1; in friend_decrypt()
1060 struct bt_mesh_net_rx *rx, in net_find_and_decrypt() argument
1076 if (!friend_decrypt(sub, data, data_len, rx, buf)) { in net_find_and_decrypt()
1077 rx->friend_cred = 1; in net_find_and_decrypt()
1078 rx->ctx.net_idx = sub->net_idx; in net_find_and_decrypt()
1079 rx->sub = sub; in net_find_and_decrypt()
1086 data, data_len, rx, buf)) { in net_find_and_decrypt()
1087 rx->ctx.net_idx = sub->net_idx; in net_find_and_decrypt()
1088 rx->sub = sub; in net_find_and_decrypt()
1098 data, data_len, rx, buf)) { in net_find_and_decrypt()
1099 rx->new_key = 1; in net_find_and_decrypt()
1100 rx->ctx.net_idx = sub->net_idx; in net_find_and_decrypt()
1101 rx->sub = sub; in net_find_and_decrypt()
1129 struct bt_mesh_net_rx *rx) in bt_mesh_net_relay() argument
1135 if (rx->net_if == BT_MESH_NET_IF_LOCAL) { in bt_mesh_net_relay()
1142 if (rx->ctx.recv_ttl == 1) { in bt_mesh_net_relay()
1146 if (rx->ctx.recv_ttl <= 1) { in bt_mesh_net_relay()
1151 if (rx->net_if == BT_MESH_NET_IF_ADV && in bt_mesh_net_relay()
1157 BT_DBG("TTL %u CTL %u dst 0x%04x", rx->ctx.recv_ttl, rx->ctl, in bt_mesh_net_relay()
1158 rx->ctx.recv_dst); in bt_mesh_net_relay()
1164 if (rx->net_if == BT_MESH_NET_IF_ADV) { in bt_mesh_net_relay()
1177 if (rx->net_if != BT_MESH_NET_IF_LOCAL) { in bt_mesh_net_relay()
1180 sbuf->om_data[1] |= rx->ctx.recv_ttl - 1; in bt_mesh_net_relay()
1185 enc = rx->sub->keys[rx->sub->kr_flag].enc; in bt_mesh_net_relay()
1186 priv = rx->sub->keys[rx->sub->kr_flag].privacy; in bt_mesh_net_relay()
1187 nid = rx->sub->keys[rx->sub->kr_flag].nid; in bt_mesh_net_relay()
1191 /* Update NID if RX or RX was with friend credentials */ in bt_mesh_net_relay()
1192 if (rx->friend_cred) { in bt_mesh_net_relay()
1201 if (bt_mesh_net_encrypt(enc, buf, BT_MESH_NET_IVI_RX(rx), false)) { in bt_mesh_net_relay()
1206 if (bt_mesh_net_obfuscate(buf->om_data, BT_MESH_NET_IVI_RX(rx), priv)) { in bt_mesh_net_relay()
1219 rx->net_if == BT_MESH_NET_IF_LOCAL)) { in bt_mesh_net_relay()
1220 if (bt_mesh_proxy_relay(buf, rx->ctx.recv_dst) && in bt_mesh_net_relay()
1221 BT_MESH_ADDR_IS_UNICAST(rx->ctx.recv_dst)) { in bt_mesh_net_relay()
1226 if (relay_to_adv(rx->net_if)) { in bt_mesh_net_relay()
1235 struct bt_mesh_net_rx *rx, struct os_mbuf *buf) in bt_mesh_net_decode() argument
1251 rx->net_if = net_if; in bt_mesh_net_decode()
1253 if (!net_find_and_decrypt(data->om_data, data->om_len, rx, buf)) { in bt_mesh_net_decode()
1259 rx->ctx.app_idx = BT_MESH_KEY_UNUSED; in bt_mesh_net_decode()
1261 rx->ctx.recv_ttl = TTL(buf->om_data); in bt_mesh_net_decode()
1264 if (rx->ctx.recv_ttl == 0) { in bt_mesh_net_decode()
1265 rx->ctx.send_ttl = 0; in bt_mesh_net_decode()
1267 rx->ctx.send_ttl = BT_MESH_TTL_DEFAULT; in bt_mesh_net_decode()
1270 rx->ctl = CTL(buf->om_data); in bt_mesh_net_decode()
1271 rx->seq = SEQ(buf->om_data); in bt_mesh_net_decode()
1272 rx->ctx.recv_dst = DST(buf->om_data); in bt_mesh_net_decode()
1278 rx->ctx.recv_dst == BT_MESH_ADDR_UNASSIGNED) { in bt_mesh_net_decode()
1283 if (BT_MESH_ADDR_IS_RFU(rx->ctx.recv_dst)) { in bt_mesh_net_decode()
1288 if (net_if != BT_MESH_NET_IF_LOCAL && bt_mesh_elem_find(rx->ctx.addr)) { in bt_mesh_net_decode()
1293 BT_DBG("src 0x%04x dst 0x%04x ttl %u", rx->ctx.addr, rx->ctx.recv_dst, in bt_mesh_net_decode()
1294 rx->ctx.recv_ttl); in bt_mesh_net_decode()
1304 struct bt_mesh_net_rx rx = { .rssi = rssi }; in bt_mesh_net_recv() local
1314 if (bt_mesh_net_decode(data, net_if, &rx, buf)) { in bt_mesh_net_recv()
1323 bt_mesh_proxy_addr_add(data, rx.ctx.addr); in bt_mesh_net_recv()
1326 rx.local_match = (bt_mesh_fixed_group_match(rx.ctx.recv_dst) || in bt_mesh_net_recv()
1327 bt_mesh_elem_find(rx.ctx.recv_dst)); in bt_mesh_net_recv()
1329 bt_mesh_trans_recv(buf, &rx); in bt_mesh_net_recv()
1334 if (!BT_MESH_ADDR_IS_UNICAST(rx.ctx.recv_dst) || in bt_mesh_net_recv()
1335 (!rx.local_match && !rx.friend_match)) { in bt_mesh_net_recv()
1337 bt_mesh_net_relay(buf, &rx); in bt_mesh_net_recv()