Sha256: decbf921890a25bd1670cf31697ce67f35e556fc53e4f8be8738e3ff3c10c5a4

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

/*
 * Author: Kazuya Suzuki
 *
 * 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 <assert.h>
#include "checks.h"
#include "log.h"
#include "packet_info.h"
#include "wrapper.h"


uint16_t
fill_ether_padding( buffer *buf ) {
  die_if_NULL( buf );
  size_t padding_length = 0;

  if ( buf->length + ETH_FCS_LENGTH < ETH_MINIMUM_LENGTH ) {
    padding_length = ETH_MINIMUM_LENGTH - buf->length - ETH_FCS_LENGTH;
    debug( "Adding %u octets padding ( original frame length = %u ).", 
           buf->length, padding_length );
    void *padding = append_back_buffer( buf, padding_length );
    memset( padding, 0, padding_length );
  }
  return ( uint16_t ) padding_length;
}


/*
 * Local variables:
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * End:
 */

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trema-0.2.5 src/lib/ether.c
trema-0.2.4 src/lib/ether.c
trema-0.2.3 src/lib/ether.c