/* include/net/dsfield.h - Manipulation of the Differentiated Services field */

/* Written 1998-2000 by Werner Almesberger, EPFL ICA */


#ifndef __NET_DSFIELD_H
#define __NET_DSFIELD_H

#include <linux/types.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <asm/byteorder.h>


static inline __u8 ipv4_get_dsfield(const struct iphdr *iph)
{
	return iph->tos;
}


static inline __u8 ipv6_get_dsfield(const struct ipv6hdr *ipv6h)
{
	return ntohs(*(const __be16 *)ipv6h) >> 4;
}


static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
    __u8 value)
{
        __u32 check = ntohs((__force __be16)iph->check);
	__u8 dsfield;

	dsfield = (iph->tos & mask) | value;
	check += iph->tos;
	if ((check+1) >> 16) check = (check+1) & 0xffff;
	check -= dsfield;
	check += check >> 16; /* adjust carry */
	iph->check = (__force __sum16)htons(check);
	iph->tos = dsfield;
}


static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
    __u8 value)
{
	__be16 *p = (__force __be16 *)ipv6h;

	*p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4);
}


#endif
'master'>master</option>
<option value='nds-private-remove' selected='selected'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/?h=nds-private-remove'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/include/net/dn_neigh.h?h=nds-private-remove'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/net/dn_neigh.h?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/net/dn_neigh.h?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/net/dn_neigh.h?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/net/dn_neigh.h'>
<input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='55af753cd9fda9c5300f5318253b08bd15fb412e'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>net</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net/dn_neigh.h?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e'>dn_neigh.h</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/net/dn_neigh.h?h=nds-private-remove&amp;id=55af753cd9fda9c5300f5318253b08bd15fb412e&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>