90 */
91 int
92 snmp_append_data(mblk_t *mpdata, char *blob, int len)
93 {
94
95 if (!mpdata)
96 return (0);
97 while (mpdata->b_cont)
98 mpdata = mpdata->b_cont;
99 if (mpdata->b_wptr + len >= mpdata->b_datap->db_lim) {
100 mpdata->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
101 mpdata = mpdata->b_cont;
102 if (!mpdata)
103 return (0);
104 }
105 bcopy(blob, (char *)mpdata->b_wptr, len);
106 mpdata->b_wptr += len;
107 return (1);
108 }
109
110 /*
111 * Need a form which avoids O(n^2) behavior locating the end of the
112 * chain every time. This is it.
113 */
114 int
115 snmp_append_data2(mblk_t *mpdata, mblk_t **last_mpp, char *blob, int len)
116 {
117
118 if (!mpdata)
119 return (0);
120 if (*last_mpp == NULL) {
121 while (mpdata->b_cont)
122 mpdata = mpdata->b_cont;
123 *last_mpp = mpdata;
124 }
125 if ((*last_mpp)->b_wptr + len >= (*last_mpp)->b_datap->db_lim) {
126 (*last_mpp)->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
127 *last_mpp = (*last_mpp)->b_cont;
128 if (!*last_mpp)
129 return (0);
130 }
131 bcopy(blob, (char *)(*last_mpp)->b_wptr, len);
132 (*last_mpp)->b_wptr += len;
133 return (1);
134 }
135
136 /*
137 * SNMP requests are issued using putmsg() on a stream containing all
138 * relevant modules. The ctl part contains a O_T_OPTMGMT_REQ message,
139 * and the data part is NULL
140 * to process this msg. If snmpcom_req() returns FALSE, then the module
141 * will try optcom_req to see if its some sort of SOCKET or IP option.
142 * snmpcom_req returns TRUE whenever the first option is recognized as
143 * an SNMP request, even if a bad one.
144 *
145 * "get" is done by a single O_T_OPTMGMT_REQ with MGMT_flags set to T_CURRENT.
146 * All modules respond with one or msg's about what they know. Responses
147 * are in T_OPTMGMT_ACK format. The opthdr level/name fields identify what
148 * is begin returned, the len field how big it is (in bytes). The info
149 * itself is in the data portion of the msg. Fixed length info returned
150 * in one msg; each table in a separate msg.
151 *
152 * setfn() returns 1 if things ok, 0 if set request invalid or otherwise
|
90 */
91 int
92 snmp_append_data(mblk_t *mpdata, char *blob, int len)
93 {
94
95 if (!mpdata)
96 return (0);
97 while (mpdata->b_cont)
98 mpdata = mpdata->b_cont;
99 if (mpdata->b_wptr + len >= mpdata->b_datap->db_lim) {
100 mpdata->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
101 mpdata = mpdata->b_cont;
102 if (!mpdata)
103 return (0);
104 }
105 bcopy(blob, (char *)mpdata->b_wptr, len);
106 mpdata->b_wptr += len;
107 return (1);
108 }
109
110 int
111 snmp_append_mblk(mblk_t *mpdata, mblk_t *mblk)
112 {
113 if (!mpdata || !mblk)
114 return (0);
115 while (mpdata->b_cont)
116 mpdata = mpdata->b_cont;
117 mpdata->b_cont = mblk;
118 return (1);
119 }
120
121 /*
122 * Need a form which avoids O(n^2) behavior locating the end of the
123 * chain every time. This is it.
124 */
125 int
126 snmp_append_data2(mblk_t *mpdata, mblk_t **last_mpp, char *blob, int len)
127 {
128
129 if (!mpdata)
130 return (0);
131 if (*last_mpp == NULL) {
132 while (mpdata->b_cont)
133 mpdata = mpdata->b_cont;
134 *last_mpp = mpdata;
135 }
136 if ((*last_mpp)->b_wptr + len >= (*last_mpp)->b_datap->db_lim) {
137 (*last_mpp)->b_cont = allocb(DATA_MBLK_SIZE, BPRI_HI);
138 *last_mpp = (*last_mpp)->b_cont;
139 if (!*last_mpp)
140 return (0);
141 }
142 bcopy(blob, (char *)(*last_mpp)->b_wptr, len);
143 (*last_mpp)->b_wptr += len;
144 return (1);
145 }
146
147 int
148 snmp_append_mblk2(mblk_t *mpdata, mblk_t **last_mpp, mblk_t *mblk)
149 {
150 if (!mpdata || !mblk)
151 return (0);
152 if (*last_mpp == NULL) {
153 while (mpdata->b_cont)
154 mpdata = mpdata->b_cont;
155 *last_mpp = mpdata;
156 }
157 (*last_mpp)->b_cont = mblk;
158 *last_mpp = (*last_mpp)->b_cont;
159 return (1);
160 }
161
162 /*
163 * SNMP requests are issued using putmsg() on a stream containing all
164 * relevant modules. The ctl part contains a O_T_OPTMGMT_REQ message,
165 * and the data part is NULL
166 * to process this msg. If snmpcom_req() returns FALSE, then the module
167 * will try optcom_req to see if its some sort of SOCKET or IP option.
168 * snmpcom_req returns TRUE whenever the first option is recognized as
169 * an SNMP request, even if a bad one.
170 *
171 * "get" is done by a single O_T_OPTMGMT_REQ with MGMT_flags set to T_CURRENT.
172 * All modules respond with one or msg's about what they know. Responses
173 * are in T_OPTMGMT_ACK format. The opthdr level/name fields identify what
174 * is begin returned, the len field how big it is (in bytes). The info
175 * itself is in the data portion of the msg. Fixed length info returned
176 * in one msg; each table in a separate msg.
177 *
178 * setfn() returns 1 if things ok, 0 if set request invalid or otherwise
|