ostinato-0.5.1/ 0000700 0001753 0001001 00000000000 12005505763 012672 5 ustar srivatsp None ostinato-0.5.1/.vimrc 0000700 0001753 0001001 00000000116 12005505614 014007 0 ustar srivatsp None set shiftwidth=4
set tabstop=8
set softtabstop=4
set expandtab
set cindent
ostinato-0.5.1/client/ 0000700 0001753 0001001 00000000000 12005505614 014143 5 ustar srivatsp None ostinato-0.5.1/client/about.ui 0000700 0001753 0001001 00000013705 12005505614 015625 0 ustar srivatsp None
About
0
0
500
327
0
0
About Ostinato
-
0
Ostinato
-
-
0
0
:/icons/logo.png
false
Qt::AlignCenter
-
-
Qt::Vertical
20
21
-
:/icons/name.png
Qt::AlignCenter
-
Version/Revision Placeholder
Qt::AlignCenter
-
Copyright (c) 2007-2012 Srivats P.
Qt::AlignCenter
-
Qt::Vertical
20
21
-
Logo (c): Dhiman Sengupta
Icons (c): Mark James (http://www.famfamfam.com/lab/icons/silk/)
Qt::AlignCenter
License
-
<p>This program 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.</p><p>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.</p><p>You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a></p>
Qt::RichText
Qt::AlignCenter
true
-
Qt::Horizontal
QDialogButtonBox::Ok
buttonBox
accepted()
About
accept()
353
280
286
262
ostinato-0.5.1/client/dumpview.cpp 0000700 0001753 0001001 00000027226 12005505614 016523 0 ustar srivatsp None /*
Copyright (C) 2010 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
*/
#include "dumpview.h"
//! \todo Enable Scrollbars
DumpView::DumpView(QWidget *parent)
: QAbstractItemView(parent)
{
int w, h;
// NOTE: Monospaced fonts only !!!!!!!!!!!
setFont(QFont("Courier"));
w = fontMetrics().width('X');
h = fontMetrics().height();
mLineHeight = h;
mCharWidth = w;
mSelectedRow = mSelectedCol = -1;
// calculate width for offset column and the whitespace that follows it
// 0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
mOffsetPaneTopRect = QRect(0, 0, w*4, h);
mDumpPaneTopRect = QRect(mOffsetPaneTopRect.right()+w*3, 0,
w*((8*3-1)+2+(8*3-1)), h);
mAsciiPaneTopRect = QRect(mDumpPaneTopRect.right()+w*3, 0,
w*(8+1+8), h);
qDebug("DumpView::DumpView");
}
QModelIndex DumpView::indexAt(const QPoint &/*point*/) const
{
#if 0
int x = point.x();
int row, col;
if (x > mAsciiPaneTopRect.left())
{
col = (x - mAsciiPaneTopRect.left()) / mCharWidth;
if (col == 8) // don't select whitespace
goto _exit;
else if (col > 8) // adjust for whitespace
col--;
}
else if (x > mDumpPaneTopRect.left())
{
col = (x - mDumpPaneTopRect.left()) / (mCharWidth*3);
}
row = point.y()/mLineHeight;
if ((col < 16) && (row < ((data.size()+16)/16)))
{
selrow = row;
selcol = col;
}
else
goto _exit;
// last row check col
if ((row == (((data.size()+16)/16) - 1)) && (col >= (data.size() % 16)))
goto _exit;
qDebug("dumpview::selection(%d, %d)", selrow, selcol);
offset = selrow * 16 + selcol;
#if 0
for(int i = 0; i < model()->rowCount(parent); i++)
{
QModelIndex index = model()->index(i, 0, parent);
if (model()->hasChildren(index))
indexAtOffset(offset, index); // Non Leaf
else
if (
dump.append(model()->data(index, Qt::UserRole).toByteArray()); // Leaf
// FIXME: Use RawValueRole instead of UserRole
}
#endif
}
_exit:
// Clear existing selection
selrow = -1;
#endif
return QModelIndex();
}
void DumpView::scrollTo(const QModelIndex &/*index*/, ScrollHint /*hint*/)
{
// FIXME: implement scrolling
}
QRect DumpView::visualRect(const QModelIndex &/*index*/) const
{
// FIXME: calculate actual rect
return rect();
}
//protected:
int DumpView::horizontalOffset() const
{
return horizontalScrollBar()->value();
}
bool DumpView::isIndexHidden(const QModelIndex &/*index*/) const
{
return false;
}
QModelIndex DumpView::moveCursor(CursorAction /*cursorAction*/,
Qt::KeyboardModifiers /*modifiers*/)
{
// FIXME(MED): need to implement movement using cursor
return currentIndex();
}
void DumpView::setSelection(const QRect &/*rect*/,
QItemSelectionModel::SelectionFlags flags)
{
// FIXME(HI): calculate indexes using rect
selectionModel()->select(QModelIndex(), flags);
}
int DumpView::verticalOffset() const
{
return verticalScrollBar()->value();
}
QRegion DumpView::visualRegionForSelection(
const QItemSelection &/*selection*/) const
{
// FIXME(HI)
return QRegion(rect());
}
//protected slots:
void DumpView::dataChanged(const QModelIndex &/*topLeft*/,
const QModelIndex &/*bottomRight*/)
{
// FIXME(HI)
update();
}
void DumpView::selectionChanged(const QItemSelection &/*selected*/,
const QItemSelection &/*deselected*/)
{
// FIXME(HI)
update();
}
void DumpView::populateDump(QByteArray &dump, int &selOfs, int &selSize,
QModelIndex parent)
{
// FIXME: Use new enum instead of Qt::UserRole
//! \todo (low): generalize this for any model not just our pkt model
Q_ASSERT(!parent.isValid());
qDebug("!!!! %d $$$$", dump.size());
for(int i = 0; i < model()->rowCount(parent); i++)
{
QModelIndex index = model()->index(i, 0, parent);
Q_ASSERT(index.isValid());
// Assumption: protocol data is in bytes (not bits)
qDebug("%d: %d bytes", i, model()->data(index, Qt::UserRole).toByteArray().size());
dump.append(model()->data(index, Qt::UserRole).toByteArray());
}
if (selectionModel()->selectedIndexes().size())
{
int j, bits;
QModelIndex index;
Q_ASSERT(selectionModel()->selectedIndexes().size() == 1);
index = selectionModel()->selectedIndexes().at(0);
if (index.parent().isValid())
{
// Field
// SelOfs = SUM(protocol sizes before selected field's protocol) +
// SUM(field sizes before selected field)
selOfs = 0;
j = index.parent().row() - 1;
while (j >= 0)
{
selOfs += model()->data(index.parent().sibling(j,0),
Qt::UserRole).toByteArray().size();
j--;
}
bits = 0;
j = index.row() - 1;
while (j >= 0)
{
bits += model()->data(index.sibling(j,0), Qt::UserRole+1).
toInt();
j--;
}
selOfs += bits/8;
selSize = model()->data(index, Qt::UserRole).toByteArray().size();
}
else
{
// Protocol
selOfs = 0;
j = index.row() - 1;
while (j >= 0)
{
selOfs += model()->data(index.sibling(j,0), Qt::UserRole).
toByteArray().size();
j--;
}
selSize = model()->data(index, Qt::UserRole).toByteArray().size();
}
}
}
// TODO(LOW): rewrite this function - it's a mess!
void DumpView::paintEvent(QPaintEvent* /*event*/)
{
QStylePainter painter(viewport());
QRect offsetRect = mOffsetPaneTopRect;
QRect dumpRect = mDumpPaneTopRect;
QRect asciiRect = mAsciiPaneTopRect;
QPalette pal = palette();
static QByteArray data;
//QByteArray ba;
int selOfs = -1, selSize;
int curSelOfs, curSelSize;
qDebug("dumpview::paintEvent");
// FIXME(LOW): unable to set the self widget's font in constructor
painter.setFont(QFont("Courier"));
// set a white background
painter.fillRect(rect(), QBrush(QColor(Qt::white)));
if (model())
{
data.clear();
populateDump(data, selOfs, selSize);
}
// display the offset, dump and ascii panes 8 + 8 bytes on a line
for (int i = 0; i < data.size(); i+=16)
{
QString dumpStr, asciiStr;
//ba = data.mid(i, 16);
// display offset
painter.drawItemText(offsetRect, Qt::AlignLeft | Qt::AlignTop, pal,
true, QString("%1").arg(i, 4, 16, QChar('0')), QPalette::WindowText);
// construct the dumpStr and asciiStr
for (int j = i; (j < (i+16)) && (j < data.size()); j++)
{
unsigned char c = data.at(j);
// extra space after 8 bytes
if (((j+8) % 16) == 0)
{
dumpStr.append(" ");
asciiStr.append(" ");
}
dumpStr.append(QString("%1").arg((uint)c, 2, 16, QChar('0')).
toUpper()).append(" ");
if (isPrintable(c))
asciiStr.append(QChar(c));
else
asciiStr.append(QChar('.'));
}
// display dump
painter.drawItemText(dumpRect, Qt::AlignLeft | Qt::AlignTop, pal,
true, dumpStr, QPalette::WindowText);
// display ascii
painter.drawItemText(asciiRect, Qt::AlignLeft | Qt::AlignTop, pal,
true, asciiStr, QPalette::WindowText);
// if no selection, skip selection painting
if (selOfs < 0)
goto _next;
// Check overlap between current row and selection
{
QRect r1(i, 0, qMin(16, data.size()-i), 8);
QRect s1(selOfs, 0, selSize, 8);
if (r1.intersects(s1))
{
QRect t = r1.intersected(s1);
curSelOfs = t.x();
curSelSize = t.width();
}
else
curSelSize = 0;
}
// overpaint selection on current row (if any)
if (curSelSize > 0)
{
QRect r;
QString selectedAsciiStr, selectedDumpStr;
qDebug("dumpview::paintEvent - Highlighted (%d, %d)",
curSelOfs, curSelSize);
// construct the dumpStr and asciiStr
for (int k = curSelOfs; (k < (curSelOfs + curSelSize)); k++)
{
unsigned char c = data.at(k);
// extra space after 8 bytes
if (((k+8) % 16) == 0)
{
// Avoid adding space at the start for fields starting
// at second column 8 byte boundary
if (k!=curSelOfs)
{
selectedDumpStr.append(" ");
selectedAsciiStr.append(" ");
}
}
selectedDumpStr.append(QString("%1").arg((uint)c, 2, 16,
QChar('0')).toUpper()).append(" ");
if (isPrintable(c))
selectedAsciiStr.append(QChar(c));
else
selectedAsciiStr.append(QChar('.'));
}
// display dump
r = dumpRect;
if ((curSelOfs - i) < 8)
r.translate(mCharWidth*(curSelOfs-i)*3, 0);
else
r.translate(mCharWidth*((curSelOfs-i)*3+1), 0);
// adjust width taking care of selection stretching between
// the two 8byte columns
if (( (curSelOfs-i) < 8 ) && ( (curSelOfs-i+curSelSize) > 8 ))
r.setWidth((curSelSize * 3 + 1) * mCharWidth);
else
r.setWidth((curSelSize * 3) * mCharWidth);
painter.fillRect(r, pal.highlight());
painter.drawItemText(r, Qt::AlignLeft | Qt::AlignTop, pal,
true, selectedDumpStr, QPalette::HighlightedText);
// display ascii
r = asciiRect;
if ((curSelOfs - i) < 8)
r.translate(mCharWidth*(curSelOfs-i)*1, 0);
else
r.translate(mCharWidth*((curSelOfs-i)*1+1), 0);
// adjust width taking care of selection stretching between
// the two 8byte columns
if (( (curSelOfs-i) < 8 ) && ( (curSelOfs-i+curSelSize) > 8 ))
r.setWidth((curSelSize * 1 + 1) * mCharWidth);
else
r.setWidth((curSelSize * 1) * mCharWidth);
painter.fillRect(r, pal.highlight());
painter.drawItemText(r, Qt::AlignLeft | Qt::AlignTop, pal,
true, selectedAsciiStr, QPalette::HighlightedText);
}
_next:
// move the rects down
offsetRect.translate(0, mLineHeight);
dumpRect.translate(0, mLineHeight);
asciiRect.translate(0, mLineHeight);
}
}
ostinato-0.5.1/client/dumpview.h 0000700 0001753 0001001 00000004067 12005505614 016166 0 ustar srivatsp None /*
Copyright (C) 2010 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
*/
#include // FIXME: High
class DumpView: public QAbstractItemView
{
public:
DumpView(QWidget *parent=0);
QModelIndex indexAt( const QPoint &point ) const;
void scrollTo( const QModelIndex &index, ScrollHint hint = EnsureVisible );
QRect visualRect( const QModelIndex &index ) const;
protected:
int horizontalOffset() const;
bool isIndexHidden( const QModelIndex &index ) const;
QModelIndex moveCursor( CursorAction cursorAction,
Qt::KeyboardModifiers modifiers );
void setSelection( const QRect &rect, QItemSelectionModel::SelectionFlags flags );
int verticalOffset() const;
QRegion visualRegionForSelection( const QItemSelection &selection ) const;
protected slots:
void dataChanged( const QModelIndex &topLeft,
const QModelIndex &bottomRight );
void selectionChanged( const QItemSelection &selected,
const QItemSelection &deselected );
void paintEvent(QPaintEvent *event);
private:
void populateDump(QByteArray &dump, int &selOfs, int &selSize,
QModelIndex parent = QModelIndex());
bool inline isPrintable(char c)
{if ((c > 48) && (c < 126)) return true; else return false; }
private:
QRect mOffsetPaneTopRect;
QRect mDumpPaneTopRect;
QRect mAsciiPaneTopRect;
int mSelectedRow, mSelectedCol;
int mLineHeight;
int mCharWidth;
};
ostinato-0.5.1/client/hexlineedit.cpp 0000700 0001753 0001001 00000004467 12005505614 017167 0 ustar srivatsp None /*
Copyright (C) 2010 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
*/
#include "hexlineedit.h"
#include "qdebug.h"
QString & uintToHexStr(quint64 num, QString &hexStr, quint8 octets);
HexLineEdit::HexLineEdit( QWidget * parent)
: QLineEdit(parent)
{
//QLineEdit::QLineEdit(parent);
}
void HexLineEdit::focusOutEvent(QFocusEvent* /*e*/)
{
#if 0
const QValidator *v = validator();
if ( v )
{
int curpos = cursorPosition();
QString str = text();
if ( v->validate( str, curpos ) == QValidator::Acceptable )
{
if ( curpos != cursorPosition() )
setCursorPosition( curpos );
if ( str != text() )
setText( str );
}
else
{
if ( curpos != cursorPosition() )
setCursorPosition( curpos );
str = text();
v->fixup( str );
if ( str != text() )
{
setText( str );
}
}
}
QLineEdit::focusOutEvent( e );
emit focusOut();
#else
#define uintToHexStr(num, bytesize) \
QString("%1").arg((num), (bytesize)*2 , 16, QChar('0'))
bool isOk;
ulong num;
qDebug("before = %s\n", text().toAscii().data());
num = text().remove(QChar(' ')).toULong(&isOk, 16);
setText(uintToHexStr(num, 4));
qDebug("after = %s\n", text().toAscii().data());
#undef uintToHexStr
#endif
}
#if 0
void HexLineEdit::focusInEvent( QFocusEvent *e )
{
QLineEdit::focusInEvent( e );
emit focusIn();
}
void HexLineEdit::keyPressEvent( QKeyEvent *e )
{
QLineEdit::keyPressEvent( e );
if ( e->key() == Key_Enter || e->key() == Key_Return )
{
setSelection( 0, text().length() );
}
}
#endif
ostinato-0.5.1/client/hexlineedit.h 0000700 0001753 0001001 00000002044 12005505614 016621 0 ustar srivatsp None /*
Copyright (C) 2010 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
*/
#ifndef _HEXLINEEDIT
#define _HEXLINEEDIT
#include
class HexLineEdit : public QLineEdit
{
Q_OBJECT
public:
// Constructors
HexLineEdit ( QWidget * parent);
protected:
void focusOutEvent( QFocusEvent *e );
//void focusInEvent( QFocusEvent *e );
//void keyPressEvent( QKeyEvent *e );
signals:
//void focusIn();
void focusOut();
};
#endif
ostinato-0.5.1/client/icons/ 0000700 0001753 0001001 00000000000 12005505614 015256 5 ustar srivatsp None ostinato-0.5.1/client/icons/about.png 0000700 0001753 0001001 00000002014 12005505614 017076 0 ustar srivatsp None PNG
IHDR szz sRGB bKGD pHYs tIME v IDATXýWq:ܿ
DwTvP v,An@{?ESoaFep ,0u]"R
lg( @ p\FUUރ@D9E !xB] "!ཇR
Dj|>)%///F|c+Z 1Da |>G}p^QUa`s1Zk 8u@bG , RZcYxc36D)gig<@k#BDLj~
J9dB9v5 ]nƘ} 0fH):>e~Z)eB-rq7[%FA Àmc^yx41Oy"S 3G" ipq===ݤMB Jsh&
KG\34@{}[5~~~85,3erUU}jW]4{bd]K&leƦιM!B/c3*t:skRY9r\v9p*{Bd,X˲Kp~QԶ-m*:NB !u]Gu5⾵'"a⺮S)Mm[^!h4ͪMY|R6p3f꺎╷] ιX&H)7ekm9r>\.ݎiY~Oe#7@ ooo "t]RG[ JrlͅdHW 4M y<#x2۬v0CtK3 Z[ G7Jn#c̶