thom311 / libnl

Netlink Library Suite
GNU Lesser General Public License v2.1
419 stars 311 forks source link

xfrm lib missing the set/get for if_id #348

Open Ali-aqrabawi opened 1 year ago

Ali-aqrabawi commented 1 year ago

example of the if_id nlattr:

// if_id attribute
    struct nlattr *if_id = (struct nlattr *) (((char *) crypt_nla) + NLMSG_ALIGN(crypt_nla->nla_len));
    if_id->nla_len = sizeof(struct nlattr) + sizeof(uint32_t);
    if_id->nla_type = XFRMA_IF_ID;

    uint32_t if_index = 43;  // Replace with the actual interface index
    memcpy(((char *) if_id + NLA_HDRLEN), &if_index, sizeof(uint32_t));
sudo ip xfrm state 
src 192.168.2.175 dst 192.168.2.1
    proto esp spi 0x01000000 reqid 123455 mode tunnel
    replay-window 0 
    auth-trunc hmac(sha256) 0x00010000000000000000000000000000 96
    enc cbc(aes) 0x3132333435363738393031323334353637383930313233343536373839303132
    encap type espinudp sport 0 dport 0 addr 192.168.2.1
    anti-replay context: seq 0x0, oseq 0x0, bitmap 0x00000000
    if_id 0x2b <-------
    sel src 0.0.0.0/0 dst 0.0.0.0/0