Class: IPQueue
- Inherits:
-
Object
- Object
- IPQueue
- Defined in:
- ext/ipqueue/ipqueue.c
Defined Under Namespace
Classes: Packet
Class Method Summary collapse
Instance Method Summary collapse
- #accept(*args) ⇒ Object
- #drop ⇒ Object
- #range ⇒ Object
-
#range= ⇒ Object
Assume IPQ_COPY_META when range is zero.
- #read(*args) ⇒ Object
Class Method Details
.new ⇒ Object
26 27 |
# File 'ext/ipqueue/ipqueue.c', line 26 static VALUE fipq_create_handle(klass, flags, protocol) VALUE klass, flags, protocol; |
Instance Method Details
#accept(*args) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'ext/ipqueue/ipqueue.c', line 146 static VALUE fipq_accept(int argc, VALUE *argv, VALUE obj) { struct ipqueue_object *ipqueue; VALUE packet_id, payload; unsigned char *buf = NULL; size_t data_len = 0; if(rb_scan_args(argc, argv, "11", &packet_id, &payload) == 2) { Check_Type(payload, T_STRING); buf = RSTRING(payload)->ptr; data_len = RSTRING(payload)->len; } Data_Get_Struct(obj, struct ipqueue_object, ipqueue); if(ipq_set_verdict(ipqueue->handle, NUM2INT(packet_id), NF_ACCEPT, data_len, buf) < 0) rb_raise(rb_eRuntimeError, "%s: %s", ipq_errstr(), strerror(errno)); return Qtrue; } |
#drop ⇒ Object
167 168 |
# File 'ext/ipqueue/ipqueue.c', line 167 static VALUE fipq_drop(obj, packet_id) VALUE obj, packet_id; |
#range ⇒ Object
77 78 79 80 81 82 83 |
# File 'ext/ipqueue/ipqueue.c', line 77 static VALUE fipq_get_range(VALUE obj) { struct ipqueue_object *ipqueue; Data_Get_Struct(obj, struct ipqueue_object, ipqueue); return INT2FIX(ipqueue->range); } |
#range= ⇒ Object
Assume IPQ_COPY_META when range is zero
53 54 |
# File 'ext/ipqueue/ipqueue.c', line 53 static VALUE fipq_set_range(obj, range) VALUE obj, range; |
#read(*args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'ext/ipqueue/ipqueue.c', line 109 static VALUE fipq_read(int argc, VALUE *argv, VALUE obj) { struct ipqueue_object *ipqueue; int ret; ipq_packet_msg_t *packet_msg; VALUE timeout, payload, packet; VALUE error[2]; if(rb_scan_args(argc, argv, "01", &timeout) == 0) timeout = INT2NUM(0); Data_Get_Struct(obj, struct ipqueue_object, ipqueue); ret = ipq_read(ipqueue->handle, ipqueue->buf, ipqueue->len, NUM2INT(timeout)); if(ret < 0) rb_raise(rb_eRuntimeError, "%s: %s", ipq_errstr(), strerror(errno)); if(ret == 0) if(errno == EINTR) rb_raise(rb_eSignal, "non-blocked signal caught"); else rb_raise(eTimeout, "timeout exceeded"); /* dirty hack? */ if((ipqueue->buf) == NLMSG_ERROR) { error[0] = rb_str_new2("netlink layer"); error[1] = INT2FIX(ipq_get_msgerr(ipqueue->buf)); rb_exc_raise(rb_class_new_instance(2, error, rb_eSystemCallError)); } /* finally, we've got it */ packet_msg = ipq_get_packet(ipqueue->buf); return create_ipqueuepacket(packet_msg, obj); } |