libiptc라이브러리의 iptc_insert_entry()로 iptable에 내용을 추가할때 문제입니다.

jihoonlights의 이미지

아래 소스코드는 libiptc HOWTO문서에 있는 내용입니다.

태그로인식하는거 같아서 []로 고쳤습니다
1 #include [stdio.h]
2 #include [tdlib.h]
3 #include [unistd.h]
4 #include [string.h]
5 #include [netinet/in.h]
6 #include [sys/socket.h]
7 #include [arpa/inet.h]
8 #include [errno.h]
9 #include [libiptc/libiptc.h]
10 #include [iptables.h]
11
12 //int main(int argc, char * argv[])
13 int main()
14 {
15 iptc_handle_t ipH;
16 struct ipt_entry e;
17 char * chain = "mychain";
18
19 if( (ipH = iptc_init("filter")) ) printf("init succeeded\n");
20 if( iptc_create_chain(chain, &ipH) ) printf("created chain <%s>\n", chain);
21 if( iptc_commit(&ipH) ) printf("committed newly created chain\n");
22
23
24 if( (ipH = iptc_init("filter")) ) printf("(re)init succeeded\n");
25
26 memset(&e, 0, sizeof(e));
27
28 inet_aton( "192.168.1.114", &e.ip.src );
29 inet_aton( "192.168.2.2", &e.ip.dst );
30 inet_aton( "255.255.255.0", &e.ip.dmsk );
31 strncpy(e.ip.iniface, "eth0", sizeof(e.ip.iniface) );
32 strncpy(e.ip.outiface, "eth1", sizeof(e.ip.outiface));
33
34 e.ip.proto = 8;
35
36 if( iptc_insert_entry(chain, &e, 0, &ipH) == 0 ) {
37 printf("insert entry failed\n");
38 exit(-1);
39 }
40
41 printf("insert entry succeeded\n");
42
43 if( ! iptc_commit( &ipH ) ) {
44 printf("new entry commit failed: %s\n", iptc_strerror(errno));
45 exit(-1);
46 }
47 printf("new entry commit succeeded\n");
48
49 return 0;
50 }

아래의 내용은 위 프로그램을 실행 했을때의 내용 입니다.

[root@gaia /home/project/iptc_insert_entry]# ./iptc_insert_entry
init succeeded
committed newly created chain
(re)init succeeded
insert entry succeeded
new entry commit failed: Invalid argument

마지막 줄의 내용은
(new entry commit failed: Invalid argument)
43번째 줄의 iptc_commit()함수의 반환이 0이 되어서 생기는 에러 입니다.

libiptc HOWTO 문서에 반환이 0일때는 버전에러로 업그레이드 하라고 나옵니다만
제가 테스트를 할때는 iptable-1.3.7번젼으로 최신버전이였습니다.

그래서 제가 iptable에 있는 소스를 찾아보고자 grep명령으로iptc_commit()함수를 찾아봤으나
헤더파일에 함수 선언부분은 있었는데 구현부는 나타나지 않았습니다.

제가 초보자라 이걸 어떻게 해결해야할지 잘 모르겠습니다.
도와주십시요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.