MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_delete_sharedkey

Function sctp_delete_sharedkey

freebsd/netinet/sctp_auth.c:1185–1213  ·  view source on GitHub ↗

- * delete a shared key from an association * ASSUMES TCB_LOCK is already held */

Source from the content-addressed store, hash-verified

1183 * ASSUMES TCB_LOCK is already held
1184 */
1185int
1186sctp_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

Callers 1

sctp_setoptFunction · 0.85

Calls 3

sctp_find_sharedkeyFunction · 0.85
sctp_free_sharedkeyFunction · 0.85
sctp_clear_cachedkeysFunction · 0.85

Tested by

no test coverage detected