Chinaunix首页 | 论坛 | 博客
  • 博客访问: 416898
  • 博文数量: 124
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 872
  • 用 户 组: 普通用户
  • 注册时间: 2018-03-29 14:38
个人简介

默默的一块石头

文章分类

全部博文(124)

文章存档

2022年(26)

2021年(10)

2020年(28)

2019年(60)

我的朋友

分类: LINUX

2019-11-19 19:16:10

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) |
0

上一篇:socket学习

下一篇:How SKBs work

给主人留下些什么吧!~~