189 |
|
|
190 |
|
|
191 |
|
/* |
192 |
+ |
* Data member wrappers |
193 |
+ |
*/ |
194 |
+ |
|
195 |
+ |
// Big-endian memory accessor |
196 |
+ |
template< int nbytes > |
197 |
+ |
struct nw_memory_helper; |
198 |
+ |
|
199 |
+ |
template<> |
200 |
+ |
struct nw_memory_helper<1> { |
201 |
+ |
static inline uint8 load(void *ptr) { return *((uint8 *)ptr); } |
202 |
+ |
static inline void store(void *ptr, uint8 val) { *((uint8 *)ptr) = val; } |
203 |
+ |
}; |
204 |
+ |
|
205 |
+ |
template<> |
206 |
+ |
struct nw_memory_helper<2> { |
207 |
+ |
static inline uint16 load(void *ptr) { return ntohs(*((uint16 *)ptr)); } |
208 |
+ |
static inline void store(void *ptr, uint16 val) { *((uint16 *)ptr) = htons(val); } |
209 |
+ |
}; |
210 |
+ |
|
211 |
+ |
template<> |
212 |
+ |
struct nw_memory_helper<4> { |
213 |
+ |
static inline uint32 load(void *ptr) { return ntohl(*((uint32 *)ptr)); } |
214 |
+ |
static inline void store(void *ptr, uint32 val) { *((uint32 *)ptr) = htonl(val); } |
215 |
+ |
}; |
216 |
+ |
|
217 |
+ |
// Scalar data member wrapper (specialise for pointer member types?) |
218 |
+ |
template< class type, class public_type > |
219 |
+ |
class nw_scalar_member_helper { |
220 |
+ |
uint8 _pad[sizeof(type)]; |
221 |
+ |
public: |
222 |
+ |
operator public_type () const { |
223 |
+ |
return (public_type)nw_memory_helper<sizeof(type)>::load((void *)this); |
224 |
+ |
} |
225 |
+ |
public_type operator -> () const { |
226 |
+ |
return this->operator public_type (); |
227 |
+ |
} |
228 |
+ |
nw_scalar_member_helper<type, public_type> & operator = (public_type val) { |
229 |
+ |
nw_memory_helper<sizeof(type)>::store((void *)this, (type)val); |
230 |
+ |
return *this; |
231 |
+ |
} |
232 |
+ |
nw_scalar_member_helper<type, public_type> & operator += (int val) { |
233 |
+ |
*this = *this + val; |
234 |
+ |
return *this; |
235 |
+ |
} |
236 |
+ |
nw_scalar_member_helper<type, public_type> & operator -= (int val) { |
237 |
+ |
*this = *this - val; |
238 |
+ |
return *this; |
239 |
+ |
} |
240 |
+ |
nw_scalar_member_helper<type, public_type> & operator &= (int val) { |
241 |
+ |
*this = *this & val; |
242 |
+ |
return *this; |
243 |
+ |
} |
244 |
+ |
nw_scalar_member_helper<type, public_type> & operator |= (int val) { |
245 |
+ |
*this = *this | val; |
246 |
+ |
return *this; |
247 |
+ |
} |
248 |
+ |
}; |
249 |
+ |
|
250 |
+ |
// Predefined member types |
251 |
+ |
typedef nw_scalar_member_helper<uint8, int8> nw_int8; |
252 |
+ |
typedef nw_scalar_member_helper<uint16, int16> nw_int16; |
253 |
+ |
typedef nw_scalar_member_helper<uint32, int32> nw_int32; |
254 |
+ |
typedef nw_scalar_member_helper<uint8, uint8> nw_uint8; |
255 |
+ |
typedef nw_scalar_member_helper<uint16, uint16> nw_uint16; |
256 |
+ |
typedef nw_scalar_member_helper<uint32, uint32> nw_uint32; |
257 |
+ |
typedef nw_scalar_member_helper<int, bool> nw_bool; |
258 |
+ |
typedef nw_scalar_member_helper<uint32, uint8 *> nw_uint8_p; |
259 |
+ |
typedef nw_scalar_member_helper<uint32, void *> nw_void_p; |
260 |
+ |
|
261 |
+ |
struct datab; |
262 |
+ |
typedef nw_scalar_member_helper<uint32, datab *> nw_datab_p; |
263 |
+ |
|
264 |
+ |
struct msgb; |
265 |
+ |
typedef nw_scalar_member_helper<uint32, msgb *> nw_msgb_p; |
266 |
+ |
|
267 |
+ |
struct queue; |
268 |
+ |
typedef nw_scalar_member_helper<uint32, queue *> nw_queue_p; |
269 |
+ |
|
270 |
+ |
struct multicast_node; |
271 |
+ |
typedef nw_scalar_member_helper<uint32, multicast_node *> nw_multicast_node_p; |
272 |
+ |
|
273 |
+ |
struct DLPIStream; |
274 |
+ |
typedef nw_scalar_member_helper<uint32, DLPIStream *> nw_DLPIStream_p; |
275 |
+ |
|
276 |
+ |
|
277 |
+ |
/* |
278 |
|
* Structures |
279 |
|
*/ |
280 |
|
|
281 |
|
// Data block |
282 |
|
struct datab { |
283 |
< |
datab *db_freep; |
284 |
< |
uint8 *db_base; |
285 |
< |
uint8 *db_lim; |
286 |
< |
uint8 db_ref; |
287 |
< |
uint8 db_type; |
283 |
> |
nw_datab_p db_freep; |
284 |
> |
nw_uint8_p db_base; |
285 |
> |
nw_uint8_p db_lim; |
286 |
> |
nw_uint8 db_ref; |
287 |
> |
nw_uint8 db_type; |
288 |
|
// ... |
289 |
|
}; |
290 |
|
|
291 |
|
// Message block |
292 |
|
struct msgb { |
293 |
< |
msgb *b_next; |
294 |
< |
msgb *b_prev; |
295 |
< |
msgb *b_cont; |
296 |
< |
uint8 *b_rptr; |
297 |
< |
uint8 *b_wptr; |
298 |
< |
datab *b_datap; |
293 |
> |
nw_msgb_p b_next; |
294 |
> |
nw_msgb_p b_prev; |
295 |
> |
nw_msgb_p b_cont; |
296 |
> |
nw_uint8_p b_rptr; |
297 |
> |
nw_uint8_p b_wptr; |
298 |
> |
nw_datab_p b_datap; |
299 |
|
// ... |
300 |
|
}; |
301 |
|
|
302 |
|
// Queue (full structure required because of size) |
303 |
|
struct queue { |
304 |
< |
void *q_qinfo; |
305 |
< |
msgb *q_first; |
306 |
< |
msgb *q_last; |
307 |
< |
queue *q_next; |
308 |
< |
queue *q_link; |
309 |
< |
void *q_ptr; |
310 |
< |
uint32 q_count; |
311 |
< |
int32 q_minpsz; |
312 |
< |
int32 q_maxpsz; |
313 |
< |
uint32 q_hiwat; |
314 |
< |
uint32 q_lowat; |
315 |
< |
void *q_bandp; |
316 |
< |
uint16 q_flag; |
317 |
< |
uint8 q_nband; |
318 |
< |
uint8 q_pad1[1]; |
319 |
< |
void *q_osx; |
320 |
< |
queue *q_ffcp; |
321 |
< |
queue *q_bfcp; |
304 |
> |
nw_void_p q_qinfo; |
305 |
> |
nw_msgb_p q_first; |
306 |
> |
nw_msgb_p q_last; |
307 |
> |
nw_queue_p q_next; |
308 |
> |
nw_queue_p q_link; |
309 |
> |
nw_DLPIStream_p q_ptr; |
310 |
> |
nw_uint32 q_count; |
311 |
> |
nw_int32 q_minpsz; |
312 |
> |
nw_int32 q_maxpsz; |
313 |
> |
nw_uint32 q_hiwat; |
314 |
> |
nw_uint32 q_lowat; |
315 |
> |
nw_void_p q_bandp; |
316 |
> |
nw_uint16 q_flag; |
317 |
> |
nw_uint8 q_nband; |
318 |
> |
uint8 _q_pad1[1]; |
319 |
> |
nw_void_p q_osx; |
320 |
> |
nw_queue_p q_ffcp; |
321 |
> |
nw_queue_p q_bfcp; |
322 |
|
}; |
323 |
|
typedef struct queue queue_t; |
324 |
|
|
325 |
|
// M_IOCTL parameters |
326 |
|
struct iocblk { |
327 |
< |
int32 ioc_cmd; |
328 |
< |
void *ioc_cr; |
329 |
< |
uint32 ioc_id; |
330 |
< |
uint32 ioc_count; |
331 |
< |
int32 ioc_error; |
332 |
< |
int32 ioc_rval; |
333 |
< |
int32 ioc_filler[4]; |
327 |
> |
nw_int32 ioc_cmd; |
328 |
> |
nw_void_p ioc_cr; |
329 |
> |
nw_uint32 ioc_id; |
330 |
> |
nw_uint32 ioc_count; |
331 |
> |
nw_int32 ioc_error; |
332 |
> |
nw_int32 ioc_rval; |
333 |
> |
int32 _ioc_filler[4]; |
334 |
|
}; |
335 |
|
|
336 |
|
// Priority specification |
337 |
|
struct dl_priority_t { |
338 |
< |
int32 dl_min, dl_max; |
338 |
> |
nw_int32 dl_min, dl_max; |
339 |
|
}; |
340 |
|
|
341 |
|
// DPLI primitives |
342 |
|
struct dl_info_req_t { |
343 |
< |
uint32 dl_primitive; // DL_INFO_REQ |
343 |
> |
nw_uint32 dl_primitive; // DL_INFO_REQ |
344 |
|
}; |
345 |
|
|
346 |
|
struct dl_info_ack_t { |
347 |
< |
uint32 dl_primitive; // DL_INFO_ACK |
348 |
< |
uint32 dl_max_sdu; |
349 |
< |
uint32 dl_min_sdu; |
350 |
< |
uint32 dl_addr_length; |
351 |
< |
uint32 dl_mac_type; |
352 |
< |
uint32 dl_reserved; |
353 |
< |
uint32 dl_current_state; |
354 |
< |
int32 dl_sap_length; |
355 |
< |
uint32 dl_service_mode; |
356 |
< |
uint32 dl_qos_length; |
357 |
< |
uint32 dl_qos_offset; |
358 |
< |
uint32 dl_qos_range_length; |
359 |
< |
uint32 dl_qos_range_offset; |
360 |
< |
uint32 dl_provider_style; |
361 |
< |
uint32 dl_addr_offset; |
362 |
< |
uint32 dl_version; |
363 |
< |
uint32 dl_brdcst_addr_length; |
364 |
< |
uint32 dl_brdcst_addr_offset; |
365 |
< |
uint32 dl_growth; |
347 |
> |
nw_uint32 dl_primitive; // DL_INFO_ACK |
348 |
> |
nw_uint32 dl_max_sdu; |
349 |
> |
nw_uint32 dl_min_sdu; |
350 |
> |
nw_uint32 dl_addr_length; |
351 |
> |
nw_uint32 dl_mac_type; |
352 |
> |
nw_uint32 dl_reserved; |
353 |
> |
nw_uint32 dl_current_state; |
354 |
> |
nw_int32 dl_sap_length; |
355 |
> |
nw_uint32 dl_service_mode; |
356 |
> |
nw_uint32 dl_qos_length; |
357 |
> |
nw_uint32 dl_qos_offset; |
358 |
> |
nw_uint32 dl_qos_range_length; |
359 |
> |
nw_uint32 dl_qos_range_offset; |
360 |
> |
nw_uint32 dl_provider_style; |
361 |
> |
nw_uint32 dl_addr_offset; |
362 |
> |
nw_uint32 dl_version; |
363 |
> |
nw_uint32 dl_brdcst_addr_length; |
364 |
> |
nw_uint32 dl_brdcst_addr_offset; |
365 |
> |
nw_uint32 dl_growth; |
366 |
|
}; |
367 |
|
|
368 |
|
struct dl_bind_req_t { |
369 |
< |
uint32 dl_primitive; // DL_BIND_REQ |
370 |
< |
uint32 dl_sap; |
371 |
< |
uint32 dl_max_conind; |
372 |
< |
uint16 dl_service_mode; |
373 |
< |
uint16 dl_conn_mgmt; |
374 |
< |
uint32 dl_xidtest_flg; |
369 |
> |
nw_uint32 dl_primitive; // DL_BIND_REQ |
370 |
> |
nw_uint32 dl_sap; |
371 |
> |
nw_uint32 dl_max_conind; |
372 |
> |
nw_uint16 dl_service_mode; |
373 |
> |
nw_uint16 dl_conn_mgmt; |
374 |
> |
nw_uint32 dl_xidtest_flg; |
375 |
|
}; |
376 |
|
|
377 |
|
struct dl_bind_ack_t { |
378 |
< |
uint32 dl_primitive; // DL_BIND_ACK |
379 |
< |
uint32 dl_sap; |
380 |
< |
uint32 dl_addr_length; |
381 |
< |
uint32 dl_addr_offset; |
382 |
< |
uint32 dl_max_conind; |
383 |
< |
uint32 dl_xidtest_flg; |
378 |
> |
nw_uint32 dl_primitive; // DL_BIND_ACK |
379 |
> |
nw_uint32 dl_sap; |
380 |
> |
nw_uint32 dl_addr_length; |
381 |
> |
nw_uint32 dl_addr_offset; |
382 |
> |
nw_uint32 dl_max_conind; |
383 |
> |
nw_uint32 dl_xidtest_flg; |
384 |
|
}; |
385 |
|
|
386 |
|
struct dl_error_ack_t { |
387 |
< |
uint32 dl_primitive; // DL_ERROR_ACK |
388 |
< |
uint32 dl_error_primitive; |
389 |
< |
uint32 dl_errno; |
390 |
< |
uint32 dl_unix_errno; |
387 |
> |
nw_uint32 dl_primitive; // DL_ERROR_ACK |
388 |
> |
nw_uint32 dl_error_primitive; |
389 |
> |
nw_uint32 dl_errno; |
390 |
> |
nw_uint32 dl_unix_errno; |
391 |
|
}; |
392 |
|
|
393 |
|
struct dl_ok_ack_t { |
394 |
< |
uint32 dl_primitive; // DL_ERROR_ACK |
395 |
< |
uint32 dl_correct_primitive; |
394 |
> |
nw_uint32 dl_primitive; // DL_ERROR_ACK |
395 |
> |
nw_uint32 dl_correct_primitive; |
396 |
|
}; |
397 |
|
|
398 |
|
struct dl_unitdata_req_t { |
399 |
< |
uint32 dl_primitive; // DL_UNITDATA_REQ |
400 |
< |
uint32 dl_dest_addr_length; |
401 |
< |
uint32 dl_dest_addr_offset; |
399 |
> |
nw_uint32 dl_primitive; // DL_UNITDATA_REQ |
400 |
> |
nw_uint32 dl_dest_addr_length; |
401 |
> |
nw_uint32 dl_dest_addr_offset; |
402 |
|
dl_priority_t dl_priority; |
403 |
|
}; |
404 |
|
|
405 |
|
struct dl_unitdata_ind_t { |
406 |
< |
uint32 dl_primitive; // DL_UNITDATA_IND |
407 |
< |
uint32 dl_dest_addr_length; |
408 |
< |
uint32 dl_dest_addr_offset; |
409 |
< |
uint32 dl_src_addr_length; |
410 |
< |
uint32 dl_src_addr_offset; |
411 |
< |
uint32 dl_group_address; |
406 |
> |
nw_uint32 dl_primitive; // DL_UNITDATA_IND |
407 |
> |
nw_uint32 dl_dest_addr_length; |
408 |
> |
nw_uint32 dl_dest_addr_offset; |
409 |
> |
nw_uint32 dl_src_addr_length; |
410 |
> |
nw_uint32 dl_src_addr_offset; |
411 |
> |
nw_uint32 dl_group_address; |
412 |
|
}; |
413 |
|
|
414 |
|
struct dl_uderror_ind_t { |
415 |
< |
uint32 dl_primitive; // DL_UDERROR_IND |
416 |
< |
uint32 dl_dest_addr_length; |
417 |
< |
uint32 dl_dest_addr_offset; |
418 |
< |
uint32 dl_unix_errno; |
419 |
< |
uint32 dl_errno; |
415 |
> |
nw_uint32 dl_primitive; // DL_UDERROR_IND |
416 |
> |
nw_uint32 dl_dest_addr_length; |
417 |
> |
nw_uint32 dl_dest_addr_offset; |
418 |
> |
nw_uint32 dl_unix_errno; |
419 |
> |
nw_uint32 dl_errno; |
420 |
|
}; |
421 |
|
|
422 |
|
struct dl_subs_bind_req_t { |
423 |
< |
uint32 dl_primitive; // DL_SUBS_BIND_REQ |
424 |
< |
uint32 dl_subs_sap_offset; |
425 |
< |
uint32 dl_subs_sap_length; |
426 |
< |
uint32 dl_subs_bind_class; |
423 |
> |
nw_uint32 dl_primitive; // DL_SUBS_BIND_REQ |
424 |
> |
nw_uint32 dl_subs_sap_offset; |
425 |
> |
nw_uint32 dl_subs_sap_length; |
426 |
> |
nw_uint32 dl_subs_bind_class; |
427 |
|
}; |
428 |
|
|
429 |
|
struct dl_subs_bind_ack_t { |
430 |
< |
uint32 dl_primitive; // DL_SUBS_BIND_ACK |
431 |
< |
uint32 dl_subs_sap_offset; |
432 |
< |
uint32 dl_subs_sap_length; |
430 |
> |
nw_uint32 dl_primitive; // DL_SUBS_BIND_ACK |
431 |
> |
nw_uint32 dl_subs_sap_offset; |
432 |
> |
nw_uint32 dl_subs_sap_length; |
433 |
|
}; |
434 |
|
|
435 |
|
struct dl_subs_unbind_req_t { |
436 |
< |
uint32 dl_primitive; // DL_SUBS_UNBIND_REQ |
437 |
< |
uint32 dl_subs_sap_offset; |
438 |
< |
uint32 dl_subs_sap_length; |
436 |
> |
nw_uint32 dl_primitive; // DL_SUBS_UNBIND_REQ |
437 |
> |
nw_uint32 dl_subs_sap_offset; |
438 |
> |
nw_uint32 dl_subs_sap_length; |
439 |
|
}; |
440 |
|
|
441 |
|
struct dl_enabmulti_req_t { |
442 |
< |
uint32 dl_primitive; // DL_ENABMULTI_REQ |
443 |
< |
uint32 dl_addr_length; |
444 |
< |
uint32 dl_addr_offset; |
442 |
> |
nw_uint32 dl_primitive; // DL_ENABMULTI_REQ |
443 |
> |
nw_uint32 dl_addr_length; |
444 |
> |
nw_uint32 dl_addr_offset; |
445 |
|
}; |
446 |
|
|
447 |
|
struct dl_disabmulti_req_t { |
448 |
< |
uint32 dl_primitive; // DL_DISABMULTI_REQ |
449 |
< |
uint32 dl_addr_length; |
450 |
< |
uint32 dl_addr_offset; |
448 |
> |
nw_uint32 dl_primitive; // DL_DISABMULTI_REQ |
449 |
> |
nw_uint32 dl_addr_length; |
450 |
> |
nw_uint32 dl_addr_offset; |
451 |
|
}; |
452 |
|
|
453 |
|
struct dl_phys_addr_req_t { |
454 |
< |
uint32 dl_primitive; // DL_PHYS_ADDR_REQ |
455 |
< |
uint32 dl_addr_type; |
454 |
> |
nw_uint32 dl_primitive; // DL_PHYS_ADDR_REQ |
455 |
> |
nw_uint32 dl_addr_type; |
456 |
|
}; |
457 |
|
|
458 |
|
struct dl_phys_addr_ack_t { |
459 |
< |
uint32 dl_primitive; // DL_PHYS_ADDR_ACK |
460 |
< |
uint32 dl_addr_length; |
461 |
< |
uint32 dl_addr_offset; |
459 |
> |
nw_uint32 dl_primitive; // DL_PHYS_ADDR_ACK |
460 |
> |
nw_uint32 dl_addr_length; |
461 |
> |
nw_uint32 dl_addr_offset; |
462 |
|
}; |
463 |
|
|
464 |
|
// Parameters for I_OTSetRawMode/kOTSetRecvMode ioctl() |
465 |
|
struct dl_recv_control_t { |
466 |
< |
uint32 dl_primitive; |
467 |
< |
uint32 dl_flags; |
468 |
< |
uint32 dl_truncation_length; |
466 |
> |
nw_uint32 dl_primitive; |
467 |
> |
nw_uint32 dl_flags; |
468 |
> |
nw_uint32 dl_truncation_length; |
469 |
|
}; |
470 |
|
|
471 |
|
union DL_primitives { |
472 |
< |
uint32 dl_primitive; |
472 |
> |
nw_uint32 dl_primitive; |
473 |
|
dl_info_req_t info_req; |
474 |
|
dl_info_ack_t info_ack; |
475 |
|
dl_bind_req_t bind_req; |
496 |
|
struct EnetPacketHeader { |
497 |
|
uint8 fDestAddr[6]; |
498 |
|
uint8 fSourceAddr[6]; |
499 |
< |
uint16 fProto; |
499 |
> |
nw_uint16 fProto; |
500 |
|
} PACKED__; |
501 |
|
|
502 |
|
struct T8022Header { |
519 |
|
|
520 |
|
struct T8022AddressStruct { |
521 |
|
uint8 fHWAddr[6]; |
522 |
< |
uint16 fSAP; |
522 |
> |
nw_uint16 fSAP; |
523 |
|
uint8 fSNAP[k8022SNAPLength]; |
524 |
|
} PACKED__; |
525 |
|
|