| 871 | | this->public.interface.add_sa(&this->public.interface, |
|---|
| 872 | | src, dst, htonl(ntohs(cpi)), IPPROTO_COMP, reqid, 0, 0, |
|---|
| 873 | | ENCR_UNDEFINED, chunk_empty, AUTH_UNDEFINED, chunk_empty, |
|---|
| 874 | | mode, ipcomp, 0, FALSE, inbound); |
|---|
| | 871 | add_sa(this, src, dst, htonl(ntohs(cpi)), IPPROTO_COMP, reqid, 0, 0, |
|---|
| | 872 | ENCR_UNDEFINED, chunk_empty, AUTH_UNDEFINED, chunk_empty, |
|---|
| | 873 | mode, ipcomp, 0, FALSE, inbound); |
|---|
| | 1165 | * Implementation of kernel_interface_t.del_sa. |
|---|
| | 1166 | */ |
|---|
| | 1167 | static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *dst, |
|---|
| | 1168 | u_int32_t spi, protocol_id_t protocol, u_int16_t cpi) |
|---|
| | 1169 | { |
|---|
| | 1170 | unsigned char request[NETLINK_BUFFER_SIZE]; |
|---|
| | 1171 | struct nlmsghdr *hdr; |
|---|
| | 1172 | struct xfrm_usersa_id *sa_id; |
|---|
| | 1173 | |
|---|
| | 1174 | /* if IPComp was used, we first delete the additional IPComp SA */ |
|---|
| | 1175 | if (cpi) |
|---|
| | 1176 | { |
|---|
| | 1177 | del_sa(this, dst, htonl(ntohs(cpi)), IPPROTO_COMP, 0); |
|---|
| | 1178 | } |
|---|
| | 1179 | |
|---|
| | 1180 | memset(&request, 0, sizeof(request)); |
|---|
| | 1181 | |
|---|
| | 1182 | DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi)); |
|---|
| | 1183 | |
|---|
| | 1184 | hdr = (struct nlmsghdr*)request; |
|---|
| | 1185 | hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; |
|---|
| | 1186 | hdr->nlmsg_type = XFRM_MSG_DELSA; |
|---|
| | 1187 | hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)); |
|---|
| | 1188 | |
|---|
| | 1189 | sa_id = (struct xfrm_usersa_id*)NLMSG_DATA(hdr); |
|---|
| | 1190 | host2xfrm(dst, &sa_id->daddr); |
|---|
| | 1191 | sa_id->spi = spi; |
|---|
| | 1192 | sa_id->proto = proto_ike2kernel(protocol); |
|---|
| | 1193 | sa_id->family = dst->get_family(dst); |
|---|
| | 1194 | |
|---|
| | 1195 | if (this->socket_xfrm->send_ack(this->socket_xfrm, hdr) != SUCCESS) |
|---|
| | 1196 | { |
|---|
| | 1197 | DBG1(DBG_KNL, "unable to delete SAD entry with SPI %.8x", ntohl(spi)); |
|---|
| | 1198 | return FAILED; |
|---|
| | 1199 | } |
|---|
| | 1200 | DBG2(DBG_KNL, "deleted SAD entry with SPI %.8x", ntohl(spi)); |
|---|
| | 1201 | return SUCCESS; |
|---|
| | 1202 | } |
|---|
| | 1203 | |
|---|
| | 1204 | /** |
|---|
| 1188 | | this->public.interface.update_sa(&this->public.interface, |
|---|
| 1189 | | htonl(ntohs(cpi)), IPPROTO_COMP, 0, |
|---|
| 1190 | | src, dst, new_src, new_dst, FALSE, FALSE); |
|---|
| | 1227 | update_sa(this, htonl(ntohs(cpi)), IPPROTO_COMP, 0, |
|---|
| | 1228 | src, dst, new_src, new_dst, FALSE, FALSE); |
|---|
| 1343 | | return SUCCESS; |
|---|
| 1344 | | } |
|---|
| 1345 | | |
|---|
| 1346 | | /** |
|---|
| 1347 | | * Implementation of kernel_interface_t.del_sa. |
|---|
| 1348 | | */ |
|---|
| 1349 | | static status_t del_sa(private_kernel_netlink_ipsec_t *this, host_t *dst, |
|---|
| 1350 | | u_int32_t spi, protocol_id_t protocol, u_int16_t cpi) |
|---|
| 1351 | | { |
|---|
| 1352 | | unsigned char request[NETLINK_BUFFER_SIZE]; |
|---|
| 1353 | | struct nlmsghdr *hdr; |
|---|
| 1354 | | struct xfrm_usersa_id *sa_id; |
|---|
| 1355 | | |
|---|
| 1356 | | /* if IPComp was used, we first delete the additional IPComp SA */ |
|---|
| 1357 | | if (cpi) |
|---|
| 1358 | | { |
|---|
| 1359 | | this->public.interface.del_sa(&this->public.interface, dst, |
|---|
| 1360 | | htonl(ntohs(cpi)), IPPROTO_COMP, 0); |
|---|
| 1361 | | } |
|---|
| 1362 | | |
|---|
| 1363 | | memset(&request, 0, sizeof(request)); |
|---|
| 1364 | | |
|---|
| 1365 | | DBG2(DBG_KNL, "deleting SAD entry with SPI %.8x", ntohl(spi)); |
|---|
| 1366 | | |
|---|
| 1367 | | hdr = (struct nlmsghdr*)request; |
|---|
| 1368 | | hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; |
|---|
| 1369 | | hdr->nlmsg_type = XFRM_MSG_DELSA; |
|---|
| 1370 | | hdr->nlmsg_len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)); |
|---|
| 1371 | | |
|---|
| 1372 | | sa_id = (struct xfrm_usersa_id*)NLMSG_DATA(hdr); |
|---|
| 1373 | | host2xfrm(dst, &sa_id->daddr); |
|---|
| 1374 | | sa_id->spi = spi; |
|---|
| 1375 | | sa_id->proto = proto_ike2kernel(protocol); |
|---|
| 1376 | | sa_id->family = dst->get_family(dst); |
|---|
| 1377 | | |
|---|
| 1378 | | if (this->socket_xfrm->send_ack(this->socket_xfrm, hdr) != SUCCESS) |
|---|
| 1379 | | { |
|---|
| 1380 | | DBG1(DBG_KNL, "unable to delete SAD entry with SPI %.8x", ntohl(spi)); |
|---|
| 1381 | | return FAILED; |
|---|
| 1382 | | } |
|---|
| 1383 | | DBG2(DBG_KNL, "deleted SAD entry with SPI %.8x", ntohl(spi)); |
|---|