| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: netif_of.c,v 1.8 2011/05/21 15:50:42 tsutsui Exp $ */ | | 1 | /* $NetBSD: netif_of.c,v 1.9 2011/07/30 04:18:38 jakllsch Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (C) 1995 Wolfgang Solfrank. | | 4 | * Copyright (C) 1995 Wolfgang Solfrank. |
5 | * Copyright (C) 1995 TooLs GmbH. | | 5 | * Copyright (C) 1995 TooLs GmbH. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -137,70 +137,70 @@ netif_close(int fd) | | | @@ -137,70 +137,70 @@ netif_close(int fd) |
137 | ssize_t | | 137 | ssize_t |
138 | netif_put(struct iodesc *desc, void *pkt, size_t len) | | 138 | netif_put(struct iodesc *desc, void *pkt, size_t len) |
139 | { | | 139 | { |
140 | struct of_dev *op; | | 140 | struct of_dev *op; |
141 | ssize_t rv; | | 141 | ssize_t rv; |
142 | size_t sendlen; | | 142 | size_t sendlen; |
143 | | | 143 | |
144 | op = ((struct netif *)desc->io_netif)->nif_devdata; | | 144 | op = ((struct netif *)desc->io_netif)->nif_devdata; |
145 | | | 145 | |
146 | #ifdef NETIF_DEBUG | | 146 | #ifdef NETIF_DEBUG |
147 | { | | 147 | { |
148 | struct ether_header *eh; | | 148 | struct ether_header *eh; |
149 | | | 149 | |
150 | printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", | | 150 | printf("netif_put: desc=%p pkt=%p len=%zu\n", |
151 | desc, pkt, len); | | 151 | desc, pkt, len); |
152 | eh = pkt; | | 152 | eh = pkt; |
153 | printf("dst: %s ", ether_sprintf(eh->ether_dhost)); | | 153 | printf("dst: %s ", ether_sprintf(eh->ether_dhost)); |
154 | printf("src: %s ", ether_sprintf(eh->ether_shost)); | | 154 | printf("src: %s ", ether_sprintf(eh->ether_shost)); |
155 | printf("type: 0x%x\n", eh->ether_type & 0xFFFF); | | 155 | printf("type: 0x%x\n", eh->ether_type & 0xFFFF); |
156 | } | | 156 | } |
157 | #endif | | 157 | #endif |
158 | | | 158 | |
159 | sendlen = len; | | 159 | sendlen = len; |
160 | if (sendlen < 60) { | | 160 | if (sendlen < 60) { |
161 | sendlen = 60; | | 161 | sendlen = 60; |
162 | #ifdef NETIF_DEBUG | | 162 | #ifdef NETIF_DEBUG |
163 | printf("netif_put: length padded to %d\n", sendlen); | | 163 | printf("netif_put: length padded to %zu\n", sendlen); |
164 | #endif | | 164 | #endif |
165 | } | | 165 | } |
166 | | | 166 | |
167 | rv = prom_write(op->handle, pkt, sendlen); | | 167 | rv = prom_write(op->handle, pkt, sendlen); |
168 | | | 168 | |
169 | #ifdef NETIF_DEBUG | | 169 | #ifdef NETIF_DEBUG |
170 | printf("netif_put: xmit returned %d\n", rv); | | 170 | printf("netif_put: xmit returned %zd\n", rv); |
171 | #endif | | 171 | #endif |
172 | | | 172 | |
173 | if (rv > len) | | 173 | if (rv > len) |
174 | rv = len; | | 174 | rv = len; |
175 | | | 175 | |
176 | return rv; | | 176 | return rv; |
177 | } | | 177 | } |
178 | | | 178 | |
179 | /* | | 179 | /* |
180 | * Receive a packet, including the ether header. | | 180 | * Receive a packet, including the ether header. |
181 | * Return the total length received (or -1 on error). | | 181 | * Return the total length received (or -1 on error). |
182 | */ | | 182 | */ |
183 | ssize_t | | 183 | ssize_t |
184 | netif_get(struct iodesc *desc, void *pkt, size_t maxlen, saseconds_t timo) | | 184 | netif_get(struct iodesc *desc, void *pkt, size_t maxlen, saseconds_t timo) |
185 | { | | 185 | { |
186 | struct of_dev *op; | | 186 | struct of_dev *op; |
187 | int tick0, tmo_ms; | | 187 | int tick0, tmo_ms; |
188 | int len; | | 188 | int len; |
189 | | | 189 | |
190 | op = ((struct netif *)desc->io_netif)->nif_devdata; | | 190 | op = ((struct netif *)desc->io_netif)->nif_devdata; |
191 | | | 191 | |
192 | #ifdef NETIF_DEBUG | | 192 | #ifdef NETIF_DEBUG |
193 | printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n", | | 193 | printf("netif_get: pkt=%p, maxlen=%zu, tmo=%d\n", |
194 | pkt, maxlen, timo); | | 194 | pkt, maxlen, timo); |
195 | #endif | | 195 | #endif |
196 | | | 196 | |
197 | tmo_ms = timo * 1000; | | 197 | tmo_ms = timo * 1000; |
198 | tick0 = prom_ticks(); | | 198 | tick0 = prom_ticks(); |
199 | | | 199 | |
200 | do { | | 200 | do { |
201 | len = prom_read(op->handle, pkt, maxlen); | | 201 | len = prom_read(op->handle, pkt, maxlen); |
202 | } while ((len == -2 || len == 0) && | | 202 | } while ((len == -2 || len == 0) && |
203 | (prom_ticks() - tick0 < tmo_ms)); | | 203 | (prom_ticks() - tick0 < tmo_ms)); |
204 | | | 204 | |
205 | #ifdef NETIF_DEBUG | | 205 | #ifdef NETIF_DEBUG |
206 | printf("netif_get: received len=%d\n", len); | | 206 | printf("netif_get: received len=%d\n", len); |