- * delete a shared key from an association * ASSUMES TCB_LOCK is already held */
| 1183 | * ASSUMES TCB_LOCK is already held |
| 1184 | */ |
| 1185 | int |
| 1186 | sctp_delete_sharedkey(struct sctp_tcb *stcb, uint16_t keyid) |
| 1187 | { |
| 1188 | sctp_sharedkey_t *skey; |
| 1189 | |
| 1190 | if (stcb == NULL) |
| 1191 | return (-1); |
| 1192 | |
| 1193 | /* is the keyid the assoc active sending key */ |
| 1194 | if (keyid == stcb->asoc.authinfo.active_keyid) |
| 1195 | return (-1); |
| 1196 | |
| 1197 | /* does the key exist? */ |
| 1198 | skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); |
| 1199 | if (skey == NULL) |
| 1200 | return (-1); |
| 1201 | |
| 1202 | /* are there other refcount holders on the key? */ |
| 1203 | if (skey->refcount > 1) |
| 1204 | return (-1); |
| 1205 | |
| 1206 | /* remove it */ |
| 1207 | LIST_REMOVE(skey, next); |
| 1208 | sctp_free_sharedkey(skey); /* frees skey->key as well */ |
| 1209 | |
| 1210 | /* clear any cached keys */ |
| 1211 | sctp_clear_cachedkeys(stcb, keyid); |
| 1212 | return (0); |
| 1213 | } |
| 1214 | |
| 1215 | /*- |
| 1216 | * deletes a shared key from the endpoint |
no test coverage detected