- * deactivates a shared key from the association * ASSUMES INP_WLOCK is already held */
| 1296 | * ASSUMES INP_WLOCK is already held |
| 1297 | */ |
| 1298 | int |
| 1299 | sctp_deact_sharedkey(struct sctp_tcb *stcb, uint16_t keyid) |
| 1300 | { |
| 1301 | sctp_sharedkey_t *skey; |
| 1302 | |
| 1303 | if (stcb == NULL) |
| 1304 | return (-1); |
| 1305 | |
| 1306 | /* is the keyid the assoc active sending key */ |
| 1307 | if (keyid == stcb->asoc.authinfo.active_keyid) |
| 1308 | return (-1); |
| 1309 | |
| 1310 | /* does the key exist? */ |
| 1311 | skey = sctp_find_sharedkey(&stcb->asoc.shared_keys, keyid); |
| 1312 | if (skey == NULL) |
| 1313 | return (-1); |
| 1314 | |
| 1315 | /* are there other refcount holders on the key? */ |
| 1316 | if (skey->refcount == 1) { |
| 1317 | /* no other users, send a notification for this key */ |
| 1318 | sctp_ulp_notify(SCTP_NOTIFY_AUTH_FREE_KEY, stcb, keyid, 0, |
| 1319 | SCTP_SO_LOCKED); |
| 1320 | } |
| 1321 | |
| 1322 | /* mark the key as deactivated */ |
| 1323 | skey->deactivated = 1; |
| 1324 | |
| 1325 | return (0); |
| 1326 | } |
| 1327 | |
| 1328 | /*- |
| 1329 | * deactivates a shared key from the endpoint |
no test coverage detected