ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
netman.h File Reference
#include <tamtypes.h>
+ Include dependency graph for netman.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NetManNetProtStack
 
struct  NetManEthRuntimeStats
 
struct  NetManEthStatus
 
struct  NetManNetIF
 

Macros

#define NETMAN_NETIF_NAME_MAX_LEN   4
 
#define NETMAN_NETIF_FRAME_SIZE   1514
 
#define NETMAN_FRAME_GROUP_SIZE   8
 
#define NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE   0x40
 
#define NETMAN_NETIF_IN_USE   0x80
 
#define NETMAN_NETIF_ETHERNET   1
 
#define NETMAN_NETIF_DIALUP   2
 
#define NETMAN_NETIF_LINK_UP   4
 
#define NETMAN_NETIF_EVF_UP   0x01
 
#define NETMAN_NETIF_EVF_DOWN   0x02
 
#define NETMAN_MAX_NETIF_COUNT   2
 

Enumerations

enum  NETMAN_NETIF_ETH_LINK_MODE {
  NETMAN_NETIF_ETH_LINK_MODE_AUTO = 0 ,
  NETMAN_NETIF_ETH_LINK_MODE_10M_HDX ,
  NETMAN_NETIF_ETH_LINK_MODE_10M_FDX ,
  NETMAN_NETIF_ETH_LINK_MODE_100M_HDX ,
  NETMAN_NETIF_ETH_LINK_MODE_100M_FDX ,
  NETMAN_NETIF_ETH_LINK_MODE_COUNT
}
 
enum  NETMAN_NETIF_ETH_LINK_STATE {
  NETMAN_NETIF_ETH_LINK_STATE_DOWN = 0 ,
  NETMAN_NETIF_ETH_LINK_STATE_UP
}
 
enum  NETMAN_NETIF_IOCTL_CODES {
  NETMAN_NETIF_IOCTL_ETH_GET_MAC = 0x1000 ,
  NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE ,
  NETMAN_NETIF_IOCTL_ETH_GET_RX_EOVERRUN_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADLEN_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADFCS_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADALIGN_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_TX_ELOSSCR_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_TX_EEDEFER_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_TX_ECOLL_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_TX_EUNDERRUN_CNT ,
  NETMAN_NETIF_IOCTL_ETH_GET_STATUS ,
  NETMAN_NETIF_IOCTL_ETH_SET_LINK_MODE ,
  NETMAN_NETIF_IOCTL_GET_LINK_STATUS = 0x3000 ,
  NETMAN_NETIF_IOCTL_GET_TX_DROPPED_COUNT ,
  NETMAN_NETIF_IOCTL_GET_RX_DROPPED_COUNT
}
 

Functions

int NetManInit (void)
 
void NetManDeinit (void)
 
int NetManGetGlobalNetIFLinkState (void)
 
int NetManSetMainIF (const char *name)
 
int NetManQueryMainIF (char *name)
 
int NetManRegisterNetworkStack (const struct NetManNetProtStack *stack)
 
void NetManUnregisterNetworkStack (void)
 
int NetManIoctl (unsigned int command, void *args, unsigned int args_len, void *output, unsigned int length)
 
int NetManSetLinkMode (int mode)
 
void NetManNetIFXmit (void)
 
void * NetManNetProtStackAllocRxPacket (unsigned int length, void **payload)
 
void NetManNetProtStackFreeRxPacket (void *packet)
 
void NetManNetProtStackEnQRxPacket (void *packet)
 
int NetManTxPacketNext (void **payload)
 
void NetManTxPacketDeQ (void)
 
int NetManTxPacketAfter (void **payload)
 
void NetManNetProtStackReallocRxPacket (void *packet, unsigned int length)
 
int NetManRegisterNetIF (struct NetManNetIF *NetIF)
 
void NetManUnregisterNetIF (const char *name)
 
void NetManToggleNetIFLinkState (int NetIFID, unsigned char state)
 

Detailed Description

Netman common definitions

Definition in file netman.h.

Macro Definition Documentation

◆ NETMAN_FRAME_GROUP_SIZE

#define NETMAN_FRAME_GROUP_SIZE   8

Definition at line 14 of file netman.h.

◆ NETMAN_MAX_NETIF_COUNT

#define NETMAN_MAX_NETIF_COUNT   2

Definition at line 163 of file netman.h.

◆ NETMAN_NETIF_DIALUP

#define NETMAN_NETIF_DIALUP   2

Set = network IF is a dailup modem.

Definition at line 143 of file netman.h.

