*/
function inet_get_local_port:long(sock:long)
{
- return @choose_defined(@cast(sock, "inet_sock")->sk->__sk_common->skc_num,
+ return @choose_defined(@inet_sock_cast(sock)->sk->__sk_common->skc_num,
# kernel >= 2.6.33
- @choose_defined(@cast(sock, "inet_sock")->inet_num,
+ @choose_defined(@inet_sock_cast(sock)->inet_num,
# kernel >= 2.6.11
- @choose_defined(@cast(sock, "inet_sock")->num,
- @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->num)))
+ @choose_defined(@inet_sock_cast(sock)->num,
+ @inet_sock_cast(sock)->inet->num)))
}
/**
function __ip_sock_saddr:long (sock:long)
{
- family = @cast(sock, "inet_sock", "kernel<net/ip.h>")->sk->__sk_common->skc_family
+ family = @inet_sock_cast(sock)->sk->__sk_common->skc_family
if (family == @const("AF_INET")) {
- return @choose_defined(@cast(sock, "inet_sock")->inet_saddr, # kernel >= 2.6.33
- @choose_defined(@cast(sock, "inet_sock")->saddr, # kernel >= 2.6.11
- @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->saddr))
+ return @choose_defined(@inet_sock_cast(sock)->inet_saddr, # kernel >= 2.6.33
+ @choose_defined(@inet_sock_cast(sock)->saddr, # kernel >= 2.6.11
+ @inet_sock_cast(sock)->inet->saddr))
}
%( CONFIG_IPV6 == "[ym]" %?
else if (family == @const("AF_INET6")) {
- return (&@cast(sock, "inet_sock", "kernel<net/ip.h>")->pinet6->saddr)
+ return (&@inet_sock_cast(sock)->pinet6->saddr)
}
%)
return 0
/* return the destination IP address for a given sock */
function __ip_sock_daddr:long (sock:long)
{
- family = @cast(sock, "inet_sock", "kernel<net/ip.h>")->sk->__sk_common->skc_family
+ family = @inet_sock_cast(sock)->sk->__sk_common->skc_family
if (family == @const("AF_INET")) {
- return @choose_defined(@cast(sock, "inet_sock")->sk->__sk_common->skc_daddr, # kernel >= 2.6.38
- @choose_defined(@cast(sock, "inet_sock")->inet_daddr, # kernel >= 2.6.33
- @choose_defined(@cast(sock, "inet_sock")->daddr, # kernel >= 2.6.11
- @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->daddr)))
+ return @choose_defined(@inet_sock_cast(sock)->sk->__sk_common->skc_daddr, # kernel >= 2.6.38
+ @choose_defined(@inet_sock_cast(sock)->inet_daddr, # kernel >= 2.6.33
+ @choose_defined(@inet_sock_cast(sock)->daddr, # kernel >= 2.6.11
+ @inet_sock_cast(sock)->inet->daddr)))
}
%( CONFIG_IPV6 == "[ym]" %?
else if (family == @const("AF_INET6")) {
- return @choose_defined(&@cast(sock, "inet_sock", "kernel<net/ip.h>")->sk->__sk_common->skc_v6_daddr,
- &@cast(sock, "inet_sock", "kernel<net/ip.h>")->pinet6->daddr)
+ return @choose_defined(&@inet_sock_cast(sock)->sk->__sk_common->skc_v6_daddr,
+ &@inet_sock_cast(sock)->pinet6->daddr)
}
%)
return 0
/* return the IP address family for a given sock */
function __ip_sock_family:long (sock:long)
{
- return (@cast(sock, "inet_sock", "kernel<net/ip.h>")->sk->__sk_common->skc_family)
+ return (@inet_sock_cast(sock)->sk->__sk_common->skc_family)
}
/* Get the IP header from a sk_buff struct */
/* return the TCP destination port for a given sock */
function __tcp_sock_dport:long (sock:long)
{
- port = @choose_defined(@cast(sock, "inet_sock", "kernel<net/inet_sock.h>")->sk->__sk_common->skc_dport, # kernel >= 3.8
- @choose_defined(@cast(sock, "inet_sock")->inet_dport, # kernel >= 2.6.33
- @choose_defined(@cast(sock, "inet_sock", "kernel")->dport, # kernel >= 2.6.11
- @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->dport)))
+ port = @choose_defined(@inet_sock_cast(sock)->sk->__sk_common->skc_dport, # kernel >= 3.8
+ @choose_defined(@inet_sock_cast(sock)->inet_dport, # kernel >= 2.6.33
+ @choose_defined(@inet_sock_cast(sock)->dport, # kernel >= 2.6.11
+ @inet_sock_cast(sock)->inet->dport)))
return ntohs(port)
}
/* return the TCP source port for a given sock */
function __tcp_sock_sport:long (sock:long)
{
- port = @choose_defined(@cast(sock, "inet_sock")->inet_sport, # kernel >= 2.6.33
- @choose_defined(@cast(sock, "inet_sock", "kernel")->sport, # kernel >= 2.6.11
- @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->sport))
+ port = @choose_defined(@inet_sock_cast(sock)->inet_sport, # kernel >= 2.6.33
+ @choose_defined(@inet_sock_cast(sock)->sport, # kernel >= 2.6.11
+ @inet_sock_cast(sock)->inet->sport))
return ntohs(port)
}