Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions abbrev.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static int abbrev_match(const char *, const char *);
* Return 1 if they match.
*/
static int
abbrev_match(tag, pattern)
const char *tag, *pattern;
abbrev_match(const char *tag, const char * pattern)
{
while (*pattern) {
/* '*' matches zero or more non-space characters */
Expand Down Expand Up @@ -81,8 +80,7 @@ abbrev_match(tag, pattern)
* that matches the tag; otherwise return the original tag.
*/
const char *
abbrev_tag(tag)
const char *tag;
abbrev_tag( const char *tag)
{
int i;

Expand All @@ -95,8 +93,7 @@ abbrev_tag(tag)

/* Add an abbreviation pattern to the list of known patterns */
void
abbrev_add(abbrev)
const char *abbrev;
abbrev_add(const char *abbrev)
{
char *name, *pattern, *p;

Expand Down Expand Up @@ -134,9 +131,7 @@ abbrev_add(abbrev)

/* Load the abbreviations listed in the given file */
void
abbrev_add_file(filename, ignore_open_error)
const char *filename;
int ignore_open_error;
abbrev_add_file( const char *filename, int ignore_open_error)
{
FILE *f;
char pattern[1024]; /* XXX arbitrary limit? */
Expand Down
16 changes: 5 additions & 11 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ static void printhelp(void);
/* Return SI unit representation for number x, e.g (3000,"%.1f") -> "3.0k" */
static
const char *
mega(x, fmt)
double x;
const char *fmt;
mega(double x, const char *fmt)
{
static char buf[1024]; /* XXX - arbitrary size */
static char suffix[] = " kMGTPE";
Expand All @@ -139,8 +137,7 @@ mega(x, fmt)

/* Return human-friendly time expression, eg in days, weeks, hours etc. */
static const char *
days(td)
double td;
days(double td)
{
static char buf[1024]; /* XXX - arbitrary size */
unsigned long t = td;
Expand Down Expand Up @@ -179,8 +176,7 @@ days(td)

/* Prepare the display using curses */
void
display_open(device, filter)
const char *device, *filter;
display_open(const char *device, const char *filter)
{

display_device = device;
Expand All @@ -205,8 +201,7 @@ display_close()
}

static void
update_stats(period)
double period;
update_stats(double period)
{
int i;
unsigned long sum;
Expand Down Expand Up @@ -278,8 +273,7 @@ batch_update(double period)

/* Update the display, sorting and drawing all the computed tags */
void
display_update(period)
double period;
display_update(double period)
{
int i, flags, ch;
int maxx, maxy, y, x;
Expand Down
19 changes: 6 additions & 13 deletions ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ struct pppoe_header {
/* Return the tag for an Ethernet II frame */

const char *
ether_tag(p, end)
const char *p;
const char *end;
ether_tag(const char *p, const char *end)
{
struct ether_header eh;
u_int16_t type;
Expand Down Expand Up @@ -119,10 +117,8 @@ pppoe_tag(p, end)
/* Return the tag for an ethernet-like frame, or NULL if unknown */

const char *
ether_tagx(type, p, end)
unsigned int type; /* should be u_int16_t */
const char *p;
const char *end;
ether_tagx(unsigned int type, /* should be u_int16_t */
const char *p, const char *end)
{
/*
* From IEEE Std 802.3 2000 edition:
Expand Down Expand Up @@ -225,8 +221,7 @@ static struct {

/* 802.2 LLC header */
static const char *
llc_tag(p, end)
const char *p, *end;
llc_tag(const char *p, const char *end)
{
/* ANSI/IEEE Std 802.2 section 3.2 LLC PDU format */
struct llc {
Expand Down Expand Up @@ -335,8 +330,7 @@ static struct {

/* Return string form of ethernet type */
static const char *
ethertype(type)
unsigned type;
ethertype(unsigned type)
{
int i;
static char unknown[32];
Expand All @@ -350,8 +344,7 @@ ethertype(type)

/* 802.2 SNAP */
static const char *
snap_tag(p, end)
const char *p, *end;
snap_tag(const char *p, const char *end)
{
u_int8_t *snap_oui; /* [3] */
u_int8_t *snap_type; /* [2] */
Expand Down
25 changes: 7 additions & 18 deletions flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ static int maxflows = 0;

/* Generate a hash value for a tag */
static unsigned int
hash(tag)
const char *tag;
hash(const char *tag)
{
unsigned int result;

Expand All @@ -55,8 +54,7 @@ hash(tag)

/* Find a flow by its tag */
struct flow *
findflow(tag)
const char *tag;
findflow(const char *tag)
{
int i;
unsigned int taghash = hash(tag);
Expand Down Expand Up @@ -98,9 +96,7 @@ findflow(tag)

/* Compare flows by the number of octets they have carried (reverse order) */
int
octetcmp(a, b)
const void *a;
const void *b;
octetcmp(const void *a, const void *b)
{
const struct flow *fa = (const struct flow *)a;
const struct flow *fb = (const struct flow *)b;
Expand All @@ -109,9 +105,7 @@ octetcmp(a, b)

/* Compare flows by their tag */
int
tagcmp(a, b)
const void *a;
const void *b;
tagcmp( const void *a, const void *b)
{
const struct flow *fa = (const struct flow *)a;
const struct flow *fb = (const struct flow *)b;
Expand All @@ -120,9 +114,7 @@ tagcmp(a, b)

/* Compare flows by the time they were last seen (reverse order) */
int
lastcmp(a, b)
const void *a;
const void *b;
lastcmp(const void *a, const void *b)
{
const struct flow *fa = (const struct flow *)a;
const struct flow *fb = (const struct flow *)b;
Expand All @@ -137,9 +129,7 @@ lastcmp(a, b)

/* Compare flows by their packet count (reverse order) */
int
packetcmp(a, b)
const void *a;
const void *b;
packetcmp(const void *a, const void *b)
{
const struct flow *fa = (const struct flow *)a;
const struct flow *fb = (const struct flow *)b;
Expand All @@ -160,8 +150,7 @@ flow_zero()

/* Remove a flow */
void
flow_del(f)
struct flow *f;
flow_del(struct flow *f)
{
int i = f - flows;

Expand Down
70 changes: 18 additions & 52 deletions frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ static void bucket_delete(struct fragtab *fragtab, struct bucket *bucket);

/* Compute a hash index from a key string */
static unsigned int
hash(key, keylen)
const void *key;
int keylen;
hash( const void *key, int keylen)
{
unsigned int h = 0;
unsigned char *p;
Expand All @@ -89,9 +87,7 @@ hash(key, keylen)

/* Remove a bucket from the lru list */
static void
bucket_lru_remove(fragtab, bucket)
struct fragtab *fragtab;
struct bucket *bucket;
bucket_lru_remove(struct fragtab *fragtab, struct bucket *bucket)
{

if (bucket->lru_back)
Expand All @@ -106,9 +102,7 @@ bucket_lru_remove(fragtab, bucket)

/* Place a (removed) bucket at the front of the lru list */
static void
bucket_lru_insert(fragtab, bucket)
struct fragtab *fragtab;
struct bucket *bucket;
bucket_lru_insert(struct fragtab *fragtab, struct bucket *bucket)
{
if (fragtab->lru_first) {
bucket->lru_fwd = fragtab->lru_first;
Expand All @@ -125,8 +119,7 @@ bucket_lru_insert(fragtab, bucket)

/* Unlink and deallocate a fragment */
static void
frag_delete(frag)
struct frag *frag;
frag_delete(struct frag *frag)
{
LIST_REMOVE(frag, ordered);
free(frag);
Expand All @@ -137,9 +130,7 @@ frag_delete(frag)
* should be.
*/
static struct frag **
frag_find(fragp, index)
struct frag **fragp;
u_int32_t index;
frag_find(struct frag **fragp, u_int32_t index)
{
while (*fragp && (*fragp)->index < index)
fragp = &LIST_NEXT(*fragp, ordered);
Expand All @@ -151,9 +142,7 @@ frag_find(fragp, index)
* Returns the end of the chain, if not found.
*/
static struct bucket **
bucket_find(fragtab, key)
struct fragtab *fragtab;
const void *key;
bucket_find(struct fragtab *fragtab, const void *key)
{
struct bucket **bucketp;
unsigned int keyhash;
Expand All @@ -168,10 +157,7 @@ bucket_find(fragtab, key)

/* Create and insert a new bucket */
static void
bucket_create(fragtab, key, dest)
struct fragtab *fragtab;
const void *key;
struct bucket **dest;
bucket_create(struct fragtab *fragtab, const void *key, struct bucket **dest)
{
struct bucket *bucket;
size_t size;
Expand All @@ -191,12 +177,8 @@ bucket_create(fragtab, key, dest)

/* Create and insert a new fragment. */
static void
frag_create(fragtab, data, datalen, index, next_index, dest)
struct fragtab *fragtab;
const void *data;
size_t datalen;
u_int32_t index, next_index;
struct frag **dest;
frag_create(struct fragtab *fragtab, const void *data, size_t datalen,
u_int32_t index, u_int32_t next_index, struct frag **dest)
{
size_t size;
struct frag* frag;
Expand All @@ -215,9 +197,7 @@ frag_create(fragtab, data, datalen, index, next_index, dest)

/* Delete a bucket and all the fragments it contains */
static void
bucket_delete(fragtab, bucket)
struct fragtab *fragtab;
struct bucket *bucket;
bucket_delete(struct fragtab *fragtab, struct bucket *bucket)
{
while (bucket->first_frag)
frag_delete(bucket->first_frag);
Expand All @@ -232,8 +212,7 @@ bucket_delete(fragtab, bucket)
* Allocate an empty fragment table
*/
struct fragtab *
fragtab_new(keylen, maxbuckets)
int keylen, maxbuckets;
fragtab_new(int keylen, int maxbuckets)
{
struct fragtab *fragtab;
int i;
Expand All @@ -256,12 +235,8 @@ fragtab_new(keylen, maxbuckets)
* to the young end of the lru list.
*/
void
fragtab_put(fragtab, key, data, datalen, index, next_index)
struct fragtab *fragtab;
const void *key;
const void *data;
size_t datalen;
u_int32_t index, next_index;
fragtab_put(struct fragtab *fragtab, const void *key, const void *data, size_t datalen,
u_int32_t index, u_int32_t next_index)
{
struct bucket **bucketp, *bucket;
struct frag **fragp;
Expand Down Expand Up @@ -289,11 +264,7 @@ fragtab_put(fragtab, key, data, datalen, index, next_index)
* or return NULL if it doesn't exist yet.
*/
const void *
fragtab_get(fragtab, key, index, datalenp)
struct fragtab *fragtab;
const void *key;
u_int32_t index;
size_t *datalenp;
fragtab_get(struct fragtab *fragtab, const void *key, u_int32_t index, size_t *datalenp)
{
struct bucket *bucket;
struct frag *frag;
Expand All @@ -313,9 +284,7 @@ fragtab_get(fragtab, key, index, datalenp)
* Delete all fragments with the given key
*/
void
fragtab_del(fragtab, key)
struct fragtab *fragtab;
const void *key;
fragtab_del(struct fragtab *fragtab, const void *key)
{
struct bucket *bucket;

Expand All @@ -329,10 +298,8 @@ fragtab_del(fragtab, key)
* ie each fragment's next_index is equal to the next fragment's index
*/
int
fragtab_check(fragtab, key, first_index, last_index)
struct fragtab *fragtab;
const void *key;
u_int32_t first_index, last_index;
fragtab_check(struct fragtab *fragtab, const void *key,
u_int32_t first_index, u_int32_t last_index)
{
struct bucket *bucket;
struct frag *frag;
Expand Down Expand Up @@ -360,8 +327,7 @@ fragtab_check(fragtab, key, first_index, last_index)
* Destroy all storage associated with the fragment table
*/
void
fragtab_free(fragtab)
struct fragtab *fragtab;
fragtab_free(struct fragtab *fragtab)
{
int i;

Expand Down
Loading