dpdk 0.0.1

A wrapper around DPDK
// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2017 The developers of dpdk. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT.


#[allow(trivial_casts)]
#[inline(always)]
pub fn ipV4HostAddressToMappedIpV6HostAddress(ipV4HostAddress: IpV4HostAddress) -> IpV6HostAddress
{
	const TemplateSize: usize = 12;
	static Template: [u8; TemplateSize] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF];
	
	unsafe
	{
		let mut result: IpV6HostAddress = uninitialized();
		
		copy_nonoverlapping(&Template as *const _ as *const u8, result.get_unchecked_mut(0), TemplateSize);
		
		#[cfg(target_endian = "little")]
		{
			let swapped = ipV4HostAddress.to_be();
			copy_nonoverlapping(&swapped as *const _ as *const u8, result.get_unchecked_mut(TemplateSize), SizeOfIpV4HostAddress);
		}
		#[cfg(target_endian = "big")]
		{
			copy_nonoverlapping(&ipV4HostAddress as *const _ as *const u8, *result.get_unchecked_mut(TemplateSize), SizeOfIpV4HostAddress);
		}
		
		result
	}
}