2 * s_common.c - common utilities for Solaris PPP
4 * Copyright (c) 2000 by Sun Microsystems, Inc.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation is hereby granted, provided that the above copyright
9 * notice appears in all copies.
11 * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF
12 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
13 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
15 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
16 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES
19 #pragma ident "%Z%%M% %I% %E% SMI"
20 #define RCSID "$Id: s_common.c,v 1.0 2000/05/08 01:10:12 masputra Exp $"
22 #include <sys/types.h>
23 #include <sys/debug.h>
24 #include <sys/param.h>
26 #include <sys/stream.h>
27 #include <sys/stropts.h>
28 #include <sys/errno.h>
29 #include <sys/ioccom.h>
30 #include <sys/cmn_err.h>
32 #include <sys/sunddi.h>
33 #include <sys/strsun.h>
34 #include <net/ppp_defs.h>
35 #include <net/pppio.h>
42 * Create and send a 4-byte message.
45 putctl4(queue_t
*q
, uchar_t type
, uchar_t code
, uint16_t val
)
49 if ((mp
= allocb(4, BPRI_HI
)) == NULL
) {
54 ((uint16_t *)mp
->b_wptr
)[1] = val
;
65 * Create and send a 8-byte message.
68 putctl8(queue_t
*q
, uchar_t type
, uchar_t code
, uint32_t val
)
72 if ((mp
= allocb(8, BPRI_HI
)) == NULL
) {
77 ((uint32_t *)mp
->b_wptr
)[1] = val
;
88 * Helper routine to return a specific byte off a data buffer.
91 msg_byte(mblk_t
*mp
, unsigned int i
)
103 return (mp
->b_rptr
[i
]);
107 * sppp_create_lsmsg()
110 * Create a PPP link status message.
113 create_lsmsg(enum LSstat ls_type
)
118 if ((mp
= allocb(sizeof (*plt
), BPRI_HI
)) == NULL
) {
122 * Make sure that this message is a control message, and contains
123 * a notification that the link has been terminated.
126 mp
->b_wptr
+= sizeof (*plt
);
127 plt
= (struct ppp_ls
*)mp
->b_rptr
;
128 plt
->magic
= PPPLSMAGIC
;
129 plt
->ppp_message
= ls_type
;