3 #include <aros/libcall.h>
4 #include <libraries/bsdsocket.h>
5 #include <utility/tagitem.h>
6 #include <proto/utility.h>
7 #include <api/amiga_api.h>
8 #include <net/if_protos.h>
9 #include <netinet/in.h>
11 long __QueryInterfaceTagList(STRPTR name
, const struct TagItem
*tags
, struct SocketBase
* libPtr
)
17 D(bug("[AROSTCP] amiga_netstat.c: __QueryInterfaceTagList()\n"));
22 while (tag
= NextTagItem((struct TagItem
**)&tags
)) {
25 case IFQ_HardwareAddressSize
:
27 *((ULONG
*)tag
->ti_Data
) = ifp
->if_addrlen
;
32 *((ULONG
*)tag
->ti_Data
) = ifp
->if_mtu
;
37 *((ULONG
*)tag
->ti_Data
) = ifp
->if_baudrate
;
40 case IFQ_PacketsReceived
:
42 *((ULONG
*)tag
->ti_Data
) = ifp
->if_ipackets
;
47 *((ULONG
*)tag
->ti_Data
) = ifp
->if_opackets
;
52 // log(LOG_CRIT, "IFQ_BadData is not implemented");
53 *((ULONG
*)tag
->ti_Data
) = 0; /*** TODO ***/
58 // log(LOG_CRIT, "IFQ_Overruns is not implemented");
59 *((ULONG
*)tag
->ti_Data
) = 0;
62 case IFQ_UnknownTypes
:
64 *((ULONG
*)tag
->ti_Data
) = ifp
->if_noproto
;
69 memcpy((void *)tag
->ti_Data
, &ifp
->if_data
.ifi_aros_ontime
, sizeof(struct timeval
));
72 // log(LOG_CRIT, "IFQ_Address is not implemented");
73 *(STRPTR
)tag
->ti_Data
= 0;
76 case IFQ_DestinationAddress
:
78 // log(LOG_CRIT, "IFQ_DestinationAddress is not implemented");
79 *(STRPTR
)tag
->ti_Data
= 0;
82 case IFQ_BroadcastAddress
:
84 // log(LOG_CRIT, "IFQ_BroadcastAddress is not implemented");
85 *(STRPTR
)tag
->ti_Data
= 0;
90 // log(LOG_CRIT, "IFQ_NetMask is not implemented");
91 *(STRPTR
)tag
->ti_Data
= 0;
96 *((ULONG
*)tag
->ti_Data
) = ifp
->if_metric
;
101 *((LONG
*)tag
->ti_Data
) = (ifp
->if_flags
& IFF_UP
) ? SM_Up
: SM_Down
;
104 case IFQ_AddressBindType
:
106 /*** TODO: this is not 100% correct, there is also IFABT_Unknown ***/
107 if (ifp
->if_data
.ifi_aros_usedhcp
)
108 *((LONG
*)tag
->ti_Data
) = IFABT_Dynamic
;
110 *((LONG
*)tag
->ti_Data
) = IFABT_Static
;
113 case IFQ_AddressLeaseExpires
:
115 /* Implementing this requires */
116 bzero((void *)tag
->ti_Data
, sizeof(struct DateStamp
)); /* tighter integration of dhclient */
117 break; /* and kernel. Left for better times */
119 case IFQ_PrimaryDNSAddress
:
120 case IFQ_SecondaryDNSAddress
:
122 bzero((void *)tag
->ti_Data
, sizeof(struct sockaddr_in
)); /* See above. In addition we don't */
123 break; /* know what is SANA-IIR4 yet */
127 ((SBQUAD_T
*)tag
->ti_Data
)->sbq_High
= 0;
128 ((SBQUAD_T
*)tag
->ti_Data
)->sbq_Low
= ifp
->if_ibytes
;
131 case IFQ_GetBytesOut
:
133 ((SBQUAD_T
*)tag
->ti_Data
)->sbq_High
= 0;
134 ((SBQUAD_T
*)tag
->ti_Data
)->sbq_Low
= ifp
->if_obytes
;
139 if ((ifp
->if_query
) && (ifp
->if_query(ifp
, tag
) == 0))
141 *((ULONG
*)tag
->ti_Data
) = 0;
148 writeErrnoValue(libPtr
, ENXIO
);
153 #if defined(__CONFIG_ROADSHOW__)
154 AROS_LH2(long, QueryInterfaceTagList
,
155 AROS_LHA(STRPTR
, name
, A0
),
156 AROS_LHA(struct TagItem
*, tags
, A1
),
157 struct SocketBase
*, libPtr
, 78, UL
)
161 #if defined(__AROS__)
162 D(bug("[AROSTCP.RS] amiga_netstat.c: QueryInterfaceTagList()\n"));
165 return __QueryInterfaceTagList(name
, tags
, libPtr
);