Skip to content

[refact](netdev): Expose netdev_set_dns and netdev_set_if #10128

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PlainWaterK
Copy link

[Descriptions]:
1. Make these functions public to avoid code duplication and allow direct usage by other components.
2. Apply clang-format for consistent code style.
[Root Cause]:NA
[Side Effects]:NA

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

目前在开发应用代码时,netdev 接口目前需要多次函数调用(netdev_get_by_name, netdev_set_ipaddr等)来完整配置网络设置,这较为低效。因为 netdev_set_if 已经存在但属于静态函数,导致用户需要自己重新实现一个类似于netdev_set_if接口的流程去进行以太网配置。
改进此功能将允许通过单个函数调用直接配置以太网多项属性,从而简化网络配置代码并避免开发者去重复实现。
所以我认为将该函数接口从静态函数变为一个普通函数可能是更合适的,如果有什么理解不到位的地方欢迎大家指正。

你的解决方案是什么 (what is your solution)

Convert netdev_set_if and netdev_set_dns from static function to normal

请提供验证的bsp和config (provide the config and bsp)

  • BSP: cvitek
  • .config: CONFIG_BSP_USING_ETHERNET
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/workflows/bsp_buildings.yml 详细请参考链接BSP自查

@supperthomas
Copy link
Member

image

@supperthomas supperthomas added the -1 No vote label Mar 23, 2025
@supperthomas
Copy link
Member

感谢PR,请仅提交需要修改的代码。格式化代码可以另起一个PR提交。

@supperthomas supperthomas marked this pull request as draft March 23, 2025 13:58
@PlainWaterK PlainWaterK force-pushed the master branch 2 times, most recently from 3560e43 to 8e4fef1 Compare April 1, 2025 08:26
[Descriptions]:
    1. Make these functions public to avoid code duplication and allow direct usage by other components.
    2. Fix ifdef's error note.
[Root Cause]:NA
[Side Effects]:NA
@PlainWaterK PlainWaterK marked this pull request as ready for review April 7, 2025 02:08
@PlainWaterK
Copy link
Author

感谢PR,请仅提交需要修改的代码。格式化代码可以另起一个PR提交。

May this patch be merged?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

return;
}

inet_aton(dns_server, &dns_addr);
Copy link
Preview

Copilot AI Apr 15, 2025

Choose a reason for hiding this comment

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

Consider verifying the return value of inet_aton to ensure that the DNS server address string is valid before calling netdev_set_dns_server.

Suggested change
inet_aton(dns_server, &dns_addr);
if (inet_aton(dns_server, &dns_addr) == 0)
{
rt_kprintf("invalid DNS server address: %s\n", dns_server);
return;
}

Copilot uses AI. Check for mistakes.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants