Mercurial > projects > hoofbaby
comparison deps/Platinum/ThirdParty/Neptune/Source/System/PSP/NptPSPNetwork.cpp @ 0:3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
author | fraserofthenight |
---|---|
date | Mon, 06 Jul 2009 08:06:28 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3425707ddbf6 |
---|---|
1 /***************************************************************** | |
2 | | |
3 | Neptune - Network :: PSP Implementation | |
4 | | |
5 | (c) 2001-2005 Gilles Boccon-Gibod | |
6 | Author: Sylvain Rebaud (sylvain@plutinosoft.com) | |
7 | | |
8 ****************************************************************/ | |
9 | |
10 /*---------------------------------------------------------------------- | |
11 | includes | |
12 +---------------------------------------------------------------------*/ | |
13 #include "NptNetwork.h" | |
14 | |
15 /*---------------------------------------------------------------------- | |
16 | NPT_NetworkInterface::GetNetworkInterfaces | |
17 +---------------------------------------------------------------------*/ | |
18 NPT_Result | |
19 NPT_NetworkInterface::GetNetworkInterfaces(NPT_List<NPT_NetworkInterface*>& interfaces) | |
20 { | |
21 union SceNetApctlInfo info; | |
22 int ret = sceNetApctlGetInfo(SCE_NET_APCTL_INFO_IP_ADDRESS, &info); | |
23 if (ret < 0) { | |
24 return NPT_FAILURE; | |
25 } | |
26 NPT_IpAddress primary_address; | |
27 if (NPT_FAILED(primary_address.Parse(info.ip_address))) { | |
28 return NPT_FAILURE; | |
29 } | |
30 | |
31 NPT_IpAddress netmask; | |
32 if (NPT_FAILED(netmask.Parse(info.netmask))) { | |
33 return NPT_FAILURE; | |
34 } | |
35 | |
36 NPT_IpAddress broadcast_address; | |
37 NPT_Flags flags = 0; | |
38 flags |= NPT_NETWORK_INTERFACE_FLAG_BROADCAST; | |
39 flags |= NPT_NETWORK_INTERFACE_FLAG_MULTICAST; | |
40 | |
41 // get mac address | |
42 SceNetEtherAddr mac_info; | |
43 ret = sceNetGetLocalEtherAddr(&mac_info); | |
44 if (ret < 0) { | |
45 return NPT_FAILURE; | |
46 } | |
47 NPT_MacAddress mac(TYPE_IEEE_802_11, mac_info.data, SCE_NET_ETHER_ADDR_LEN); | |
48 | |
49 // create an interface object | |
50 char iface_name[5]; | |
51 iface_name[0] = 'i'; | |
52 iface_name[1] = 'f'; | |
53 iface_name[2] = '0'; | |
54 iface_name[3] = '0'; | |
55 iface_name[4] = '\0'; | |
56 NPT_NetworkInterface* iface = new NPT_NetworkInterface(iface_name, mac, flags); | |
57 | |
58 // set the interface address | |
59 NPT_NetworkInterfaceAddress iface_address( | |
60 primary_address, | |
61 broadcast_address, | |
62 NPT_IpAddress::Any, | |
63 netmask); | |
64 iface->AddAddress(iface_address); | |
65 | |
66 // add the interface to the list | |
67 interfaces.Add(iface); | |
68 | |
69 return NPT_SUCCESS; | |
70 } | |
71 |