X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..9c340da9ffa670c20c3658a2be43d35868a9f5d9:/projects/stargazer/plugins/capture/cap_debug/ip.c diff --git a/projects/stargazer/plugins/capture/cap_debug/ip.c b/projects/stargazer/plugins/capture/cap_debug/ip.c index bc632f37..02bd10f1 100644 --- a/projects/stargazer/plugins/capture/cap_debug/ip.c +++ b/projects/stargazer/plugins/capture/cap_debug/ip.c @@ -1,4 +1,4 @@ -/* $Id: ip.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ +/* $Id: ip.c,v 1.1 2005/12/12 18:14:22 nobunaga Exp $ Copyright (C) 2002 Marc Kirchner @@ -37,7 +37,7 @@ pkt_ip_header(struct packet *pkt, if (!pkt) return EPKTINVALPTR; - + ip = (struct ip *) pkt->pkt_ptr; ip->ip_hl = iphdr_len; @@ -53,72 +53,3 @@ pkt_ip_header(struct packet *pkt, return 0; } - -int -pkt_ip_option_header(struct packet *pkt, unsigned char type, unsigned char len, unsigned char ptr, unsigned char oflw_flg, void *optval, size_t optlen) -{ - unsigned char *vp; - - if (!pkt) - return EPKTINVALPTR; - - vp = pkt->pkt_ptr; - *vp = type; - switch (type) { - case PKT_IP_OPT_END: - break; - case PKT_IP_OPT_NOP: - break; - case PKT_IP_OPT_SEC: - if ((pkt->pkt_pos + 2 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - memcpy((void*)(vp+2), optval, optlen); - } else { - return EPKTRANGE; - } - break; - case PKT_IP_OPT_RR: - case PKT_IP_OPT_LSRR: - case PKT_IP_OPT_SSRR: - case PKT_IP_OPT_SID: - if ((pkt->pkt_pos + 3 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - *(vp+2) = ptr; - memcpy((void*)(vp+3), optval, optlen); - } else { - return EPKTRANGE; - } - break; - case PKT_IP_OPT_TS: - if ((pkt->pkt_pos + 4 + optlen) <= pkt->pkt_size) { - *(vp+1) = len; - *(vp+2) = ptr; - *(vp+3) = oflw_flg; - memcpy((void*)(vp+4), optval, optlen); - } else { - return EPKTRANGE; - } - break; - default: - return EPKTUNKNOWNTYPE; - } - return PKTOK; -} - -int -pkt_ip_cksum(struct packet *pkt) -{ - /* - * checksum should be calculated by kernel - * when we are using SOCK_RAW access. - */ - struct ip *ip; - - if (!pkt) - return EPKTINVALPTR; - - ip = (struct ip *) pkt->pkt_ptr; - ip->ip_sum = 0; - ip->ip_sum = in_cksum((unsigned short *)ip, sizeof(struct ip)); - return 0; -}