◆ NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE

#define NETMAN_NETIF_ETH_LINK_DISABLE_PAUSE   0x40

Flow-control

Definition at line 50 of file netman.h.

◆ NETMAN_NETIF_ETHERNET

#define NETMAN_NETIF_ETHERNET   1

Set = network IF is an Ethernet IF.

Definition at line 141 of file netman.h.

◆ NETMAN_NETIF_EVF_DOWN

#define NETMAN_NETIF_EVF_DOWN   0x02

Definition at line 161 of file netman.h.

◆ NETMAN_NETIF_EVF_UP

#define NETMAN_NETIF_EVF_UP   0x01

Definition at line 160 of file netman.h.

◆ NETMAN_NETIF_FRAME_SIZE

#define NETMAN_NETIF_FRAME_SIZE   1514

Definition at line 13 of file netman.h.

◆ NETMAN_NETIF_IN_USE

#define NETMAN_NETIF_IN_USE   0x80

Set internally by NETMAN. Do not set externally.

Definition at line 139 of file netman.h.

◆ NETMAN_NETIF_LINK_UP

#define NETMAN_NETIF_LINK_UP   4

Set = network IF has a link up status.

Definition at line 145 of file netman.h.

◆ NETMAN_NETIF_NAME_MAX_LEN

#define NETMAN_NETIF_NAME_MAX_LEN   4

Definition at line 12 of file netman.h.

Enumeration Type Documentation

◆ NETMAN_NETIF_ETH_LINK_MODE

Enumerator
NETMAN_NETIF_ETH_LINK_MODE_AUTO 

Auto negotiation cannot be reflected by NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE.

NETMAN_NETIF_ETH_LINK_MODE_10M_HDX 

10Mbit Half-DupleX

NETMAN_NETIF_ETH_LINK_MODE_10M_FDX 

10Mbit Full-DupleX

NETMAN_NETIF_ETH_LINK_MODE_100M_HDX 

100Mbit Half-DupleX

NETMAN_NETIF_ETH_LINK_MODE_100M_FDX 

100Mbit Full-DupleX

NETMAN_NETIF_ETH_LINK_MODE_COUNT 

Definition at line 52 of file netman.h.

52  {
63 
65 };
@ NETMAN_NETIF_ETH_LINK_MODE_100M_HDX
Definition: netman.h:60
@ NETMAN_NETIF_ETH_LINK_MODE_COUNT
Definition: netman.h:64
@ NETMAN_NETIF_ETH_LINK_MODE_10M_FDX
Definition: netman.h:58
@ NETMAN_NETIF_ETH_LINK_MODE_10M_HDX
Definition: netman.h:56
@ NETMAN_NETIF_ETH_LINK_MODE_AUTO
Definition: netman.h:54
@ NETMAN_NETIF_ETH_LINK_MODE_100M_FDX
Definition: netman.h:62

◆ NETMAN_NETIF_ETH_LINK_STATE

Enumerator
NETMAN_NETIF_ETH_LINK_STATE_DOWN 
NETMAN_NETIF_ETH_LINK_STATE_UP 

Definition at line 67 of file netman.h.

67  {
70 };
@ NETMAN_NETIF_ETH_LINK_STATE_DOWN
Definition: netman.h:68
@ NETMAN_NETIF_ETH_LINK_STATE_UP
Definition: netman.h:69

◆ NETMAN_NETIF_IOCTL_CODES

Enumerator
NETMAN_NETIF_IOCTL_ETH_GET_MAC 

Output = 6 bytes of MAC address.

NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE 
NETMAN_NETIF_IOCTL_ETH_GET_RX_EOVERRUN_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADLEN_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADFCS_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADALIGN_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_TX_ELOSSCR_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_TX_EEDEFER_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_TX_ECOLL_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_TX_EUNDERRUN_CNT 
NETMAN_NETIF_IOCTL_ETH_GET_STATUS 
NETMAN_NETIF_IOCTL_ETH_SET_LINK_MODE 

Input = struct NetManIFLinkModeParams. Note: does not wait for the IF to finish. Use NetManSetLinkMode() instead.

NETMAN_NETIF_IOCTL_GET_LINK_STATUS 
NETMAN_NETIF_IOCTL_GET_TX_DROPPED_COUNT 
NETMAN_NETIF_IOCTL_GET_RX_DROPPED_COUNT 

Definition at line 72 of file netman.h.

