- 论坛徽章:
- 0
|
不知道大家有没有人看Unix Network Programming V1 3ed,在19章 Key Management Sockets中,编译dump和add都没有问题,但运行时都会提示:
linhaohong# ./dump
socket error: Protocol not supported
linhaohong# ./add 127.0.0.1 127.0.0.1 HMAC-SHA-1-96 160 0123456789abcdef0123456789abcdef01234567
socket error: Protocol not supported
而我在SUSE linux 9.0上运行没有问题:
zwtmglab:/home/linhaohong/unpv13e/key # ./add 127.0.0.1 127.0.0.1 HMAC-SHA-1-96 160 0123456789abcdef0123456789abcdef01234567
Sending add message:
SADB Message Add, errno 0, satype IPsec AH, seq 0, pid 2009
SA: SPI=1989672960 Replay Window=0 State=Mature
Authentication Algorithm: HMAC-SHA-1
Encryption Algorithm: None
Source address: 127.0.0.1/32
Dest address: 127.0.0.1/32
Authentication key, 160 bits: 0x0123456789abcdef0123456789abcdef01234567
Reply returned:
SADB Message Add, errno 0, satype IPsec AH, seq 0, pid 2009
SA: SPI=1989672960 Replay Window=0 State=Mature
Authentication Algorithm: HMAC-SHA-1
Encryption Algorithm: None
Hard lifetime:
0 allocations, 0 bytes0 addtime, 0 usetime
Soft lifetime:
0 allocations, 0 bytes0 addtime, 0 usetime
Current lifetime:
0 allocations, 0 bytes
added at Thu Sep 6 12:56:25 2007, never used
Source address: 127.0.0.1/32
Dest address: 127.0.0.1/32
Proxy address: 0.0.0.0 (IP proto 255)
[unknown extension 19]
zwtmglab:/home/linhaohong/unpv13e/key # ./dump
Sending dump message:
SADB Message Dump, errno 0, satype Unspecified, seq 0, pid 2051
Messages returned:
SADB Message Dump, errno 0, satype IPsec AH, seq 0, pid 2051
SA: SPI=1989672960 Replay Window=0 State=Mature
Authentication Algorithm: HMAC-SHA-1
Encryption Algorithm: None
Hard lifetime:
0 allocations, 0 bytes0 addtime, 0 usetime
Soft lifetime:
0 allocations, 0 bytes0 addtime, 0 usetime
Current lifetime:
0 allocations, 0 bytes
added at Thu Sep 6 12:56:25 2007, never used
Source address: 127.0.0.1/32
Dest address: 127.0.0.1/32
Proxy address: 0.0.0.0 (IP proto 255)
Authentication key, 160 bits: 0x0123456789abcdef0123456789abcdef01234567
[unknown extension 19]
注意:linux中需要把#include <net/pfkeyv2.h>调整为#include <linux/pfkeyv2.h>,并将unp.h的struct in_pktinfo定义注释掉。 |
|