Sha256: 2f0364de106be27d18b66424778c65edb78da93a82c17cb933d2c886b09d79f2
Contents?: true
Size: 1.84 KB
Versions: 4
Compression:
Stored size: 1.84 KB
Contents
/* * Copyright (C) 2008-2012 NEC Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "ruby.h" #include "trema.h" void set_xid( const buffer *openflow_message, uint32_t xid ) { ( ( struct ofp_header * ) ( openflow_message->data ) )->xid = htonl( xid ); } VALUE get_xid( VALUE self ) { buffer *openflow_message; Data_Get_Struct( self, buffer, openflow_message ); uint32_t xid = ntohl( ( ( struct ofp_header * ) ( openflow_message->data ) )->xid ); return UINT2NUM( xid ); } void set_length( const buffer *openflow_message, uint16_t length ) { ( ( struct ofp_header * ) ( openflow_message->data ) )->length = htons( ( uint16_t ) ( sizeof( struct ofp_header ) + length ) ); } uint16_t get_length( const buffer *openflow_message ) { return ( uint16_t ) ( openflow_message->length - sizeof( struct ofp_vendor_header ) ); } void validate_xid( VALUE xid ) { if ( rb_obj_is_kind_of( xid, rb_cInteger ) != Qtrue ) { rb_raise( rb_eTypeError, "Transaction ID must be an integer" ); } if ( rb_funcall( xid, rb_intern( "unsigned_32bit?" ), 0 ) == Qfalse ) { rb_raise( rb_eArgError, "Transaction ID must be an unsigned 32-bit integer" ); } } /* * Local variables: * c-basic-offset: 2 * indent-tabs-mode: nil * End: */
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
trema-0.2.6 | ruby/trema/trema-ruby-utils.c |
trema-0.2.5 | ruby/trema/trema-ruby-utils.c |
trema-0.2.4 | ruby/trema/trema-ruby-utils.c |
trema-0.2.3 | ruby/trema/trema-ruby-utils.c |