72  {
73  // Ethernet I/F-only IOCTL codes
76  //Function codes with no input and no output; the result is in the return value.
86  //Returns struct NetManEthStatus
88 
91 
92  // Dial-up I/F-only IOCTL codes
93  // 0x2000
94 
95  // Common IOCTL codes
99 };
@ NETMAN_NETIF_IOCTL_ETH_GET_LINK_MODE
Definition: netman.h:77
@ NETMAN_NETIF_IOCTL_GET_LINK_STATUS
Definition: netman.h:96
@ NETMAN_NETIF_IOCTL_ETH_GET_STATUS
Definition: netman.h:87
@ NETMAN_NETIF_IOCTL_ETH_GET_RX_EOVERRUN_CNT
Definition: netman.h:78
@ NETMAN_NETIF_IOCTL_ETH_GET_TX_EUNDERRUN_CNT
Definition: netman.h:85
@ NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADLEN_CNT
Definition: netman.h:79
@ NETMAN_NETIF_IOCTL_GET_TX_DROPPED_COUNT
Definition: netman.h:97
@ NETMAN_NETIF_IOCTL_ETH_GET_TX_ECOLL_CNT
Definition: netman.h:84
@ NETMAN_NETIF_IOCTL_ETH_GET_TX_ELOSSCR_CNT
Definition: netman.h:82
@ NETMAN_NETIF_IOCTL_ETH_GET_MAC
Definition: netman.h:75
@ NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADFCS_CNT
Definition: netman.h:80
@ NETMAN_NETIF_IOCTL_GET_RX_DROPPED_COUNT
Definition: netman.h:98
@ NETMAN_NETIF_IOCTL_ETH_GET_TX_EEDEFER_CNT
Definition: netman.h:83
@ NETMAN_NETIF_IOCTL_ETH_SET_LINK_MODE
Definition: netman.h:90
@ NETMAN_NETIF_IOCTL_ETH_GET_RX_EBADALIGN_CNT
Definition: netman.h:81

Function Documentation

◆ NetManDeinit()

void NetManDeinit ( void  )

Definition at line 58 of file netman.c.

59 {
60  if(IsInitialized)
61  {
63 
66  IsInitialized = 0;
67  }
68 }
void NetManUnregisterNetworkStack(void)
Definition: netman.c:92
static unsigned char IsInitialized
Definition: netman.c:12
void NetManDeinitRPCClient(void)
Definition: rpc_client.c:160
void NetManDeinitRPCServer(void)
Definition: rpc_server.c:236

References IsInitialized, NetManDeinitRPCClient(), NetManDeinitRPCServer(), and NetManUnregisterNetworkStack().

Referenced by main().

◆ NetManGetGlobalNetIFLinkState()

int NetManGetGlobalNetIFLinkState ( void  )

Definition at line 27 of file netman.c.

28 {
29  return NIFLinkState;
30 }
static char NIFLinkState
Definition: netman.c:13

References NIFLinkState.

◆ NetManInit()

int NetManInit ( void  )

Definition at line 43 of file netman.c.

44 {
45  int result;
46 
47  if(!IsInitialized)
48  {
49  if((result=NetManInitRPCServer())==0)
50  {
52  }
53  }else result = 0;
54 
55  return result;
56 }
s32 result
Definition: rpc_client.c:23
int NetManInitRPCClient(void)
Definition: rpc_client.c:57
int NetManInitRPCServer(void)
Definition: rpc_server.c:209

References IsInitialized, NetManInitRPCClient(), NetManInitRPCServer(), and result.

Referenced by main(), NetManRegisterNetworkStack(), and ps2ipInit().

◆ NetManIoctl()

int NetManIoctl ( unsigned int  command,
void *  args,
unsigned int  args_len,
void *  output,
unsigned int  length 
)

Definition at line 109 of file netman.c.

110 {
111  return IsInitialized?NetManRpcIoctl(command, arg, arg_len, output, length):-1;
112 }
s32 command
Definition: libpad.c:156
int NetManRpcIoctl(unsigned int command, void *arg, unsigned int arg_len, void *output, unsigned int length)
Definition: rpc_client.c:173

References command, IsInitialized, and NetManRpcIoctl().

Referenced by ethGetNetIFLinkStatus(), ethPrintLinkStatus(), and SMapIFInit().

◆ NetManNetIFXmit()

void NetManNetIFXmit ( void  )

Definition at line 103 of file netman.c.

104 {
105  if(IsInitialized)
107 }
void NetManRpcNetIFXmit(void)
Definition: rpc_client.c:284

