FRDU:IsValidFriendCode: Difference between revisions

IReir (talk | contribs)
Created page with "=Request= {| class="wikitable" border="1" |- ! Index Word ! Description |- | 0 | Header code [0x00260080] |- | 1-2 | (u64) friend code to validate |} The friend code can be..."
 
TimmSkiller (talk | contribs)
No edit summary
 
Line 1: Line 1:
=Request=
=Request=
{| class="wikitable" border="1"
{{IPC/Request}}
|-
{{IPC/RequestHeader|0x0026|2|0}}
!  Index Word
{{IPC/RequestEntryRange|2|u64, Friend Code}}
!  Description
{{IPC/RequestEnd}}
|-
| 0
| Header code [0x00260080]
|-
| 1-2
| (u64) friend code to validate
|}


The friend code can be derived from the textual form of "1234-5678-9012" by stripping the slashes and then converting the string to an integer.
=Response=
{{IPC/Request}}
{{#vardefine:ipc_offset|0}}
{{IPC/RequestHeader|0x0026|2|0}}
{{IPC/RequestEntry|Result code}}
{{IPC/RequestEntry|bool, IsValidFriendCode}}
{{IPC/RequestEnd}}
 
=Description=
Returns whether or not the given friend code is valid. The following logic is used (everything is in little-endian byte order):
 
<code>
is_valid = friend_code != 0 &&


This function just calls [[FRDU:PrincipalIdToFriendCode]] with the lower half of the friend code and checks if the checksum byte returned matches the input.
(u32)(friend_code >> 32) <= 127 &&


=Response=
[[FRDU:PrincipalIdToFriendCode]]((u32)(friend_code & 0xFFFFFFFF)) == friend_code
{| class="wikitable" border="1"
</code>
|-
!  Index Word
!  Description
|-
| 0
| Header code
|-
| 1
| Result code
|-
| 2
| 1 if the provided friend code is valid, 0 otherwise
|}