Skip to content

Commit c4cd169

Browse files
committed
Merge pull request appneta#214 from appneta/4.1.1-beta2
remove unused code
2 parents 87ba93d + d0a7ca2 commit c4cd169

File tree

10 files changed

+8
-159
lines changed

10 files changed

+8
-159
lines changed

src/common/sendpacket.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ sendpacket_open_tuntap(const char *device, char *errbuf)
831831
{
832832
sendpacket_t *sp;
833833
struct ifreq ifr;
834-
int flags = 0;
835834
int tapfd;
836835

837836
assert(device);

src/tcpedit/plugins/dlt_en10mb/en10mb.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,14 @@ dlt_en10mb_parse_opts(tcpeditdlt_t *ctx)
269269
int
270270
dlt_en10mb_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
271271
{
272-
tcpeditdlt_plugin_t *plugin = NULL;
273272
struct tcpr_ethernet_hdr *eth = NULL;
274273
struct tcpr_802_1q_hdr *vlan = NULL;
275274
en10mb_extra_t *extra = NULL;
276-
en10mb_config_t *config = NULL;
277275

278276
assert(ctx);
279277
assert(packet);
280278
assert(pktlen >= 14);
281279

282-
plugin = tcpedit_dlt_getplugin(ctx, dlt_value);
283-
config = plugin->config;
284-
285280
/* get our src & dst address */
286281
eth = (struct tcpr_ethernet_hdr *)packet;
287282
memcpy(&(ctx->dstaddr.ethernet), eth, ETHER_ADDR_LEN);

src/tcpedit/plugins/dlt_ieee80211/ieee80211.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ int
101101
dlt_ieee80211_init(tcpeditdlt_t *ctx)
102102
{
103103
tcpeditdlt_plugin_t *plugin;
104-
ieee80211_config_t *config;
105104
assert(ctx);
106105

107106
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
@@ -116,9 +115,7 @@ dlt_ieee80211_init(tcpeditdlt_t *ctx)
116115
/* allocate memory for our config data */
117116
if (sizeof(ieee80211_config_t) > 0)
118117
plugin->config = safe_malloc(sizeof(ieee80211_config_t));
119-
120-
config = (ieee80211_config_t *)plugin->config;
121-
118+
122119
/* FIXME: set default config values here */
123120

124121
return TCPEDIT_OK; /* success */

src/tcpedit/plugins/dlt_jnpr_ether/jnpr_ether.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ int
109109
dlt_jnpr_ether_init(tcpeditdlt_t *ctx)
110110
{
111111
tcpeditdlt_plugin_t *plugin;
112-
jnpr_ether_config_t *config;
113112
assert(ctx);
114113

115114
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
@@ -124,9 +123,7 @@ dlt_jnpr_ether_init(tcpeditdlt_t *ctx)
124123
/* allocate memory for our config data */
125124
if (sizeof(jnpr_ether_config_t) > 0)
126125
plugin->config = safe_malloc(sizeof(jnpr_ether_config_t));
127-
128-
config = (jnpr_ether_config_t *)plugin->config;
129-
126+
130127
return TCPEDIT_OK; /* success */
131128
}
132129

src/tcpedit/plugins/dlt_linuxsll/linuxsll.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ int
9696
dlt_linuxsll_init(tcpeditdlt_t *ctx)
9797
{
9898
tcpeditdlt_plugin_t *plugin;
99-
linuxsll_config_t *config;
10099
assert(ctx);
101100

102101
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
@@ -112,7 +111,6 @@ dlt_linuxsll_init(tcpeditdlt_t *ctx)
112111
if (sizeof(linuxsll_config_t) > 0)
113112
plugin->config = safe_malloc(sizeof(linuxsll_config_t));
114113

115-
config = (linuxsll_config_t *)plugin->config;
116114

117115
return TCPEDIT_OK; /* success */
118116
}

src/tcpedit/plugins/dlt_pppserial/pppserial.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ int
108108
dlt_pppserial_init(tcpeditdlt_t *ctx)
109109
{
110110
tcpeditdlt_plugin_t *plugin;
111-
pppserial_config_t *config;
112111
assert(ctx);
113112

114113
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
@@ -123,9 +122,7 @@ dlt_pppserial_init(tcpeditdlt_t *ctx)
123122
/* allocate memory for our config data */
124123
if (sizeof(pppserial_config_t) > 0)
125124
plugin->config = safe_malloc(sizeof(pppserial_config_t));
126-
127-
config = (pppserial_config_t *)plugin->config;
128-
125+
129126
/* FIXME: set default config values here */
130127

131128
return TCPEDIT_OK; /* success */
@@ -214,7 +211,6 @@ dlt_pppserial_parse_opts(tcpeditdlt_t *ctx)
214211
int
215212
dlt_pppserial_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
216213
{
217-
tcpeditdlt_plugin_t *plugin = NULL;
218214
struct tcpr_pppserial_hdr *ppp = NULL;
219215

220216
assert(ctx);
@@ -227,7 +223,6 @@ dlt_pppserial_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
227223
* protocol field informs you of the following header, but alas does not
228224
* use standard IEEE 802.11 values (IPv4 is not 0x0800, but is 0x0021)
229225
*/
230-
plugin = tcpedit_dlt_getplugin(ctx, dlt_value);
231226
ppp = (struct tcpr_pppserial_hdr *)packet;
232227
switch (ntohs(ppp->protocol)) {
233228
case 0x0021: /* IPv4 */
@@ -273,15 +268,13 @@ dlt_pppserial_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir
273268
int
274269
dlt_pppserial_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
275270
{
276-
tcpeditdlt_plugin_t *plugin = NULL;
277271
struct tcpr_pppserial_hdr *ppp = NULL;
278272
int protocol = 0;
279273

280274
assert(ctx);
281275
assert(packet);
282276
assert(pktlen > 4);
283277

284-
plugin = tcpedit_dlt_getplugin(ctx, dlt_value);
285278
ppp = (struct tcpr_pppserial_hdr *)packet;
286279
switch (ntohs(ppp->protocol)) {
287280
case 0x0021: /* IPv4 */

src/tcpedit/plugins/dlt_radiotap/radiotap.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,21 @@ int
102102
dlt_radiotap_init(tcpeditdlt_t *ctx)
103103
{
104104
tcpeditdlt_plugin_t *plugin;
105-
radiotap_config_t *config;
106105
assert(ctx);
107-
106+
108107
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
109108
tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name);
110109
return TCPEDIT_ERROR;
111110
}
112-
111+
113112
/* allocate memory for our deocde extra data */
114113
if (sizeof(radiotap_extra_t) > 0)
115114
ctx->decoded_extra = safe_malloc(sizeof(radiotap_extra_t));
116115

117116
/* allocate memory for our config data */
118117
if (sizeof(radiotap_config_t) > 0)
119118
plugin->config = safe_malloc(sizeof(radiotap_config_t));
120-
121-
config = (radiotap_config_t *)plugin->config;
122119

123-
124120
return TCPEDIT_OK; /* success */
125121
}
126122

src/tcpedit/plugins/dlt_raw/raw.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,21 @@ int
9797
dlt_raw_init(tcpeditdlt_t *ctx)
9898
{
9999
tcpeditdlt_plugin_t *plugin;
100-
raw_config_t *config;
101100
assert(ctx);
102-
101+
103102
if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
104103
tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name);
105104
return TCPEDIT_ERROR;
106105
}
107-
106+
108107
/* allocate memory for our deocde extra data */
109108
if (sizeof(raw_extra_t) > 0)
110109
ctx->decoded_extra = safe_malloc(sizeof(raw_extra_t));
111110

112111
/* allocate memory for our config data */
113112
if (sizeof(raw_config_t) > 0)
114113
plugin->config = safe_malloc(sizeof(raw_config_t));
115-
116-
config = (raw_config_t *)plugin->config;
117-
114+
118115
return TCPEDIT_OK; /* success */
119116
}
120117

src/tcpprep.c

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ void print_stats(const char *);
7272
static int check_ipv4_regex(const unsigned long ip);
7373
static int check_ipv6_regex(const struct tcpr_in6_addr *addr);
7474
static COUNTER process_raw_packets(pcap_t * pcap);
75-
static int check_dst_port(ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr, int len);
7675

7776

7877
/*
@@ -201,79 +200,6 @@ main(int argc, char *argv[])
201200

202201
}
203202

204-
205-
/**
206-
* checks the dst port to see if this is destined for a server port.
207-
* returns 1 for true, 0 for false
208-
*/
209-
static int
210-
check_dst_port(ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr, int len)
211-
{
212-
tcp_hdr_t *tcp_hdr = NULL;
213-
udp_hdr_t *udp_hdr = NULL;
214-
tcpprep_opt_t *options = tcpprep->options;
215-
uint8_t proto;
216-
u_char *l4;
217-
218-
if (ip_hdr) {
219-
if (len < ((ip_hdr->ip_hl * 4) + 4))
220-
return 0; /* not enough data in the packet to know */
221-
222-
proto = ip_hdr->ip_p;
223-
l4 = get_layer4_v4(ip_hdr, len);
224-
} else if (ip6_hdr) {
225-
if (len < (TCPR_IPV6_H + 4))
226-
return 0; /* not enough data in the packet to know */
227-
228-
proto = get_ipv6_l4proto(ip6_hdr, len);
229-
dbgx(3, "Our layer4 proto is 0x%hhu", proto);
230-
if ((l4 = get_layer4_v6(ip6_hdr, len)) == NULL)
231-
return 0;
232-
233-
dbgx(3, "Found proto %u at offset %p. base %p (%p)", proto, (void *)l4, (void *)ip6_hdr, (void*)(l4 - (u_char *)ip6_hdr));
234-
} else {
235-
assert(0);
236-
}
237-
238-
dbg(3, "Checking the destination port...");
239-
240-
switch(proto) {
241-
case IPPROTO_TCP:
242-
tcp_hdr = (tcp_hdr_t *)l4;
243-
244-
/* is a service? */
245-
if (options->services.tcp[ntohs(tcp_hdr->th_dport)]) {
246-
dbgx(1, "TCP packet is destined for a server port: %d", ntohs(tcp_hdr->th_dport));
247-
return 1;
248-
}
249-
250-
/* nope */
251-
dbgx(1, "TCP packet is NOT destined for a server port: %d", ntohs(tcp_hdr->th_dport));
252-
return 0;
253-
break;
254-
255-
case IPPROTO_UDP:
256-
udp_hdr = (udp_hdr_t *)l4;
257-
258-
/* is a service? */
259-
if (options->services.udp[ntohs(udp_hdr->uh_dport)]) {
260-
dbgx(1, "UDP packet is destined for a server port: %d", ntohs(udp_hdr->uh_dport));
261-
return 1;
262-
}
263-
264-
/* nope */
265-
dbgx(1, "UDP packet is NOT destined for a server port: %d", ntohs(udp_hdr->uh_dport));
266-
return 0;
267-
break;
268-
269-
default:
270-
/* not a TCP or UDP packet... return as non_ip */
271-
dbg(1, "Packet isn't a UDP or TCP packet... no port to process.");
272-
return options->nonip;
273-
}
274-
}
275-
276-
277203
/**
278204
* checks to see if an ip address matches a regex. Returns 1 for true
279205
* 0 for false
@@ -329,7 +255,6 @@ process_raw_packets(pcap_t * pcap)
329255
struct pcap_pkthdr pkthdr;
330256
const u_char *pktdata = NULL;
331257
COUNTER packetnum = 0;
332-
int l2len, cache_result = 0;
333258
u_char ipbuff[MAXPACKET], *buffptr;
334259
tcpr_dir_t direction = TCPR_DIR_ERROR;
335260
tcpprep_opt_t *options = tcpprep->options;
@@ -395,8 +320,6 @@ process_raw_packets(pcap_t * pcap)
395320
/* go to next packet */
396321
continue;
397322
}
398-
399-
l2len = get_l2len(pktdata, pkthdr.caplen, pcap_datalink(pcap));
400323

401324
/* look for include or exclude CIDR match */
402325
if (options->xX.cidr != NULL) {
@@ -427,7 +350,6 @@ process_raw_packets(pcap_t * pcap)
427350
if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C))
428351
direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S;
429352

430-
cache_result = add_cache(&options->cachedata, SEND, direction);
431353
break;
432354

433355
case CIDR_MODE:
@@ -442,7 +364,6 @@ process_raw_packets(pcap_t * pcap)
442364
if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C))
443365
direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S;
444366