References IsInitialized, and NetManRpcNetIFXmit().

Referenced by SMapLowLevelOutput().

◆ NetManNetProtStackAllocRxPacket()

void* NetManNetProtStackAllocRxPacket ( unsigned int  length,
void **  payload 
)

Definition at line 114 of file netman.c.

115 {
117 }
static unsigned char IsNetStackInitialized
Definition: netman.c:12
static struct NetManNetProtStack MainNetProtStack
Definition: netman.c:11
void *(* AllocRxPacket)(unsigned int size, void **payload)
Definition: netman.h:19
#define NULL
Definition: tamtypes.h:91

References NetManNetProtStack::AllocRxPacket, IsNetStackInitialized, MainNetProtStack, and NULL.

Referenced by NETMAN_RxThread(), and NetManRPCAllocRxBuffers().

◆ NetManNetProtStackEnQRxPacket()

void NetManNetProtStackEnQRxPacket ( void *  packet)

Definition at line 124 of file netman.c.

125 {
128 }
packet_t packet
Definition: font.c:24
void(* EnQRxPacket)(void *packet)
Definition: netman.h:21

References NetManNetProtStack::EnQRxPacket, IsNetStackInitialized, MainNetProtStack, and packet.

Referenced by NETMAN_RxThread().

◆ NetManNetProtStackFreeRxPacket()

void NetManNetProtStackFreeRxPacket ( void *  packet)

Definition at line 119 of file netman.c.

120 {
122 }
void(* FreeRxPacket)(void *packet)
Definition: netman.h:20

References NetManNetProtStack::FreeRxPacket, IsNetStackInitialized, MainNetProtStack, and packet.

◆ NetManNetProtStackReallocRxPacket()

void NetManNetProtStackReallocRxPacket ( void *  packet,
unsigned int  length 
)

Definition at line 146 of file netman.c.

147 {
149 }
void(* ReallocRxPacket)(void *packet, unsigned int size)
Definition: netman.h:25

References IsNetStackInitialized, MainNetProtStack, packet, and NetManNetProtStack::ReallocRxPacket.

Referenced by NETMAN_RxThread().

◆ NetManQueryMainIF()

int NetManQueryMainIF ( char *  name)

Definition at line 309 of file rpc_client.c.

310 {
311  int result;
312 
313  if (!IsInitialized)
314  return -1;
315 
317 
319  {
320  if((result=ReceiveBuffer.QueryMainNetIFResult.result) == 0)
321  {
322  strncpy(name, ReceiveBuffer.QueryMainNetIFResult.name, NETMAN_NETIF_NAME_MAX_LEN);
323  name[NETMAN_NETIF_NAME_MAX_LEN-1] = '\0';
324  }
325  }
326 
328 
329  return result;
330 }
s32 SignalSema(s32 sema_id)
s32 WaitSema(s32 sema_id)
#define NETMAN_NETIF_NAME_MAX_LEN
Definition: netman.h:12
@ NETMAN_IOP_RPC_FUNC_QUERY_MAIN_NETIF
Definition: netman_rpc.h:29
static SifRpcClientData_t NETMAN_rpc_cd
Definition: rpc_client.c:11
static int NetManIOSemaID
Definition: rpc_client.c:30
static unsigned char IsInitialized
Definition: rpc_client.c:38
static union @21 ReceiveBuffer
int SifCallRpc(SifRpcClientData_t *client, int rpc_number, int mode, void *send, int ssize, void *receive, int rsize, SifRpcEndFunc_t end_function, void *end_param)

References IsInitialized, NETMAN_IOP_RPC_FUNC_QUERY_MAIN_NETIF, NETMAN_NETIF_NAME_MAX_LEN, NETMAN_rpc_cd, NetManIOSemaID, NULL, ReceiveBuffer, result, SifCallRpc(), SignalSema(), and WaitSema().

◆ NetManRegisterNetIF()

int NetManRegisterNetIF ( struct NetManNetIF NetIF)

◆ NetManRegisterNetworkStack()

int NetManRegisterNetworkStack ( const struct NetManNetProtStack stack)

Definition at line 70 of file netman.c.

71 {
72  int result;
73 
74  if((result=NetManInit())==0)
75  {
77  {
79  {
80  memcpy(&MainNetProtStack, stack, sizeof(MainNetProtStack));
82  if((result=NetManRPCAllocRxBuffers()) == 0)
84  }
85  }
86  else result=0;
87  }
88 
89  return result;
90 }
void NetManUpdateStackNIFLinkState(void)
Definition: netman.c:32
int NetManInit(void)
Definition: netman.c:43
int NetManRPCRegisterNetworkStack(void)
Definition: rpc_client.c:109
int NetManRPCAllocRxBuffers(void)
Definition: rpc_server.c:65

