Lines Matching +full:code +full:- +full:0
4 * SPDX-License-Identifier: Apache-2.0
23 int (*parse)(struct net_pkt *pkt, uint8_t code, in ppp_parse_options() argument
36 return -EMSGSIZE; in ppp_parse_options()
39 while (remaining > 0) { in ppp_parse_options()
41 if (ret < 0) { in ppp_parse_options()
44 return -EBADMSG; in ppp_parse_options()
48 if (ret < 0) { in ppp_parse_options()
51 return -EBADMSG; in ppp_parse_options()
54 opt_val_len = opt_len - sizeof(opt_type) - sizeof(opt_len); in ppp_parse_options()
58 NET_DBG("[%s/%p] option %s (%d) len %d", fsm->name, fsm, in ppp_parse_options()
59 ppp_option2str(fsm->protocol, opt_type), opt_type, in ppp_parse_options()
63 if (ret < 0) { in ppp_parse_options()
70 remaining -= opt_len; in ppp_parse_options()
73 if (remaining < 0) { in ppp_parse_options()
74 return -EBADMSG; in ppp_parse_options()
77 return 0; in ppp_parse_options()
83 uint8_t code) in ppp_peer_option_info_get() argument
87 for (i = 0; i < num_options; i++) { in ppp_peer_option_info_get()
88 if (options[i].code == code) { in ppp_peer_option_info_get()
109 uint8_t code, uint8_t len, in ppp_parse_option_conf_req_unsupported() argument
113 struct ppp_fsm *fsm = parse_data->fsm; in ppp_parse_option_conf_req_unsupported()
114 struct net_pkt *ret_pkt = parse_data->ret_pkt; in ppp_parse_option_conf_req_unsupported()
116 ppp_peer_option_info_get(parse_data->options_info, in ppp_parse_option_conf_req_unsupported()
117 parse_data->num_options_info, in ppp_parse_option_conf_req_unsupported()
118 code); in ppp_parse_option_conf_req_unsupported()
121 fsm->name, fsm, "Check", in ppp_parse_option_conf_req_unsupported()
122 ppp_option2str(parse_data->protocol, code), in ppp_parse_option_conf_req_unsupported()
123 code, len); in ppp_parse_option_conf_req_unsupported()
126 return 0; in ppp_parse_option_conf_req_unsupported()
129 parse_data->rej_count++; in ppp_parse_option_conf_req_unsupported()
131 net_pkt_write_u8(ret_pkt, code); in ppp_parse_option_conf_req_unsupported()
132 net_pkt_write_u8(ret_pkt, len + sizeof(code) + sizeof(len)); in ppp_parse_option_conf_req_unsupported()
134 if (len > 0) { in ppp_parse_option_conf_req_unsupported()
138 return 0; in ppp_parse_option_conf_req_unsupported()
142 uint8_t code, uint8_t len, in ppp_parse_option_conf_req_supported() argument
146 struct ppp_fsm *fsm = parse_data->fsm; in ppp_parse_option_conf_req_supported()
148 ppp_peer_option_info_get(parse_data->options_info, in ppp_parse_option_conf_req_supported()
149 parse_data->num_options_info, in ppp_parse_option_conf_req_supported()
150 code); in ppp_parse_option_conf_req_supported()
153 ret = option_info->parse(fsm, pkt, parse_data->user_data); in ppp_parse_option_conf_req_supported()
154 if (ret == -EINVAL) { in ppp_parse_option_conf_req_supported()
155 parse_data->nack_count++; in ppp_parse_option_conf_req_supported()
156 ret = option_info->nack(fsm, parse_data->ret_pkt, in ppp_parse_option_conf_req_supported()
157 parse_data->user_data); in ppp_parse_option_conf_req_supported()
188 if (ret < 0) { in ppp_config_info_req()
189 return -EINVAL; in ppp_config_info_req()
201 if (ret < 0) { in ppp_config_info_req()
202 return -EINVAL; in ppp_config_info_req()
225 AF_UNSPEC, 0, PPP_BUF_ALLOC_TIMEOUT); in ppp_my_options_add()
230 for (i = 0; i < fsm->my_options.count; i++) { in ppp_my_options_add()
231 info = &fsm->my_options.info[i]; in ppp_my_options_add()
232 data = &fsm->my_options.data[i]; in ppp_my_options_add()
234 if (data->flags & PPP_MY_OPTION_REJECTED) { in ppp_my_options_add()
238 err = net_pkt_write_u8(pkt, info->code); in ppp_my_options_add()
243 err = info->conf_req_add(ctx, pkt); in ppp_my_options_add()
267 static int ppp_my_option_get(struct ppp_fsm *fsm, uint8_t code, in ppp_my_option_get() argument
273 for (i = 0; i < fsm->my_options.count; i++) { in ppp_my_option_get()
274 if (fsm->my_options.info[i].code == code) { in ppp_my_option_get()
275 *info = &fsm->my_options.info[i]; in ppp_my_option_get()
276 *data = &fsm->my_options.data[i]; in ppp_my_option_get()
277 return 0; in ppp_my_option_get()
281 return -ENOENT; in ppp_my_option_get()
284 static int ppp_my_option_parse(struct net_pkt *pkt, uint8_t code, in ppp_my_option_parse() argument
288 struct ppp_context *ctx = ppp_fsm_ctx(d->fsm); in ppp_my_option_parse()
293 ret = ppp_my_option_get(d->fsm, code, &info, &data); in ppp_my_option_parse()
294 if (ret < 0) { in ppp_my_option_parse()
295 return 0; in ppp_my_option_parse()
298 return d->handle(ctx, pkt, len, info, data); in ppp_my_option_parse()
320 data->flags |= PPP_MY_OPTION_ACKED; in ppp_my_option_parse_conf_ack()
322 if (info->conf_ack_handle) { in ppp_my_option_parse_conf_ack()
323 return info->conf_ack_handle(ctx, pkt, len); in ppp_my_option_parse_conf_ack()
326 return 0; in ppp_my_option_parse_conf_ack()
342 return info->conf_nak_handle(ctx, pkt, len); in ppp_my_option_parse_conf_nak()
358 data->flags |= PPP_MY_OPTION_REJECTED; in ppp_my_option_parse_conf_rej()
360 return 0; in ppp_my_option_parse_conf_rej()
371 uint32_t ppp_my_option_flags(struct ppp_fsm *fsm, uint8_t code) in ppp_my_option_flags() argument
377 ret = ppp_my_option_get(fsm, code, &info, &data); in ppp_my_option_flags()
382 return data->flags; in ppp_my_option_flags()