rubyipq 0.1.0-i686-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/rubyipq_util.c ADDED
@@ -0,0 +1,110 @@
1
+ /*
2
+ * rubyipq v0.1.0
3
+ * Ruby bindings for Netfilter's libipq.
4
+ *
5
+ * Copyright (c) 2005 Leonardo Eloy
6
+ * Author: Leonardo Eloy <l.eloy@terra.com.br/leonardo.eloy@gmail.com>
7
+ * Project Homepage: http://rubyipq.rubyforge.org
8
+ *
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program; if not, write to the Free Software
22
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
+ */
24
+
25
+ #include "rubyipq.h"
26
+
27
+ /*
28
+ __u32_to_str took from http://glug.ucdb.br/~ulysses/libipq.html
29
+ */
30
+ char * __u32_to_str (__u32 ip) {
31
+ unsigned int tmp = 0;
32
+ int i;
33
+ char *str_ip;
34
+
35
+ str_ip = (char *)malloc (sizeof(char) * 16);
36
+ str_ip[0] = '\0';
37
+ for (i=0; i<4; i++) {
38
+ tmp = ip & DECIMAL_BYTE_VALUE;
39
+ sprintf ((str_ip + strlen(str_ip)), "%d.", (unsigned int)tmp);
40
+ ip >>= 8;
41
+ }
42
+ sprintf ((str_ip + (strlen(str_ip) - 1)), "%c", '\0'); //erase last dot
43
+
44
+ str_ip[15] = '\0'; //just safe.
45
+ return ((char *)str_ip);
46
+ }
47
+
48
+ unsigned char *get_last_packet() {
49
+ if (last_packet == NULL)
50
+ rb_raise(rb_eRuntimeError, "no packet in queue '%s'", last_packet);
51
+
52
+
53
+ return last_packet;
54
+ }
55
+
56
+ ipq_packet_msg_t *get_last_packet_msg() {
57
+ if (last_packet_msg == NULL) {
58
+ last_packet_msg = ipq_get_packet(get_last_packet());
59
+ if (!last_packet_msg)
60
+ rb_raise(rb_eRuntimeError, "could not set packet message structure");
61
+ }
62
+
63
+ return last_packet_msg;
64
+ }
65
+
66
+ struct iphdr *get_last_ip_h() {
67
+ if (last_ip_h == NULL) {
68
+ last_ip_h = (struct iphdr *)get_last_packet_msg()->payload;
69
+
70
+ if (!last_ip_h)
71
+ rb_raise(rb_eRuntimeError, "could not set ip header structure");
72
+ }
73
+
74
+ return last_ip_h;
75
+ }
76
+
77
+ struct tcphdr *get_last_tcp_h() {
78
+ if (last_tcp_h == NULL) {
79
+ last_tcp_h = (struct tcphdr *)(get_last_packet_msg()->payload +
80
+ (get_last_ip_h()->ihl << 2));
81
+
82
+ if (!last_tcp_h)
83
+ rb_raise(rb_eRuntimeError, "could not set tcp header structure");
84
+ }
85
+
86
+ return last_tcp_h;
87
+ }
88
+
89
+ struct udphdr *get_last_udp_h() {
90
+ if (last_udp_h == NULL) {
91
+ last_udp_h = (struct udphdr *)(get_last_packet_msg()->payload +
92
+ (get_last_ip_h()->ihl << 2));
93
+
94
+ if (!last_udp_h)
95
+ rb_raise(rb_eRuntimeError, "could not set udp header structure");
96
+ }
97
+
98
+ return last_udp_h;
99
+ }
100
+
101
+ void static_cleanup() {
102
+ /* Good and ol' clean up :) */
103
+ last_packet = NULL;
104
+ last_packet_msg = NULL;
105
+ last_ip_h = NULL;
106
+ last_tcp_h = NULL;
107
+ last_udp_h = NULL;
108
+ last_icmp_h = NULL;
109
+ }
110
+
metadata ADDED
@@ -0,0 +1,56 @@
1
+ !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: rubyipq
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2005-11-03 00:00:00 -03:00
8
+ summary: Ruby bindings for Netfilter's libipq
9
+ require_paths:
10
+ - .
11
+ email: l.eloy@terra.com.br
12
+ homepage:
13
+ rubyforge_project: rubyipq
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: i686-linux
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Leonardo Eloy
30
+ files:
31
+ - rubyipq.c
32
+ - rubyipq.h
33
+ - rubyipq_ipheader.c
34
+ - rubyipq_proto.h
35
+ - rubyipq_tcpheader.c
36
+ - rubyipq_udpheader.c
37
+ - rubyipq_util.c
38
+ - rubyipq_defs.h
39
+ - extconf.rb
40
+ - Makefile
41
+ - Rubyipq.so
42
+ - COPYING
43
+ test_files: []
44
+
45
+ rdoc_options: []
46
+
47
+ extra_rdoc_files: []
48
+
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ requirements: []
54
+
55
+ dependencies: []
56
+