Hello,
I'm new to IPSec, i have downloaded the "ipsec-tools-0.7.3.tar.gz" to get familiar with the IPSEC and i'm working on it. While deleting the Security Association i have got two function in pfkey.c file

1. int pfkey_send_delete(so, satype, mode, src, dst, spi)
    int so;
    u_int satype, mode;
    struct sockaddr *src, *dst;
    u_int32_t spi;

2. int
pfkey_send_delete_all(so, satype, mode, src, dst)
    int so;
    u_int satype, mode;
    struct sockaddr *src, *dst;


Can any one tell me how the kernel will differentiate these two API, in which we use same type SADB_DELETE.

I used this function "pfkey_send_delete_all" to delete Security Association but i have received the errno number 22(Invalid Argument).

This below code which i added in the "test-pfkey.c" file,

case SADB_DELETE:
{
  struct sockaddr_in src_sa, dst_sa;
 memset(&src_sa, 0, sizeof(struct sockaddr_in));
 memset(&dst_sa, 0, sizeof(struct sockaddr_in));
 src_sa.sin_family = PF_INET;
 src_sa.sin_port = htons(INADDR_ANY);
 inet_aton(src, &src_sa.sin_addr.s_addr);

 dst_sa.sin_family = PF_INET;
 dst_sa.sin_port = htons(INADDR_ANY);
 inet_aton(dst, &dst_sa.sin_addr.s_addr);

 int ret = pfkey_send_delete_all(soc, SADB_SATYPE_ESP, IPSEC_MODE_ANY, (struct sockaddr* )&src_sa, (struct sockaddr *)&dst_sa); 
}

Can any one help me where i'm going wrong?
-- 
Regards,
Venkatgiri