2012-04-04 34 views
2

正確なエラーと同様に、該当するコードは以下のとおりです。setsockoptで奇妙なエラー "プロトコルが利用できません"

sd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); 
if (setsockopt(sd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) 
{ 
    printf("%s\n", strerror(errno)); 
} 
if (setsockopt(sd, IPPROTO_IP, IP_DF, &on, sizeof(on)) < 0) 
{ 
    printf("%s\n", strerror(errno)); 
    printf("DF\n"); 
} 

エラー:

[email protected]:~# gcc main.c 
main.c: In function ‘main’: 
main.c:71: warning: format not a string literal and no format arguments 
[email protected]:~# ./a.out localhost 
Protocol not available 
DF 

それは最初のものではない間に、第2のsetsockoptが、erroringされていることを奇妙です。

答えて

3

IP_DFはパケットフラグであり、ソケットオプションではありません。有効なソケットオプションは、ip(7)のマニュアルページに記載されています。

+0

ip(7)のマニュアルページを読んで、どのようにデフラグしないか設定できません。助けて? – W00t

0

ip(7)のマニュアルページ。

IP_NODEFRAG (since Linux 2.6.36) 
      If enabled (argument is nonzero), the reassembly of outgoing packets is 
      disabled in the netfilter layer. This option is only valid for 
      SOCK_RAW sockets. The argument is an integer.