我写了一个简单的内核模块来连接到'ip'上运行的服务器。虽然,我将ip改为错误的值,但它给了我成功。这是代码,
memset(&kthread->addr_send, 0, sizeof(struct sockaddr));
kthread->addr_send.sin_family = AF_INET;
kthread->addr_send.sin_addr.s_addr = inet_addr(ip);
kthread->addr_send.sin_port = htons(DEFAULT_PORT);
if ( (err = kthread->sock_send->ops->connect(kthread->sock_send, (struct sockaddr *)&kthread->addr_send, sizeof(struct sockaddr), 0) ) < 0 ) {
printk(KERN_INFO MODULE_NAME": Could not connect to socket, error = %d\n", -err);
goto again;
}
printk(KERN_INFO MODULE_NAME": Connection Success to %s \n", ip);
inet_addr()由我编写,它提供了完美的输出。这似乎是什么问题?任何帮助表示赞赏。