Kill now unused adjustpacket(), getpacket() and processpacket()
after moving to packet_*() counterparts.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/packet.c | 248 ----------------------------------------------------------
src/packet.h | 7 --
2 files changed, 0 insertions(+), 255 deletions(-)
diff --git a/src/packet.c b/src/packet.c
index 46c5024..3432081 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -79,57 +79,6 @@ static unsigned int get_tr_ip_offset(char *pkt)
sizeof(struct trllc);
}
-static void adjustpacket(char *tpacket, struct sockaddr_ll *fromaddr,
- char **packet, unsigned int *readlen)
-{
- unsigned int dataoffset;
-
- switch (fromaddr->sll_hatype) {
- case ARPHRD_ETHER:
- case ARPHRD_LOOPBACK:
- *packet = tpacket + ETH_HLEN;
- *readlen -= ETH_HLEN;
- if (fromaddr->sll_protocol == ETH_P_8021Q) {
- /* strip 0x8100 802.1Q VLAN Extended Header */
- *packet += 4;
- *readlen -= 4;
- /* update network protocol */
- fromaddr->sll_protocol = *((unsigned short *) *packet);
- }
- break;
- case ARPHRD_SLIP:
- case ARPHRD_CSLIP:
- case ARPHRD_SLIP6:
- case ARPHRD_PPP:
- case ARPHRD_CSLIP6:
- case ARPHRD_TUNNEL:
- case ARPHRD_NONE:
- case ARPHRD_IPGRE:
- *packet = tpacket;
- break;
- case ARPHRD_FRAD:
- case ARPHRD_DLCI:
- *packet = tpacket + 4;
- *readlen -= 4;
- break;
- case ARPHRD_FDDI:
- *packet = tpacket + sizeof(struct fddihdr);
- *readlen -= sizeof(struct fddihdr);
- break;
- case ARPHRD_IEEE802_TR:
- case ARPHRD_IEEE802:
- /* Token Ring patch supplied by Tomas Dvorak */
- /* Get the start of the IP packet from the Token Ring frame. */
- dataoffset = get_tr_ip_offset(tpacket);
- *packet = tpacket + dataoffset;
- *readlen -= dataoffset;
- break;
- default:
- *packet = (char *) NULL; /* return a NULL packet to signal */
- break; /* an unrecognized link protocol */
- } /* to the caller. Hopefully, this */
-} /* switch statement will grow. */
-
static int packet_adjust(struct pkt_hdr *pkt)
{
int retval = 0;
@@ -189,47 +138,6 @@ static int packet_adjust(struct pkt_hdr *pkt)
return retval;
}
-/*
- * IPTraf input function; reads both keystrokes and network packets.
- */
-
-void getpacket(int fd, char *buf, struct sockaddr_ll *fromaddr, int *ch,
- int *br, WINDOW * win)
-{
- socklen_t fromlen;
- fd_set set;
- int ss;
-
- do {
- FD_ZERO(&set);
-
- /* Monitor stdin only if in interactive, not daemon mode. */
- if (!daemonized)
- FD_SET(0, &set);
-
- /* Monitor raw socket */
- FD_SET(fd, &set);
-
- struct timeval tv = {
- .tv_sec = 0,
- .tv_usec = DEFAULT_UPDATE_DELAY
- };
-
- ss = select(fd + 1, &set, 0, 0, &tv);
- } while ((ss < 0) && (errno == EINTR));
-
- *br = 0;
- *ch = ERR;
-
- if (FD_ISSET(fd, &set)) {
- fromlen = sizeof(struct sockaddr_ll);
- *br = recvfrom(fd, buf, MAX_PACKET_SIZE, MSG_TRUNC,
- (struct sockaddr *) fromaddr, &fromlen);
- }
- if (!daemonized && FD_ISSET(0, &set))
- *ch = wgetch(win);
-}
-
/* IPTraf input function; reads both keystrokes and network packets. */
void packet_get(int fd, struct pkt_hdr *pkt, int *ch, WINDOW *win)
{
@@ -280,162 +188,6 @@ void packet_get(int fd, struct pkt_hdr *pkt, int *ch, WINDOW *win)
*ch = wgetch(win);
}
-int processpacket(char *tpacket, char **packet, unsigned int *br,
- unsigned int *total_br, unsigned int *sport,
- unsigned int *dport, struct sockaddr_ll *fromaddr,
- struct filterstate *filter,
- int match_opposite, int v6inv4asv6)
-{
- /*
- * Get IPTraf link type based on returned information and move past
- * data link header.
- */
- fromaddr->sll_protocol = ntohs(fromaddr->sll_protocol);
- adjustpacket(tpacket, fromaddr, packet, br);
-
- if (*packet == NULL)
- return INVALID_PACKET;
-
-again: if (fromaddr->sll_protocol == ETH_P_IP) {
- struct iphdr *ip;
- int hdr_check;
- register int ip_checksum;
- register int iphlen;
- unsigned int f_sport = 0, f_dport = 0;
-
- /*
- * At this point, we're now processing IP packets. Start by getting
- * IP header and length.
- */
- ip = (struct iphdr *) (*packet);
- iphlen = ip->ihl * 4;
-
- /*
- * Compute and verify IP header checksum.
- */
-
- ip_checksum = ip->check;
- ip->check = 0;
- hdr_check = in_cksum((u_short *) ip, iphlen);
-
- if ((hdr_check != ip_checksum))
- return CHECKSUM_ERROR;
-
- if ((ip->protocol == IPPROTO_TCP || ip->protocol == IPPROTO_UDP)
- && (sport != NULL && dport != NULL)) {
- unsigned int sport_tmp, dport_tmp;
-
- /*
- * Process TCP/UDP fragments
- */
- if ((ntohs(ip->frag_off) & 0x3fff) != 0) {
- int firstin;
-
- /*
- * total_br contains total byte count of all fragments
- * not yet retrieved. Will differ only if fragments
- * arrived before the first fragment, in which case
- * the total accumulated fragment sizes will be returned
- * once the first fragment arrives.
- */
-
- if (total_br != NULL)
- *total_br =
- processfragment(ip, &sport_tmp,
- &dport_tmp,
- &firstin);
-
- if (!firstin)
- return MORE_FRAGMENTS;
- } else {
- struct tcphdr *tcp;
- struct udphdr *udp;
- char *ip_payload = (char *) ip + iphlen;
-
- switch (ip->protocol) {
- case IPPROTO_TCP:
- tcp = (struct tcphdr *) ip_payload;
- sport_tmp = tcp->source;
- dport_tmp = tcp->dest;
- break;
- case IPPROTO_UDP:
- udp = (struct udphdr *) ip_payload;
- sport_tmp = udp->source;
- dport_tmp = udp->dest;
- break;
- default:
- sport_tmp = 0;
- dport_tmp = 0;
- break;
- }
-
- if (total_br != NULL)
- *total_br = *br;
- }
-
- if (sport != NULL)
- *sport = sport_tmp;
-
- if (dport != NULL)
- *dport = dport_tmp;
-
- /*
- * Process IP filter
- */
- f_sport = ntohs(sport_tmp);
- f_dport = ntohs(dport_tmp);
- }
- if ((filter->filtercode != 0)
- &&
- (!ipfilter
- (ip->saddr, ip->daddr, f_sport, f_dport, ip->protocol,
- match_opposite, &(filter->fl))))
- return PACKET_FILTERED;
- if (v6inv4asv6 && (ip->protocol == IPPROTO_IPV6)) {
- fromaddr->sll_protocol = ETH_P_IPV6;
- *packet += iphlen;
- *br -= iphlen;
- goto again;
- }
- return PACKET_OK;
- } else if (fromaddr->sll_protocol == ETH_P_IPV6) {
- struct tcphdr *tcp;
- struct udphdr *udp;
- struct ip6_hdr *ip6 = (struct ip6_hdr *) *packet;
- char *ip_payload = (char *) ip6 + 40;
-
- //TODO: Filter packets
- switch (ip6->ip6_nxt) { /* FIXME: extension headers ??? */
- case IPPROTO_TCP:
- tcp = (struct tcphdr *) ip_payload;
- if (sport)
- *sport = tcp->source;
- if (dport)
- *dport = tcp->dest;
- break;
- case IPPROTO_UDP:
- udp = (struct udphdr *) ip_payload;
- if (sport)
- *sport = udp->source;
- if (dport)
- *dport = udp->dest;
- break;
- default:
- if (sport)
- *sport = 0;
- if (dport)
- *dport = 0;
- break;
- }
- } else {
- /* not IPv4 and not IPv6: apply non-IP packet filter */
- if (!nonipfilter(filter, fromaddr->sll_protocol)) {
- return PACKET_FILTERED;
- }
- }
- return PACKET_OK;
-}
-
int packet_process(struct pkt_hdr *pkt, unsigned int *total_br,
unsigned int *sport, unsigned int *dport,
struct filterstate *filter, int match_opposite,
diff --git a/src/packet.h b/src/packet.h
index 715902f..fc350b9 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -48,14 +48,7 @@ struct pkt_hdr {
};
void open_socket(int *fd);
-void getpacket(int fd, char *buf, struct sockaddr_ll *fromaddr, int *ch,
- int *br, WINDOW * win);
void packet_get(int fd, struct pkt_hdr *pkt, int *ch, WINDOW *win);
-int processpacket(char *tpacket, char **packet, unsigned int *br,
- unsigned int *total_br, unsigned int *sport,
- unsigned int *dport, struct sockaddr_ll *fromaddr,
- struct filterstate *ofilter,
- int match_opposite, int v6inv4asv6);
int packet_process(struct pkt_hdr *pkt, unsigned int *total_br,
unsigned int *sport, unsigned int *dport,
struct filterstate *filter, int match_opposite,
--
1.7.8.4