/*
 * mars-nwe-dosutils - NetWare/DOS utility tools.
 *
 * Copyright (C) 2026 Mario Fetka
 * Copyright (C) 1993,1996 Martin Stover, Marburg, Germany
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Purpose: C declarations for IPX packet structures and low-level IPX/far-memory assembly glue.
 * Depends on: ipx.asm for Open Watcom builds, doc/kern.asm for the historical TASM source, and net.h for shared types.
 */

#ifndef IPX_H
#define IPX_H

#if defined(__WATCOMC__)
#define IPX_CALL _Cdecl
#else
#define IPX_CALL
#endif

typedef struct {
   uint8  checksum[2];
   uint16  packetlen;
   uint8  tcontrol;
   uint8  ptype;
   uint8  dest_net[4];
   uint8  dest_node[6];
   uint16  dest_sock;        /* HI LOW */
   uint8  source_net[4];
   uint8  source_node[6];
   uint16  source_sock;      /* HI LOW */
} IPX_HEADER;

typedef struct {
  uint8        *link_address;
  FUNC_VOID    esr_routine;
  uint8        in_use_flag;
  uint8        completition_code;
  uint16       socket;               /* HI LOW                 */
  uint8        ipx_workspace[4];      /* interner Gebrauch      */
  uint8        drv_workspace[4];      /* interner Gebrauch      */
  uint8        immediate_address[6];  /* HI LOW Node Address    */
  uint16       fragment_count;        /* Anzahl Fragment Buffers */
  uint8        *fragment_1;
  uint16       fragment_1_size;
  /* Können auch mehr sein */
} ECB;

extern int   IPX_CALL IPXinit(void);
extern int   IPX_CALL IPXopen_socket(UI sock, int live);
extern void  IPX_CALL IPXclose_socket(UI sock);
extern int   IPX_CALL IPXlisten(ECB *ecb);
extern void  asm_esr_routine(void);
extern void  esr_routine(ECB *ecb);
extern void  IPX_CALL xmemmove(void *ziel, void *quelle, UI anz);

#undef IPX_CALL

#endif /* IPX_H */