445-
cache_result = add_cache(&options->cachedata, SEND, direction);
446367
break;
447368

448369
case MAC_MODE:
@@ -453,7 +374,6 @@ process_raw_packets(pcap_t * pcap)
453374
if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C))
454375
direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S;
455376

456-
cache_result = add_cache(&options->cachedata, SEND, direction);
457377
break;
458378

459379
case AUTO_MODE:
@@ -480,13 +400,6 @@ process_raw_packets(pcap_t * pcap)
480400
* based cache
481401
*/
482402
dbg(2, "processing second pass of auto: router mode...");
483-
if (ip_hdr) {
484-
cache_result = add_cache(&options->cachedata, SEND,
485-
check_ip_tree(options->nonip, ip_hdr->ip_src.s_addr));
486-
} else {
487-
cache_result = add_cache(&options->cachedata, SEND,
488-
check_ip6_tree(options->nonip, &ip6_hdr->ip_src));
489-
}
490403
break;
491404

492405
case BRIDGE_MODE:
@@ -495,13 +408,6 @@ process_raw_packets(pcap_t * pcap)
495408
* based cache
496409
*/
497410
dbg(2, "processing second pass of auto: bridge mode...");
498-
if (ip_hdr) {
499-
cache_result = add_cache(&options->cachedata, SEND,
500-
check_ip_tree(DIR_UNKNOWN, ip_hdr->ip_src.s_addr));
501-
} else {
502-
cache_result = add_cache(&options->cachedata, SEND,
503-
check_ip6_tree(DIR_UNKNOWN, &ip6_hdr->ip_src));
504-
}
505411
break;
506412

