X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..b21a698b1773f5b1d1fd78fb3817d4c195a0dab6:/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..a2627177 100644 --- a/projects/stargazer/plugins/capture/cap_debug/ip.c +++ b/projects/stargazer/plugins/capture/cap_debug/ip.c @@ -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; -}