sign: fix and move swapXX into a .h file for reuse
This commit is contained in:
parent
b9fd68f71d
commit
50fec9fa5a
39
common/byteswap.h
Normal file
39
common/byteswap.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright (C) 2010-2016 Srivats P.
|
||||
|
||||
This file is part of "Ostinato"
|
||||
|
||||
This is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef _BYTE_SWAP_H
|
||||
#define _BYTE_SWAP_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
static inline quint32 swap32(quint32 val)
|
||||
{
|
||||
return (((val >> 24) & 0x000000FF) |
|
||||
((val >> 16) & 0x0000FF00) |
|
||||
((val << 16) & 0x00FF0000) |
|
||||
((val << 24) & 0xFF000000));
|
||||
}
|
||||
|
||||
static inline quint16 swap16(quint16 val)
|
||||
{
|
||||
return (((val >> 8) & 0x00FF) |
|
||||
((val << 8) & 0xFF00));
|
||||
}
|
||||
|
||||
#endif
|
@ -31,20 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
#include <QTemporaryFile>
|
||||
#include <QtGlobal>
|
||||
|
||||
static inline quint32 swap32(quint32 val)
|
||||
{
|
||||
return (((val >> 24) && 0x000000FF) |
|
||||
((val >> 16) && 0x0000FF00) |
|
||||
((val << 16) && 0x00FF0000) |
|
||||
((val << 24) && 0xFF000000));
|
||||
}
|
||||
|
||||
static inline quint16 swap16(quint16 val)
|
||||
{
|
||||
return (((val >> 8) && 0x00FF) |
|
||||
((val << 8) && 0xFF00));
|
||||
}
|
||||
|
||||
const quint32 kPcapFileMagic = 0xa1b2c3d4;
|
||||
const quint32 kPcapFileMagicSwapped = 0xd4c3b2a1;
|
||||
const quint16 kPcapFileVersionMajor = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user