507413
case SERVER_MODE:
@@ -510,13 +416,6 @@ process_raw_packets(pcap_t * pcap)
510416
* where unknowns are servers
511417
*/
512418
dbg(2, "processing second pass of auto: server mode...");
513-
if (ip_hdr) {
514-
cache_result = add_cache(&options->cachedata, SEND,
515-
check_ip_tree(DIR_SERVER, ip_hdr->ip_src.s_addr));
516-
} else {
517-
cache_result = add_cache(&options->cachedata, SEND,
518-
check_ip6_tree(DIR_SERVER, &ip6_hdr->ip_src));
519-
}
520419
break;
521420

522421
case CLIENT_MODE:
@@ -525,22 +424,13 @@ process_raw_packets(pcap_t * pcap)
525424
* where unknowns are clients
526425
*/
527426
dbg(2, "processing second pass of auto: client mode...");
528-
if (ip_hdr) {
529-
cache_result = add_cache(&options->cachedata, SEND,
530-
check_ip_tree(DIR_CLIENT, ip_hdr->ip_src.s_addr));
531-
} else {
532-
cache_result = add_cache(&options->cachedata, SEND,
533-
check_ip6_tree(DIR_CLIENT, &ip6_hdr->ip_src));
534-
}
535427
break;
536428

537429
case PORT_MODE:
538430
/*
539431
* process ports based on their destination port
540432
*/
541433
dbg(2, "processing port mode...");
542-
cache_result = add_cache(&options->cachedata, SEND,
543-
check_dst_port(ip_hdr, ip6_hdr, (pkthdr.caplen - l2len)));
544434
break;
545435

546436
case FIRST_MODE:
@@ -549,13 +439,6 @@ process_raw_packets(pcap_t * pcap)
549439
* by the ones which send the first packet in a session
550440
*/
551441
dbg(2, "processing second pass of auto: first packet mode...");
552-
if (ip_hdr) {
553-
cache_result = add_cache(&options->cachedata, SEND,
554-
check_ip_tree(DIR_UNKNOWN, ip_hdr->ip_src.s_addr));
555-
} else {
556-
cache_result = add_cache(&options->cachedata, SEND,
557-
check_ip6_tree(DIR_UNKNOWN, &ip6_hdr->ip_src));
558-
}
559442
break;
560443

561444
default:

0 commit comments

Comments
 (0)