netgraph.c (134789) | netgraph.c (196513) |
---|---|
1/*- 2 * Copyright (c) 2000 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2000 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/netgraph.c 134789 2004-09-05 01:46:52Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/netgraph.c 196513 2009-08-24 17:18:17Z brian $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <sys/un.h> 32#include <netinet/in.h> 33#include <arpa/inet.h> 34#include <netdb.h> --- 195 unchanged lines hidden (view full) --- 230 return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : (ssize_t)n; 231} 232 233static ssize_t 234ng_Read(struct physical *p, void *v, size_t n) 235{ 236 char hook[NG_HOOKSIZ]; 237 | 27 */ 28 29#include <sys/param.h> 30#include <sys/socket.h> 31#include <sys/un.h> 32#include <netinet/in.h> 33#include <arpa/inet.h> 34#include <netdb.h> --- 195 unchanged lines hidden (view full) --- 230 return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : (ssize_t)n; 231} 232 233static ssize_t 234ng_Read(struct physical *p, void *v, size_t n) 235{ 236 char hook[NG_HOOKSIZ]; 237 |
238log_Printf(LogDEBUG, "ng_Read\n"); | |
239 switch (p->dl->state) { 240 case DATALINK_DIAL: 241 case DATALINK_LOGIN: 242 return ng_MessageIn(p, v, n); 243 } 244 245 return NgRecvData(p->fd, v, n, hook); 246} --- 30 unchanged lines hidden (view full) --- 277 close(dev->cs); 278 free(dev); 279} 280 281static void 282ng_device2iov(struct device *d, struct iovec *iov, int *niov, 283 int maxiov __unused, int *auxfd, int *nauxfd) 284{ | 238 switch (p->dl->state) { 239 case DATALINK_DIAL: 240 case DATALINK_LOGIN: 241 return ng_MessageIn(p, v, n); 242 } 243 244 return NgRecvData(p->fd, v, n, hook); 245} --- 30 unchanged lines hidden (view full) --- 276 close(dev->cs); 277 free(dev); 278} 279 280static void 281ng_device2iov(struct device *d, struct iovec *iov, int *niov, 282 int maxiov __unused, int *auxfd, int *nauxfd) 283{ |
285 struct ngdevice *dev = device2ng(d); | 284 struct ngdevice *dev; |
286 int sz = physical_MaxDeviceSize(); 287 | 285 int sz = physical_MaxDeviceSize(); 286 |
288 iov[*niov].iov_base = realloc(d, sz); 289 if (iov[*niov].iov_base == NULL) { | 287 iov[*niov].iov_base = d = realloc(d, sz); 288 if (d == NULL) { |
290 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 291 AbortProgram(EX_OSERR); 292 } 293 iov[*niov].iov_len = sz; 294 (*niov)++; 295 | 289 log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); 290 AbortProgram(EX_OSERR); 291 } 292 iov[*niov].iov_len = sz; 293 (*niov)++; 294 |
295 dev = device2ng(d); |
|
296 *auxfd = dev->cs; 297 (*nauxfd)++; 298} 299 300static const struct device basengdevice = { 301 NG_DEVICE, 302 "netgraph", 303 0, --- 440 unchanged lines hidden --- | 296 *auxfd = dev->cs; 297 (*nauxfd)++; 298} 299 300static const struct device basengdevice = { 301 NG_DEVICE, 302 "netgraph", 303 0, --- 440 unchanged lines hidden --- |