Skip to content

Commit

Permalink
minor typo fix (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyujie2002 authored May 31, 2024
1 parent aa875d5 commit 270edc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion labs/kernel_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ printk
内存分配
--------

在 Linux 内核中,只能分配驻留内存。要想分配驻留内存,可以使用 :c:func:`kmalloc` 调用。下面是一个典型的 :c:func:`kmalloc` 调用示例:
在 Linux 中,常驻内存只能使用 :c:func:`kmalloc` 调用来分配。下面是一个典型的 :c:func:`kmalloc` 调用示例:

.. code-block:: c
Expand Down
6 changes: 3 additions & 3 deletions labs/networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ socket 相关操作包括:

这些调用的参数如下:

* ``net`` (如果存在)用作对所使用的网络命名空间的引用;通常我们会使用 ``init_net`` 进行初始化;
* ``family`` 表示在信息传输中使用的协议族;它们通常以 ``PF_``(协议族)字符串开头;表示所使用的协议族的常量可以在 :file:`linux/socket.h` 中找到,其中最常用的是 ``PF_INET``用于 TCP/IP 协议;
* ``type`` 是 socket 的类型;用于此参数的常量可以在 :file:`linux/net.h` 中找到,其中最常用的是 ``SOCK_STREAM`` (用于基于连接的源到目的地通信)以及 ``SOCK_DGRAM`` (用于无连接通信);
* ``net`` (如果存在) 用作对所使用的网络命名空间的引用;通常我们会使用 ``init_net`` 进行初始化;
* ``family`` 表示在信息传输中使用的协议族;它们通常以 ``PF_`` (协议族) 字符串开头;表示所使用的协议族的常量可以在 :file:`linux/socket.h` 中找到,其中最常用的是 ``PF_INET``, 用于 TCP/IP 协议;
* ``type`` 是 socket 的类型;用于此参数的常量可以在 :file:`linux/net.h` 中找到,其中最常用的是 ``SOCK_STREAM`` (用于基于连接的源到目的地通信) 以及 ``SOCK_DGRAM`` (用于无连接通信);
* ``protocol`` 表示使用的协议,与 ``type`` 参数密切相关;用于此参数的常量可以在 :file:`linux/in.h` 中找到,其中最常用的是 ``IPPROTO_TCP`` (用于 TCP), ``IPPROTO_UDP`` (用于 UDP)。

要在内核空间中创建 TCP socket,你需要调用:
Expand Down

0 comments on commit 270edc2

Please sign in to comment.