Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

网络socket的系统调用接口。 #247

Merged
merged 39 commits into from Apr 19, 2023
Merged

Conversation

fslongjin
Copy link
Member

@fslongjin fslongjin commented Apr 19, 2023

用户程序能够像linux一样,编写tcp server、tcp client、udp server、udp client程序。
编译网络程序需要使用最新的relibc

guanjinquan and others added 30 commits March 18, 2023 18:49
…uan/DragonOS into patch-add-network-stack-support
/// @param addrlen 地址长度
///
/// @return 成功返回0,失败返回错误码
pub fn do_getsockname(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

真正执行的函数前缀换成execute会不会好一点

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为文件系统那边也这样写了,所以这边这样写。打算在接下来重构系统调用模块之后,删掉这种写法。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okk

@@ -29,7 +59,10 @@ QEMU_RTC_CLOCK="clock=host,base=localtime"
QEMU_SERIAL="file:../serial_opt.txt"
QEMU_DRIVE="id=disk,file=${QEMU_DISK_IMAGE},if=none"

QEMU_DEVICES="-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -nic user,model=virtio-net-pci -usb -device qemu-xhci,id=xhci,p2=8,p3=4 -machine accel=${qemu_accel} -machine q35"

# ps: 下面这条使用tap的方式,无法dhcp获取到ip,暂时不知道为什么
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我好像没看到挂载网卡的步骤

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-nic user,model=virtio-net-pci,hostfwd=tcp::12580-:12580
这个是

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我说的是tap模式下桥挂载本地网卡

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我说的是tap模式下桥挂载本地网卡

哦哦哦,因为tap连接本地的bridge的话需要手动配置网桥,然后这里我仍然没有解决断网的问题。因此直接用了user+hostfwd端口转发的方式。
然后,使用nat模式的话,我搜索到的方法是编写ifup和ifdown对应的脚本。但脚本配置dnsmasq这个dhcp服务器的时候有点问题,还没搞清楚为什么。系统内无法dhcp获取到ip地址。
# QEMU_DEVICES="-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -net nic,netdev=nic0 -netdev tap,id=nic0,model=virtio-net-pci,script=qemu/ifup-nat,downscript=qemu/ifdown-nat -usb -device qemu-xhci,id=xhci,p2=8,p3=4 -machine accel=${qemu_accel} -machine q35 "

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦哦,明白了

@fslongjin fslongjin merged commit cde5492 into master Apr 19, 2023
1 check passed
fslongjin added a commit that referenced this pull request Apr 28, 2023
* 新增VFS文档,以及修改文档配置 (#209)

* 1.新增vfs设计文档
2.修改文档版权标志为"2022-2023, DragonOS Community"
3.修改电脑版文档页面的宽度为90%

* layout.html末尾加空行

* 修正了FAT32判断逻辑,解决了文件系统为FAT12/16时系统无法正常启动的问题。 (#211)

* fix(fat): fix determination of fat type casue crash if fs is fat12/16

* refactor(fat): split BiosParameterBlock.validate() into BiosParameterBlockFAT32.validate() and BiosParameterBlockLegacy.validate()

* 调整“最大允许的簇号”的常量放置的位置。


* 增加x87FPU支持 (#212)

* remove `ret_from_syscall`
*修复ps2键盘驱动程序inode在进程fork的时候导致死锁的问题.
*更新: VFS每次拷贝文件描述符的时候,都会去调用inode的open函数



* 部分函数从返回值为Result<<>,i32>修改为Result<<>,SystemError> (#210)

* 将Result<<>,i32>替换为Result<<>,SystemError>
* bugfix: 显示双缓冲区初始化的时候,连续注册了两次Video Softirq的问题。



* 第一套键盘扫描码的状态机 (#216)

第一套键盘扫描码的状态机

* 将TTY与stdio进行连接,实现基本的stdio功能 (#217)

* 将stdio与tty接上

* Patch keyboard capslock alt (#219)

* keyboard-alt-capslock

* 解决键盘输入'%'字符的时候无法回显的bug



* Add dup,dup2 (#224)

* dup,dup2

* fix: sys_dup2语义与posix不一致的问题


* 添加了qemu使用VNC作为图像输出的选项 (#222)

* 添加了qemu使用VNC作为图像输出的选项

* 设置vnc端口为5900


* 软中断&定时器重构 (#223)

* 软中断&定时器重构


* 修改timer的clock()

* 删除debug信息



* V0.1.6发行日志&更新构建系统文档 (#225)

1.更新构建系统文档
2.V0.1.6发行日志

* Patch add 0.1.6 changelog (#226)

* 修正标题错误

* 修复显示刷新线程的空指针问题 (#228)

* 新增设备驱动模型,为设备和驱动提供高层视图 (#227)

* 添加base mod

* 添加设备驱动模型相关文件

* 删除单独的mod文件,使用mod.rs,修改一些格式上的问题

* 移动驱动错误类型到该文件

* 修改一些格式上的问题

* 修改CFSqueue从Vec变成红黑树 (#229)

使用了由tickbh编写的rbtree: https://github.com/tickbh/rbtree-rs/blob/master/src/lib.rs


* new: lazy_init (#230)

* Patch add lazy init (#236)

* 修正并发安全问题

* pci重构+pcie支持 (#235)

* pci重构+pcie支持

* pci重构测试完成

* 修正makefile的问题

* 小修改

* 修改函数名字

* 增加对dhcpv4的支持(tcp、udp socket已写好,但由于缺少epoll机制,尚未完整测试) (#237)

* 为virtio网卡完成smoltcp的phy层配置

* raw socket

* 初步写完udp和tcp socket

* 能够正常通过dhcp获取ipv4地址(具有全局iface btree)



* 调整brk系统调用,使得参数、返回值与Linux一致 (#238)

* 新增用于测试relibc的app

* 为适配relibc,修改do_execve中关于用户栈的内容的设置

* 调整brk系统调用,使得参数、返回值与Linux一致

* 修改errno,使其与relibc的保持一致 (#234)

修改errno,使其与relibc的保持一致

* 修复ecam无法获取MCFG table的问题 (#241)

* 修复Issue#220;vnc的端口号恢复5900 (#243)


* 修复Issue#220

* qemu-vnc端口号恢复为5900

* new: DowncastArc and its docs (#244)

* 增加定时器和软中断文档,修改了softirq面向c的接口 (#245)

* 增加定时器和软中断文档

* 修改softirq对c的接口和文档

* 修改文档格式

* 新增网络socket的系统调用接口 (#247)

1.修复spinlock忘记恢复rflags的问题
2.WaitQueue增加wakeup_all的功能
3.完善tcp,udp,raw socket
4.把PollStatus结构体改为使用bitflags
5.新增iovec结构体
6.完成网络的系统调用
7.在bootstrap里面添加dnsmasq bridge-utils iptables

* 新增SysFS (#250)

* 添加sysfs

* 注册sysfs

* 添加sysfs相关

* 添加rust-anlyzer辅助配置

* 将设备与sysfs相关联

* 添加单独的文件管理sysfs下的文件夹

* 解决使用zsh在构建DragonOS时,无法直接使用一键初始化脚本进行安装的问题  (#252)

* 匿名管道重构&增加IrqArch trait以及IrqFlags及其守卫 (#253)

* 实现匿名管道

* 增加IrqArch trait以及IrqFlags及其守卫


* 根据sysfs完善设备驱动模型 & 添加sysfs官方文档 (#254)

* 根据sysfs完善设备驱动模型

* 添加sysfs官方文档

* doc: V0.1.7发行日志 (#255)
@fslongjin fslongjin deleted the patch-add-network-stack-support branch May 24, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants