📄 setudpchecksum.cc
字号:
// -*- c-basic-offset: 4 -*-/* * setudpchecksum.{cc,hh} -- sets the UDP header checksum * Robert Morris, Eddie Kohler * * Copyright (c) 1999-2000 Massachusetts Institute of Technology * Copyright (c) 2002 International Computer Science Institute * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, subject to the conditions * listed in the Click LICENSE file. These conditions include: you must * preserve this copyright notice, and you cannot mention the copyright * holders in advertising related to the Software without their permission. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This * notice is a summary of the Click LICENSE file; the license in that file is * legally binding. */#include <click/config.h>#include "setudpchecksum.hh"#include <click/glue.hh>#include <click/error.hh>#include <clicknet/ip.h>#include <clicknet/udp.h>CLICK_DECLSSetUDPChecksum::SetUDPChecksum(){}SetUDPChecksum::~SetUDPChecksum(){}Packet *SetUDPChecksum::simple_action(Packet *p_in){ WritablePacket *p = p_in->uniqueify(); if (!p) return 0; // XXX check IP header/UDP protocol? click_ip *iph = p->ip_header(); click_udp *udph = p->udp_header(); int len; if (IP_ISFRAG(iph) || p->transport_length() < (int) sizeof(click_udp) || (len = ntohs(udph->uh_ulen), p->transport_length() < len)) { // fragment, or packet data too short checked_output_push(1, p); return 0; } udph->uh_sum = 0; unsigned csum = click_in_cksum((unsigned char *)udph, len); udph->uh_sum = click_in_cksum_pseudohdr(csum, iph, len); return p;}CLICK_ENDDECLSEXPORT_ELEMENT(SetUDPChecksum)ELEMENT_MT_SAFE(SetUDPChecksum)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -