public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior
@ 2022-07-13 16:44 Ayush Singh
  2022-07-13 17:36 ` Michael D Kinney
  0 siblings, 1 reply; 4+ messages in thread
From: Ayush Singh @ 2022-07-13 16:44 UTC (permalink / raw)
  To: devel; +Cc: michael.d.kinney, mikuback, jabeena.b.gaibusab, jiewen.yao

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior
  2022-07-13 16:44 [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior Ayush Singh
@ 2022-07-13 17:36 ` Michael D Kinney
  2022-07-13 18:30   ` Ayush Singh
  0 siblings, 1 reply; 4+ messages in thread
From: Michael D Kinney @ 2022-07-13 17:36 UTC (permalink / raw)
  To: Ayush Singh, devel@edk2.groups.io, Kinney, Michael D
  Cc: mikuback@linux.microsoft.com, Gaibusab, Jabeena B, Yao, Jiewen

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 <ayushdevel1325@gmail.com>
> Sent: Wednesday, July 13, 2022 9:45 AM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; mikuback@linux.microsoft.com; Gaibusab, Jabeena B
> <jabeena.b.gaibusab@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior
  2022-07-13 17:36 ` Michael D Kinney
@ 2022-07-13 18:30   ` Ayush Singh
  2022-07-15 21:03     ` Ayush Singh
  0 siblings, 1 reply; 4+ messages in thread
From: Ayush Singh @ 2022-07-13 18:30 UTC (permalink / raw)
  To: Kinney, Michael D
  Cc: devel@edk2.groups.io, mikuback@linux.microsoft.com,
	Gaibusab, Jabeena B, Yao, Jiewen

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
<michael.d.kinney@intel.com> 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 <ayushdevel1325@gmail.com>
> > Sent: Wednesday, July 13, 2022 9:45 AM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>; mikuback@linux.microsoft.com; Gaibusab, Jabeena B
> > <jabeena.b.gaibusab@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> > 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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior
  2022-07-13 18:30   ` Ayush Singh
@ 2022-07-15 21:03     ` Ayush Singh
  0 siblings, 0 replies; 4+ messages in thread
From: Ayush Singh @ 2022-07-15 21:03 UTC (permalink / raw)
  To: Kinney, Michael D
  Cc: devel@edk2.groups.io, mikuback@linux.microsoft.com,
	Gaibusab, Jabeena B, Yao, Jiewen

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 = <Empty function that does nothing>

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
> <michael.d.kinney@intel.com> 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 <ayushdevel1325@gmail.com>
>>> Sent: Wednesday, July 13, 2022 9:45 AM
>>> To: devel@edk2.groups.io
>>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; mikuback@linux.microsoft.com; Gaibusab, Jabeena B
>>> <jabeena.b.gaibusab@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
>>> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-15 21:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-13 16:44 [NetworkPkg] Clarification on EFI_TCP6_PROTOCOL Destruction Behavior Ayush Singh
2022-07-13 17:36 ` Michael D Kinney
2022-07-13 18:30   ` Ayush Singh
2022-07-15 21:03     ` Ayush Singh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox