tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / api / amiga_netstat.c
blob8854b047bc873bb1c92cae106cc27dd1edf097e9
1 #include <conf.h>
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)
13 struct TagItem *tag;
14 struct ifnet *ifp;
16 #if defined(__AROS__)
17 D(bug("[AROSTCP] amiga_netstat.c: __QueryInterfaceTagList()\n"));
18 #endif
20 ifp = ifunit(name);
21 if (ifp) {
22 while (tag = NextTagItem((struct TagItem **)&tags)) {
23 switch (tag->ti_Tag)
25 case IFQ_HardwareAddressSize:
27 *((ULONG *)tag->ti_Data) = ifp->if_addrlen;
28 break;
30 case IFQ_MTU:
32 *((ULONG *)tag->ti_Data) = ifp->if_mtu;
33 break;
35 case IFQ_BPS:
37 *((ULONG *)tag->ti_Data) = ifp->if_baudrate;
38 break;
40 case IFQ_PacketsReceived:
42 *((ULONG *)tag->ti_Data) = ifp->if_ipackets;
43 break;
45 case IFQ_PacketsSent:
47 *((ULONG *)tag->ti_Data) = ifp->if_opackets;
48 break;
50 case IFQ_BadData:
52 // log(LOG_CRIT, "IFQ_BadData is not implemented");
53 *((ULONG *)tag->ti_Data) = 0; /*** TODO ***/
54 break;
56 case IFQ_Overruns:
58 // log(LOG_CRIT, "IFQ_Overruns is not implemented");
59 *((ULONG *)tag->ti_Data) = 0;
60 break;
62 case IFQ_UnknownTypes:
64 *((ULONG *)tag->ti_Data) = ifp->if_noproto;
65 break;
67 case IFQ_LastStart:
69 memcpy((void *)tag->ti_Data, &ifp->if_data.ifi_aros_ontime, sizeof(struct timeval));
70 break;
71 case IFQ_Address:
72 // log(LOG_CRIT, "IFQ_Address is not implemented");
73 *(STRPTR)tag->ti_Data = 0;
74 break;
76 case IFQ_DestinationAddress:
78 // log(LOG_CRIT, "IFQ_DestinationAddress is not implemented");
79 *(STRPTR)tag->ti_Data = 0;
80 break;
82 case IFQ_BroadcastAddress:
84 // log(LOG_CRIT, "IFQ_BroadcastAddress is not implemented");
85 *(STRPTR)tag->ti_Data = 0;
86 break;
88 case IFQ_NetMask:
90 // log(LOG_CRIT, "IFQ_NetMask is not implemented");
91 *(STRPTR)tag->ti_Data = 0;
92 break;
94 case IFQ_Metric:
96 *((ULONG *)tag->ti_Data) = ifp->if_metric;
97 break;
99 case IFQ_State:
101 *((LONG *)tag->ti_Data) = (ifp->if_flags & IFF_UP) ? SM_Up : SM_Down;
102 break;
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;
109 else
110 *((LONG *)tag->ti_Data) = IFABT_Static;
111 break;
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 */
125 case IFQ_GetBytesIn:
127 ((SBQUAD_T *)tag->ti_Data)->sbq_High = 0;
128 ((SBQUAD_T *)tag->ti_Data)->sbq_Low = ifp->if_ibytes;
129 break;
131 case IFQ_GetBytesOut:
133 ((SBQUAD_T *)tag->ti_Data)->sbq_High = 0;
134 ((SBQUAD_T *)tag->ti_Data)->sbq_Low = ifp->if_obytes;
135 break;
137 default:
139 if ((ifp->if_query) && (ifp->if_query(ifp, tag) == 0))
140 break;
141 *((ULONG *)tag->ti_Data) = 0;
146 return 0;
147 } else {
148 writeErrnoValue(libPtr, ENXIO);
149 return -1;
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)
159 AROS_LIBFUNC_INIT
161 #if defined(__AROS__)
162 D(bug("[AROSTCP.RS] amiga_netstat.c: QueryInterfaceTagList()\n"));
163 #endif
165 return __QueryInterfaceTagList(name, tags, libPtr);
167 AROS_LIBFUNC_EXIT
169 #endif