8#define FRIEND_COMMENT_LEN 16+1
9#define FRIEND_GAME_MODE_DESCRIPTION_LEN 127+1
11#define NASC_INGAMESN_LEN 11+1
12#define NASC_KEYHASH_LEN 8+1
13#define NASC_SVC_LEN 4+1
15#define FRIEND_LIST_SIZE 100
17#define NFS_TYPESTR_LEN 2+1
22typedef u16 ScrambledFriendCode[6];
69 u32 joinAvailabilityFlag;
70 u32 matchmakeSystemType;
75 u8 applicationArg[20];
109 FriendGameModeDescription gameModeDescription;
139 char serverAddress[0x20];
142 char authToken[0x100];
151 char serviceHost[0x80];
152 char serviceToken[0x100];
166 MiiScreenName screenName;
218 NASC_SERVER_UNDER_MAINTENANCE = 101,
219 NASC_DEVICE_BANNED = 102,
220 NASC_INVALID_PRODUCT_CODE = 107,
221 NASC_INVALID_REQUEST_PARAM = 109,
222 NASC_SERVER_NO_LONGER_AVAILABLE = 110,
223 NASC_INVALID_SVC = 112,
224 NASC_INVALID_FPD_VERSION = 119,
225 NASC_INVALID_TITLE_VERSION = 120,
226 NASC_INVALID_DEVICE_CERTIFICATE = 121,
227 NASC_INVALID_PID_HMAC = 122,
228 NASC_BANNED_ROM_ID = 123,
229 NASC_INVALID_GAME_ID = 125,
230 NASC_INVALID_KEY_HASH = 127,
295 NAT_MAPPING_UNKNOWN = 0,
296 NAT_MAPPING_ENDPOINT_INDEPENDENT,
297 NAT_MAPPING_ENDPOINT_DEPENDENT
303 NAT_FILTERING_UNKNOWN = 0,
304 NAT_FILTERING_PORT_INDEPENDENT,
305 NAT_FILTERING_PORT_DEPENDENT
void errorCode(errorConf *err, int error)
Sets error code to display.
Result FRD_GetMyPassword(char *password, u32 bufsize)
Gets the current friend account's NEX password.
Result FRD_GetExtendedNatProperties(u32 *natMappingType, u32 *natFilteringType, u32 *natMappingPortIncrement)
Gets extended NAT properties.
Result FRD_AddFriendWithApproach(u8 *unkbuf, u32 unkbufSize, EncryptedApproachContext *ctx, Handle completionEvent)
Adds a friend using their encrypted approach context.
#define FRIEND_GAME_MODE_DESCRIPTION_LEN
127-character NULL-terminated UTF-16 game mode description
Definition frd.h:9
Result FRD_GetFriendMii(FriendMii *miiList, const FriendKey *friendKeyList, u32 count)
Gets the current user's friends' Mii data.
Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isShowPlayedGame)
Gets the current user's privacy information.
Result FRDA_UpdatePlayingGame(GameKey *playingGame)
Updates the game being played by the current user.
Handle * frdGetSessionHandle(void)
Get the friend user/admin service handle.
Result FRD_GetMyPresence(MyPresence *presence)
Gets the current user's presence information.
Result FRDA_SetNcPrincipalId(u32 ncPrincipalId)
Sets the NcPrincipalId of the current user.
#define NFS_TYPESTR_LEN
2-character NULL-terminated ASCII NFS (Nintendo Friend Server) type string
Definition frd.h:17
Result FRDA_UpdateComment(FriendComment *comment)
Updates the current user's comment (personal message).
Result FRD_GetMyScreenName(MiiScreenName *name)
Gets the current user's screen name.
Result FRD_GetFriendPresence(FriendPresence *friendPresences, const FriendKey *friendKeyList, u32 count)
Gets friend presence data for the current user's friends.
Result FRD_GetFriendComment(FriendComment *comments, u32 commentsLen, const FriendKey *friendKeyList, u32 count)
Gets the comment (personal) message of the current user's friends.
Result FRD_GetMyFavoriteGame(GameKey *favoriteGame)
Gets the current user's favourite game.
Result FRD_GetMyNcPrincipalId(u32 *ncPrincipalId)
Gets the NcPrincipalId for the current user.
Result FRD_RequestServiceLocator(u32 serverId, char *keyhash, char *svc, u8 majorSdkVersion, u8 minorSdkVersion, Handle completionEvent)
Request service locator info for a given NEX server.
Result FRD_GetNatProperties(u32 *natMappingType, u32 *natFilteringType)
Returns NAT properties for the current internet connection.
NASCEnvironment
Enum for NASC Server Environment.
Definition frd.h:235
Result FRD_GetMyProfile(Profile *profile)
Gets the current user's profile information.
Result FRDA_DeleteLocalAccount(u8 localAccountId)
Deletes a local friends account.
Result FRD_IsOnline(bool *state)
Gets the online status of the current user.
Result FRDA_UpdateFavoriteGame(GameKey *favoriteGame)
Updates the current user's favorite game.
FriendAttributes
Enum for friend attributes according to relationship type.
Definition frd.h:287
@ FRIEND_ATTRIBUTE_EVER_REGISTERED
Whether or not the current user has ever been in a friend relationship with the friend....
Definition frd.h:288
@ FRIEND_ATTRIBUTE_REGISTRATION_COMPLETE
Whether or not the current user has been fully registered by this friend. Set only when the relations...
Definition frd.h:289
NASCResult
Enum for NASC Result.
Definition frd.h:216
void frdExit(void)
Exits friend services.
Result FRD_AttachToEventNotification(Handle event)
Registers the event handle that will be signaled to inform the session of various status changes.
Result FRDA_RemoveFriend(u32 principalId, u64 localFriendCode)
Remove a friend.
FriendNotificationMask
Enum for notification event mask.
Definition frd.h:262
Result FRDA_UpdatePreference(bool isPublicMode, bool isShowGameMode, bool isShowPlayedMode)
Updates the current user's friend list preferences.
Result FRD_GetServerTypes(u8 *nascEnvironment, u8 *nfsType, u8 *nfsNo)
Gets the server environment configuration for the current user.
Result FRD_IsValidFriendCode(u64 friendCode, bool *isValid)
Checks if the friend code is valid.
Result FRD_UpdateMyPresence(Presence *presence, FriendGameModeDescription *desc)
Updates the current user's presence data and game mode description.
NatMappingType
Enum for NAT mapping type.
Definition frd.h:294
Result FRD_GetFriendPlayingGame(FriendPlayingGame *playingGames, const FriendKey *friendKeyList, u32 count)
Get the current user's friends' playing game.
Result FRD_SetNotificationMask(FriendNotificationMask mask)
Sets the notification mask for the event notification system.
NatFilteringType
Enum for NAT filtering type.
Definition frd.h:302
Result FRD_GetServiceLocatorData(ServiceLocatorData *data)
Get service locator data requested using FRD_RequestServiceLocator.
Result FRD_GetFriendFavoriteGame(GameKey *favoriteGames, const FriendKey *friendKeyList, u32 count)
Get the current user's friends' favourite games.
Result FRDA_UpdateMii(FriendMii *mii, MiiScreenName *screenName, bool profanityFlag, u8 characterSet)
Updates the current user's Mii.
Result FRD_GetFriendInfo(FriendInfo *infos, const FriendKey *friendKeyList, u32 count, bool maskNonAscii, bool profanityFlag)
Get info about the current user's friends.
Result FRD_HasLoggedIn(bool *state)
Gets the login status of the current user.
Result FRD_DetectNatProperties(Handle completionEvent)
Starts an internal task to determine the NAT properties of the current internet connection.
Result FRD_SetClientSdkVersion(u32 sdkVer)
Sets the Friend API to use a specific SDK version.
Result FRD_GetFriendProfile(Profile *profiles, const FriendKey *friendKeyList, u32 count)
Get the current user's friends' profile data.
Result FRD_GetMyPlayingGame(GameKey *playingGame)
Gets the current user's playing game.
Result FRD_GetMyLocalAccountId(u8 *localAccountId)
Gets the ID of the current local account.
Result FRD_PrincipalIdToFriendCode(u32 principalId, u64 *friendCode)
Returns the friend code using the given principal ID.
Result FRD_GetMiiScreenName(MiiScreenName *screenNames, u32 screenNamesLen, u8 *characterSets, u32 characterSetsLen, const FriendKey *friendKeyList, u32 count, bool maskNonAscii, bool profanityFlag)
Gets screen names for the current user's friends.
Result FRD_SendInvitation(const FriendKey *friendKeyList, u32 count)
Sends an invitation to the current user's friends.
Result FRD_GetEventNotification(NotificationEvent *event, u32 count, u32 *recievedNotifCount)
Get Latest Event Notification.
CharacterSet
Enum for character set.
Definition frd.h:207
@ CHARSET_KOR
Character set for KOR.
Definition frd.h:210
@ CHARSET_TWN
Character set for TWN.
Definition frd.h:211
@ CHARSET_JPN_USA_EUR
Character set for JPN, USA, and EUR(+AUS).
Definition frd.h:208
@ CHARSET_CHN
Character set for CHN.
Definition frd.h:209
Result FRDA_IncrementMoveCount()
Increments the move count in the current local account's save data.
#define FRIEND_COMMENT_LEN
16-character NULL-terminated UTF-16 comment
Definition frd.h:8
Result FRDA_AddFriendOnline(Handle event, u32 principalId)
Adds a friend online ("Internet" option).
Result FRD_GetMyMii(FriendMii *mii)
Gets the current user's Mii data.
Result FRD_UpdateGameModeDescription(FriendGameModeDescription *desc)
Updates the game mode description string.
Result FRD_IsInFriendList(u64 friendCode, bool *isFromList)
Gets whether a friend code is included in the current user's friend list.
Result FRD_GetMyFriendKey(FriendKey *key)
Gets the current user's friend key.
Result FRD_Login(Handle event)
Log in to Nintendo's friend server.
Result FRD_GetMyApproachContext(EncryptedApproachContext *ctx)
Gets the current user's encrypted approach context.
Result FRD_ResultToErrorCode(u32 *errorCode, Result res)
Get a support error code (XXX-YYYY) for the given result code.
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 size)
Gets the current user's friend key list.
Result FRD_Logout(void)
Logs out of Nintendo's friend server.
Result frdInit(bool forceUser)
Initializes friend services.
Result FRD_RequestGameAuthentication(u32 serverId, u16 *ingamesn, u32 ingamesnSize, u8 majorSdkVersion, u8 minorSdkVersion, Handle completionEvent)
Requests game server authentication.
Result FRD_GetFriendAttributeFlags(u32 *attributes, const FriendKey *friendKeyList, u32 count)
Get attributes for the current user's friends.
Result FRD_AllowHalfAwake(bool allow)
Configures the current session to allow or disallow running the friends service in sleep mode (half-a...
Result FRD_GetServerTimeDifference(u64 *diff)
Returns the difference (in nanoseconds) between server time and device time.
Result FRD_GetLastResponseResult()
Get the result of the last internal operation.
Result FRDA_UpdateMiiScreenName(FriendKey *friendKey, MiiScreenName *screenName, u8 characterSet)
Updates a friend's display name.
Result FRD_GetFriendRelationship(u8 *relationships, const FriendKey *friendKeyList, u32 count)
Get the relationship type for the current user's friends.
FriendNotificationTypes
Enum for notification event types.
Definition frd.h:243
@ FRIEND_CHANGED_COMMENT
Friend changed comment.
Definition frd.h:255
@ FRIEND_SENT_ANY_INVITATION
Friend sent invitiation (with nonmatching GameJoinID)
Definition frd.h:257
@ FRIEND_CHANGED_ANY_PRESENCE
Friend Presence changed (with nonmatching GameJoinID)
Definition frd.h:256
@ FRIEND_REGISTERED_USER
Friend registered self as friend.
Definition frd.h:251
@ FRIEND_UPDATED_PROFILE
Friend Profile changed.
Definition frd.h:249
@ FRIEND_CHANGED_GAME_MODE_DESCRIPTION
Friend changed game mode description.
Definition frd.h:253
@ FRIEND_WENT_OFFLINE
Friend went offline.
Definition frd.h:250
@ USER_WENT_ONLINE
Self went online.
Definition frd.h:244
@ USER_WENT_OFFLINE
Self went offline.
Definition frd.h:245
@ FRIEND_CHANGED_FAVORITE_GAME
Friend changed favorite game.
Definition frd.h:254
@ FRIEND_WENT_ONLINE
Friend Went Online.
Definition frd.h:246
@ FRIEND_UPDATED_MII
Friend Mii changed.
Definition frd.h:248
@ FRIEND_UPDATED_PRESENCE
Friend Presence changed (with matching GameJoinID)
Definition frd.h:247
@ FRIEND_SENT_JOINABLE_INVITATION
Friend sent invitation (with matching GameJoinID)
Definition frd.h:252
Result FRDA_UnloadLocalAccount()
Unloads the currently active local account.
Result FRD_FriendCodeToPrincipalId(u64 friendCode, u32 *principalId)
Returns the principal ID using the given friend code.
Result FRDA_AddFriendOffline(FriendKey *friendKey, FriendMii *mii, FriendProfile *friendProfile, MiiScreenName *screenName, bool profanityFlag, u8 characterSet)
Adds a friend offline ("Local" option).
Result FRD_GetGameAuthenticationData(GameAuthenticationData *data)
Get game server authentication data requested using FRD_RequestGameAuthentication.
Result FRD_UnscrambleLocalFriendCode(u64 *unscrambled, ScrambledFriendCode *scrambled, u32 count)
Unscrambles a scrambled friend code.
Result FRD_DecryptApproachContext(DecryptedApproachContext *decryptedContext, EncryptedApproachContext *encryptedContext, bool maskNonAscii, u8 characterSet)
Decrypts an encrypted approach context.
Result FRDA_Save()
Saves all data of the friends module.
Result FRDA_CreateLocalAccount(u8 localAccountId, u8 nascEnvironment, u8 nfsType, u8 nfsNo)
Creates a new local friends account.
Result FRD_GetMyComment(FriendComment *comment)
Gets the current user's comment on their friend profile.
RelationshipType
Enum for friend relationship type.
Definition frd.h:277
@ RELATIONSHIP_INCOMPLETE
Provisionally registered friend.
Definition frd.h:278
@ RELATIONSHIP_DELETED
Relationship was deleted.
Definition frd.h:281
@ RELATIONSHIP_LOCAL
Provisionally registered friend (but this relationship has not been sent to the server yet).
Definition frd.h:282
@ RELATIONSHIP_NOT_FOUND
Friend not registered at all.
Definition frd.h:280
@ RELATIONSHIP_COMPLETE
Fully registered friend.
Definition frd.h:279
Result FRDA_LoadLocalAccount(u8 localAccountId)
Loads a local friends account.
Encrypted inner Approach Context structure.
Definition frd.h:160
Decrypted Approach Context structure.
Definition frd.h:187
bool hasMii
Whether or not this friend has a Mii.
Definition frd.h:192
FriendProfile friendProfile
Friend profile of this friend.
Definition frd.h:197
u8 characterSet
Character set for text data.
Definition frd.h:194
MiiScreenName screenName
UTF-16 screen name of this friend.
Definition frd.h:199
FriendKey friendKey
Friend key of this friend.
Definition frd.h:196
FriendMii mii
Mii data of this friend.
Definition frd.h:198
Encrypted Approach Context structure.
Definition frd.h:172
Friend info structure.
Definition frd.h:114
s64 addedTimestamp
NEX timestamp of when this friend was added to the current user's friend list.
Definition frd.h:116
MiiScreenName screenName
The screen name of this friend.
Definition frd.h:120
FriendKey friendKey
FriendKey of this friend.
Definition frd.h:115
u8 characterSet
The character set used for the text parts of the data of this friend.
Definition frd.h:121
u8 relationship
The type of the relationship with this friend.
Definition frd.h:117
FriendProfile friendProfile
Friend profile data of this friend.
Definition frd.h:119
FriendMii mii
The Mii of this friend.
Definition frd.h:123
Friend key data.
Definition frd.h:30
Friend Mii data.
Definition frd.h:97
u8 characterSet
The character set for text data.
Definition frd.h:99
bool dirtyFlag
Whether or not the Mii is marked as "dirty" (needs to be uploaded to the server).
Definition frd.h:100
MiiData mii
The actual Mii data.
Definition frd.h:102
bool profanityFlag
Whether or not the Mii contains profanity.
Definition frd.h:98
Friend playing game structure.
Definition frd.h:107
GameKey game
Game key of the game.
Definition frd.h:108
Friend presence data.
Definition frd.h:87
Presence presence
The actual presence data.
Definition frd.h:88
bool hasSentInvitation
Whether or not this friend has sent the current user an invitation.
Definition frd.h:90
bool isPresenceLoaded
Whether or not the presence data for this user has been loaded from the server.
Definition frd.h:89
bool found
Whether or not this friend was found.
Definition frd.h:91
Friend profile data.
Definition frd.h:57
Profile profile
Base profile data of this friend.
Definition frd.h:58
GameKey favoriteGame
Favorite game of this friend.
Definition frd.h:59
s64 lastOnlineTimestamp
NEX timestamp of when this friend was last seen online.
Definition frd.h:63
FriendComment personalMessage
Personal message (comment) of this friend.
Definition frd.h:61
u32 ncPrincipalId
NC PrincipalID of this friend.
Definition frd.h:60
Game Authentication Data structure.
Definition frd.h:136
u32 nascResult
NASC result code for the LOGIN operation.
Definition frd.h:137
u16 serverPort
Port of the game server.
Definition frd.h:140
u64 serverTime
NEX timestamp for current server time.
Definition frd.h:143
u32 httpStatusCode
HTTP status code for the NASC LOGIN operation.
Definition frd.h:138
Game key data.
Definition frd.h:38
Shared Base Mii struct.
Definition mii.h:17
Current user's presence data.
Definition frd.h:80
FriendGameModeDescription gameModeDescription
The game mode description of the current user.
Definition frd.h:82
Presence presence
The actual presence data.
Definition frd.h:81
Friend Notification Event structure.
Definition frd.h:128
u8 type
Type of event.
Definition frd.h:129
FriendKey sender
Friend key of friend who caused this notification event to be sent.
Definition frd.h:131
Base presence data.
Definition frd.h:68
Base profile data.
Definition frd.h:46
u8 country
Country code.
Definition frd.h:48
u8 region
The region code for the hardware.
Definition frd.h:47
u8 platform
Platform code.
Definition frd.h:51
u8 area
Area code.
Definition frd.h:49
u8 language
Language code.
Definition frd.h:50
Service Locator Data strcture.
Definition frd.h:148
u8 statusData
statusdata value from the NASC response data.
Definition frd.h:153
u64 serverTime
NEX timestamp for current server time.
Definition frd.h:155
u32 httpStatusCode
HTTP status code for the NASC LOGIN operation.
Definition frd.h:150
u32 nascResult
NASC result code for the SVCLOC operation.
Definition frd.h:149
int64_t s64
64-bit signed integer
Definition types.h:29
#define BIT(n)
Creates a bitmask from a bit number.
Definition types.h:47
uint64_t u64
64-bit unsigned integer
Definition types.h:24
#define CTR_PACKED
Packs a struct (and other types?) so it won't include padding bytes.
Definition types.h:52
uint8_t u8
would be nice if newlib had this already
Definition types.h:21
u32 Handle
Resource handle.
Definition types.h:41
s32 Result
Function result.
Definition types.h:42
uint16_t u16
16-bit unsigned integer
Definition types.h:22
uint32_t u32
32-bit unsigned integer
Definition types.h:23