References IsNetStackInitialized, MainNetProtStack, NetManInit(), NetManRPCAllocRxBuffers(), NetManRPCRegisterNetworkStack(), NetManUpdateStackNIFLinkState(), and result.

Referenced by ps2ipInit().

◆ NetManSetLinkMode()

int NetManSetLinkMode ( int  mode)

Definition at line 332 of file rpc_client.c.

333 {
334  int result;
335 
336  if (!IsInitialized)
337  return -1;
338 
340 
341  TransmitBuffer.mode = mode;
343  result=ReceiveBuffer.result;
344 
346 
347  return result;
348 }
@ NETMAN_IOP_RPC_FUNC_SET_LINK_MODE
Definition: netman_rpc.h:30
static union @20 TransmitBuffer
s32 mode
Definition: rpc_client.c:15
signed int s32
Definition: tamtypes.h:58

References IsInitialized, mode, NETMAN_IOP_RPC_FUNC_SET_LINK_MODE, NETMAN_rpc_cd, NetManIOSemaID, NULL, ReceiveBuffer, result, SifCallRpc(), SignalSema(), TransmitBuffer, and WaitSema().

Referenced by ethApplyNetIFConfig().

◆ NetManSetMainIF()

int NetManSetMainIF ( const char *  name)

Definition at line 290 of file rpc_client.c.

291 {
292  int result;
293 
294  if (!IsInitialized)
295  return -1;
296 
298 
299  strncpy(TransmitBuffer.netifName, name, NETMAN_NETIF_NAME_MAX_LEN);
300  TransmitBuffer.netifName[NETMAN_NETIF_NAME_MAX_LEN-1] = '\0';
302  result=ReceiveBuffer.result;
303 
305 
306  return result;
307 }
@ NETMAN_IOP_RPC_FUNC_SET_MAIN_NETIF
Definition: netman_rpc.h:28

References IsInitialized, NETMAN_IOP_RPC_FUNC_SET_MAIN_NETIF, NETMAN_NETIF_NAME_MAX_LEN, NETMAN_rpc_cd, NetManIOSemaID, NULL, ReceiveBuffer, result, SifCallRpc(), SignalSema(), TransmitBuffer, and WaitSema().

◆ NetManToggleNetIFLinkState()

void NetManToggleNetIFLinkState ( int  NetIFID,
unsigned char  state 
)

◆ NetManTxPacketAfter()

int NetManTxPacketAfter ( void **  payload)

Definition at line 141 of file netman.c.

142 {
143  return IsInitialized?MainNetProtStack.AfterTxPacket(payload):-1;
144 }
int(* AfterTxPacket)(void **payload)
Definition: netman.h:24

References NetManNetProtStack::AfterTxPacket, IsInitialized, and MainNetProtStack.

Referenced by NETMAN_TxThread().

◆ NetManTxPacketDeQ()

void NetManTxPacketDeQ ( void  )

Definition at line 135 of file netman.c.

136 {
137  if(IsInitialized)
139 }
void(* DeQTxPacket)(void)
Definition: netman.h:23

References NetManNetProtStack::DeQTxPacket, IsInitialized, and MainNetProtStack.

Referenced by NETMAN_TxThread().

◆ NetManTxPacketNext()

int NetManTxPacketNext ( void **  payload)

Definition at line 130 of file netman.c.

131 {
132  return IsInitialized?MainNetProtStack.NextTxPacket(payload):-1;
133 }
int(* NextTxPacket)(void **payload)
Definition: netman.h:22

References IsInitialized, MainNetProtStack, and NetManNetProtStack::NextTxPacket.

Referenced by NETMAN_TxThread().

◆ NetManUnregisterNetIF()

void NetManUnregisterNetIF ( const char *  name)

◆ NetManUnregisterNetworkStack()

void NetManUnregisterNetworkStack ( void  )

Definition at line 92 of file netman.c.

93 {
95  {
97  memset(&MainNetProtStack, 0, sizeof(MainNetProtStack));
98 
100  }
101 }
int NetManRPCUnregisterNetworkStack(void)
Definition: rpc_client.c:142

References IsNetStackInitialized, MainNetProtStack, and NetManRPCUnregisterNetworkStack().

Referenced by NetManDeinit(), and ps2ipDeinit().