| 915 | } |
| 916 | |
| 917 | static void handle_cap_update(bin_packet_t *packet, node_info_t *source) |
| 918 | { |
| 919 | str cap; |
| 920 | int nr_cap, i, j; |
| 921 | struct remote_cap *cur; |
| 922 | struct local_cap *lcap; |
| 923 | int nr_nodes; |
| 924 | int node_id; |
| 925 | node_info_t *node; |
| 926 | int cap_state; |
| 927 | int rc; |
| 928 | int require_reply; |
| 929 | int seq_no, timestamp; |
| 930 | |
| 931 | bin_pop_int(packet, &seq_no); |
| 932 | bin_pop_int(packet, ×tamp); |
| 933 | |
| 934 | lock_get(source->lock); |
| 935 | if (validate_update(source->cap_seq_no, seq_no, |
| 936 | source->cap_timestamp, timestamp, 0, source->node_id) < 0) { |
| 937 | lock_release(source->lock); |
| 938 | return; |
| 939 | } else { |
| 940 | source->cap_seq_no = seq_no; |
| 941 | source->cap_timestamp = timestamp; |
| 942 | } |
| 943 | lock_release(source->lock); |
| 944 | |
| 945 | bin_pop_int(packet, &nr_nodes); |
| 946 | |
| 947 | for (i = 0; i < nr_nodes; i++) { |
| 948 | bin_pop_int(packet, &node_id); |
| 949 | |
| 950 | if (node_id == current_id) { |
| 951 | bin_pop_int(packet, &nr_cap); |
| 952 | for (j = 0; j < nr_cap; j++) { |
| 953 | bin_pop_str(packet, &cap); |
| 954 | bin_pop_int(packet, &cap_state); |
| 955 | } |
| 956 | continue; |
| 957 | } |
| 958 | node = get_node_by_id(source->cluster, node_id); |
| 959 | if (!node) { |
| 960 | LM_ERR("Unknown id [%d] in capability update from node [%d]\n", |
| 961 | node_id, source->node_id); |
| 962 | return; |
| 963 | } |
| 964 | |
| 965 | bin_pop_int(packet, &nr_cap); |
| 966 | for (j = 0; j < nr_cap; j++) { |
| 967 | bin_pop_str(packet, &cap); |
| 968 | bin_pop_int(packet, &cap_state); |
| 969 | |
| 970 | lock_get(node->lock); |
| 971 | |
| 972 | for (cur = node->capabilities; cur && str_strcmp(&cap, &cur->name); |
| 973 | cur = cur->next) ; |
| 974 | if (!cur) { /* new capability */ |
no test coverage detected