Skip to content

Commit ccc433e

Browse files
committed
eth: initial working release
1 parent 8cfd871 commit ccc433e

File tree

27 files changed

+1147
-155
lines changed

27 files changed

+1147
-155
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
src/parser.c
33
*.o
44
tmp
5+

COPYING

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

Rakefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
#
2+
# Copyright (C) 2014 jibi <[email protected]>
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
#
18+
119
require 'rake'
220
require 'rake/clean'
321

htdocs/file

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Hi. This is ETH.
2+
And this is a phisical file.
3+
4+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
5+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
6+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
7+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
8+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
9+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
10+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
11+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
12+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
13+
14+
(we should go ahead the 1500 MTU)
15+
16+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
17+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
18+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
19+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
20+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
21+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
22+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
23+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
24+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
25+
26+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
27+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
28+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
29+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
30+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
31+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
32+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
33+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
34+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
35+
36+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
37+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
38+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
39+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
40+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
41+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
42+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
43+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
44+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
45+
46+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
47+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
48+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
49+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
50+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
51+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
52+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
53+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
54+
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
55+
56+
test.
57+

include/eth.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_H
20+
#define _ETH_H
21+
122
#ifndef likely
223
#define likely(x) __builtin_expect(!!(x), 1)
324
#define unlikely(x) __builtin_expect(!!(x), 0)
425
#endif
526

27+
#endif
28+

include/eth/exotcp.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
#ifndef _EXOTCP_H
2-
#define _EXOTCP_H
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_EXOTCP_H
20+
#define _ETH_EXOTCP_H
321

422
#include <stdint.h>
523
#include <stddef.h>

include/eth/exotcp/arp.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_EXOTCP_ARP_H
20+
#define _ETH_EXOTCP_ARP_H
21+
122
#include <stdint.h>
223

324
#include <eth/exotcp.h>
@@ -24,3 +45,5 @@ void init_arp();
2445
void process_arp(packet_t *p);
2546
void dump_arp_hdr(arp_hdr_t *hdr);
2647

48+
#endif
49+

include/eth/exotcp/checksum.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_EXOTCP_CHECKSUM_H
20+
#define _ETH_EXOTCP_CHECKSUM_H
21+
122
#include <stdlib.h>
223
#include <stdint.h>
324

@@ -10,3 +31,5 @@ uint16_t checksum(const uint8_t *buf, uint32_t size);
1031
uint32_t partial_checksum(uint32_t sum, const uint8_t *buf, uint32_t size);
1132
uint16_t finalize_checksum(uint32_t sum, const uint8_t *buf, uint32_t size);
1233

34+
#endif
35+

include/eth/exotcp/eth.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_EXOTCP_ETH_H
20+
#define _ETH_EXOTCP_ETH_H
21+
22+
123
#include <stddef.h>
224

325
#include <netinet/ether.h>
@@ -16,8 +38,12 @@ typedef struct eth_hdr_s {
1638
#define ETH_TYPE_IPV4 HTONS(0x0800)
1739
#define ETH_TYPE_ARP HTONS(0x0806)
1840

41+
#define ETH_MTU (1500 - sizeof(eth_hdr_t))
42+
1943
void process_eth(char *packet_buf, size_t len);
2044
void dump_eth_hdr(eth_hdr_t *hdr);
2145
char *format_eth_addr(unsigned char *a);
2246
int is_broadcast_addr(struct ether_addr *a);
2347

48+
#endif
49+

include/eth/exotcp/hash.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
/*
2+
* Copyright (C) 2014 jibi <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
19+
#ifndef _ETH_EXOTCP_HASH_H
20+
#define _ETH_EXOTCP_HASH_H
21+
122
#include <stdint.h>
223
#include <glib.h>
324

425
uint32_t murmur_hash( const void * key, int len, uint32_t seed );
526
guint hash_tcp_conn(gconstpointer t);
627
gboolean cmp_tcp_conn(gconstpointer t1, gconstpointer t2);
728

29+
#endif
30+

0 commit comments

Comments
 (0)