1.setsockopt
/*
* Set a socket option. Because we don't know the option lengths we have
* to pass the user mode parameter for the protocols to sort out.
*/
SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,
char __user *, optval, int, optlen)
{
......
if (level == SOL_SOCKET)
err = sock_setsockopt(sock, level, optname, optval,optlen);
else
err = sock->ops->setsockopt(sock, level, optname, optval,optlen);
......
}
追踪TCP/IP
const struct proto_ops inet_stream_ops = {
.family = PF_INET,
......
.setsockopt = sock_common_setsockopt,
......
};
struct proto tcp_prot = {
.name = "TCP",
......
.setsockopt = tcp_setsockopt,
......
};
const struct inet_connection_sock_af_ops ipv4_specific = {
......
.setsockopt = ip_setsockopt,
......
};
1.sock_common_setsockopt()
/*
* Set socket options on an inet socket.
*/
int sock_common_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
//struct proto *skc_prot;
return sk->sk_prot->setsockopt(sk, level, optname, optval, optlen);
}
EXPORT_SYMBOL(sock_common_setsockopt);
2.tcp_setsockopt()
int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
unsigned int optlen)
{
const struct inet_connection_sock *icsk = inet_csk(sk);
if (level != SOL_TCP)
return icsk->icsk_af_ops->setsockopt(sk, level, optname,
optval, optlen);
return do_tcp_setsockopt(sk, level, optname, optval, optlen);
}
阅读(5653) | 评论(0) | 转发(0) |