From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mx.groups.io with SMTP id smtpd.web09.2085.1657919016329326354 for ; Fri, 15 Jul 2022 14:03:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fmhq/PsW; spf=pass (domain: gmail.com, ip: 209.85.216.46, mailfrom: ayushdevel1325@gmail.com) Received: by mail-pj1-f46.google.com with SMTP id s21so6649739pjq.4 for ; Fri, 15 Jul 2022 14:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=B6OVtKMzFHeYmLxdfK2LiquXf9/VcS0CBEOAmhc8qs4=; b=fmhq/PsWBqEc9CTyMudX1TbKU7GbFu6d6iJIe9uSo3UkIw8F7XQrKaN38azLH3sAsI db5XCXW8MaJIwCSDKhDEA4o4B/IrGMTI489nzHwaYQegrAwVmaf4eLI8PgRZESx7fUtU hMayF5DIgBlDsh9hGUYaiVPOXrTu6BGJAVjdUW6oCHK5XpMz5DVvg17X/1cZmIzUJxi8 /yq7YzMNq5hr2Yh+A2vVQWQK2xQ3p5Snph3pb2SmyvPGrjnpjRjoAoYclzkIZ0VvTBqy uf8cPSCf4QBrBNwHS7Uy3ViEaUfi0jmJN5MuAhNJVr3MWgXEt0chK5nQWKiBOeZK3uow KvFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=B6OVtKMzFHeYmLxdfK2LiquXf9/VcS0CBEOAmhc8qs4=; b=XpnjxLda1LUQPgZnpdl10QbFMq1AjlVGhI6Dvw1tokNPa4/E/PSzVsL3jcdEVOso7m 8Vqx4fLOvI+9Cowjan9gRr/8IwREC4Z1iZNgv49WFSwIaSKJzUYSbvbq1jO1vi9SgAiE OFEmgymOrLgPTIB5SsVrf82OA9tijQzHA0bIMxOwIhqmmu3s+f+Vt8aCTG4ejhPsci4a zY06+uKIirQWo80fS2Or3PfA+qEen9O50KJ4WXMsi1oflQwE2AoDosfYauuY2YUcPOfL LflV4XxjOSHq+l4fby48uFXWeLLAF0M/UDNbyBU4SOxRMnQ4uFtDv7sBBEP5omsib1Nl L9EQ== X-Gm-Message-State: AJIora/BlushtTTyscm6/PVfEbzLTnfkOxtRaJ/BTWb+if6Cn7iytzn5 KYar+aSofZ1KtVFJbi3zKFg= X-Google-Smtp-Source: AGRyM1u05xmcatU0O0Obt+H9a1eIliiW4IKSVb0sP2NDYKbwl1jArdhVADi2HQolOr1uQtOwu8GvSw== X-Received: by 2002:a17:902:e850:b0:16c:41d1:19d2 with SMTP id t16-20020a170902e85000b0016c41d119d2mr15626883plg.125.1657919015778; Fri, 15 Jul 2022 14:03:35 -0700 (PDT) Return-Path: Received: from ?IPV6:2401:4900:1f3e:2e8d:c9ea:4f84:eaf8:6bbf? ([2401:4900:1f3e:2e8d:c9ea:4f84:eaf8:6bbf]) by smtp.gmail.com with ESMTPSA id w22-20020a1709026f1600b0016bde4cc505sm3980352plk.131.2022.07.15.14.03.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jul 2022 14:03:35 -0700 (PDT) Message-ID: Date: Sat, 16 Jul 2022 02:33:30 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior From: "Ayush Singh" To: "Kinney, Michael D" Cc: "devel@edk2.groups.io" , "mikuback@linux.microsoft.com" , "Gaibusab, Jabeena B" , "Yao, Jiewen" References: In-Reply-To: Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Ok, so I have made some small progress in implementing networking. However, I have a few things I don't quite understand since I have never really dug so deep into networking before: 1. I am trying to implement a TcpListener[1]. I think TcpListener can be implemented by setting the `EFI_TCP6_ACCESS_POINT->ActiveFlag` to false during configuration. However, while binding the TcpListenere to an address, should the `StationAddress` or the `RemoteAddress` be set to the supplied address? 2. Is there any UEFI Shell Application/utility that I can use to listen to an address (like `nc` in linux). This would be helpful for me to test out whether something is a problem in my implementation or in my qemu config. 3. The networking stuff in Rust is synchronous. Currently, I am creating a new event during accept with the following parameters: ``` Type = EVT_NOTIFY_SIGNAL NotifyTpl = TPL_CALLBACK NotifyFunction = NotifyContext = NULL ``` I pass this event as `ListenToken->CompletionToken->Event`. Then I call `EFI_BOOT_SERVICES.WaitForEvent()` on this event. Is there any better way to do this? 4. Does the EFI_TCP6_PROTOCOL support IPv4-mapped IPv6 address [2]? I was thinking just converting the IPv4 address to IPv6 instead of using EFI_TCP4_PROTOCOL. Ayush Singh [1]: https://doc.rust-lang.org/std/net/struct.TcpListener.html# [2]: https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#ipv4-mapped-ipv6-addresses On 7/14/22 00:00, Ayush Singh wrote: > Thanks. I'm not sure if I will use it directly, but it gives a very > good idea about using these protocols in Rust std. > > On Wed, Jul 13, 2022 at 11:07 PM Kinney, Michael D > wrote: >> It may be simpler to use the following lib class that layers on top of the TCP protocols. >> >> https://github.com/tianocore/edk2/blob/master/NetworkPkg/Include/Library/TcpIoLib.h >> >> The implementation of this lib shows the correct sequence: >> >> https://github.com/tianocore/edk2/blob/master/NetworkPkg/Library/DxeTcpIoLib/DxeTcpIoLib.c >> >> It uses NetLib services too >> >> https://github.com/tianocore/edk2/blob/master/NetworkPkg/Library/DxeNetLib/DxeNetLib.c >> >> Mike >> >> >>> -----Original Message----- >>> From: Ayush Singh >>> Sent: Wednesday, July 13, 2022 9:45 AM >>> To: devel@edk2.groups.io >>> Cc: Kinney, Michael D ; mikuback@linux.microsoft.com; Gaibusab, Jabeena B >>> ; Yao, Jiewen >>> Subject: [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior >>> >>> Hello everyone. I am trying to implement Network Support in Rust std for >>> UEFI. While trying to use the TCP6_PROTOCOL, I am not quite sure how to >>> deal with destructing the protocol. Since TCP6_PROTOCOL is created using >>> a EFI_SERVICE_BINDING_PROTCOL, it should be destroyed using the >>> `DestroyChild()` method. However, do I also have to call >>> `TCP6_PROTOCOL->Close()` before this or will `DestroyChild()` do that >>> implicitly? If I do have to call this method myself, then do I need to >>> do `DestroyChild()` in the `CloseToken->Event->NotifyFunction` or is it >>> fine to `DestroyChild()` after calling `Close()` (event though `Close` >>> is nonblocking) ? >>> >>> >>> Also, it would be great if someone can point me to some TCP Network >>> applications. I did find some but most were either drivers, or were very >>> simple and did not do any Cleanup stuff. >>> >>> >>> Note: Rust does not need the user to close the connection manually. It >>> is closed once the object is dropped (which is done once the object >>> owner goes out of scope at compile time). >>> >>> >>> Yours Sincerely >>> >>> Ayush Singh