From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 1/5] gatppp: Add PPP server extension
Date: Mon, 21 Jun 2010 23:36:52 -0500 [thread overview]
Message-ID: <201006212336.52715.denkenz@gmail.com> (raw)
In-Reply-To: <1277113682-17510-1-git-send-email-zhenhua.zhang@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2451 bytes --]
Hi Zhenhua,
> static enum rcr_result ipcp_rcr(struct pppcp_data *pppcp,
> const struct pppcp_packet *packet,
> guint8 **new_options, guint16 *new_len)
> {
> struct ppp_option_iter iter;
> + struct ipcp_data *ipcp = pppcp_get_data(pppcp);
> + guint32 peer_addr = 0;
> + guint32 dns1 = 0;
> + guint32 dns2 = 0;
> + guint32 nbns1 = 0;
> + guint32 nbns2 = 0;
>
> ppp_option_iter_init(&iter, packet);
>
> - if (ppp_option_iter_next(&iter) == FALSE)
> - return RCR_ACCEPT;
> + while (ppp_option_iter_next(&iter) == TRUE) {
> + const guint8 *data = ppp_option_iter_get_data(&iter);
> +
> + switch (ppp_option_iter_get_type(&iter)) {
> + case IP_ADDRESS:
> + memcpy(&peer_addr, data, 4);
> + break;
> + case PRIMARY_DNS_SERVER:
> + memcpy(&dns1, data, 4);
> + break;
> + case SECONDARY_DNS_SERVER:
> + memcpy(&dns2, data, 4);
> + break;
> + case PRIMARY_NBNS_SERVER:
> + memcpy(&nbns1, data, 4);
> + break;
> + case SECONDARY_NBNS_SERVER:
> + memcpy(&nbns2, data, 4);
> + break;
> + default:
> + break;
> + }
> + }
> +
> + if (peer_addr) {
> + if (ipcp->peer_addr == 0) {
> + /* RFC 1332 section 3.3
> + * As client, accept the server IP as peer's address
> + */
> + ipcp->peer_addr = peer_addr;
> +
> + return RCR_ACCEPT;
I'm still confused about this part. As client we should accept server's IP
address as long as its non-zero. Otherwise Conf-Rej the option.
> + } else if (ipcp->peer_addr == peer_addr && ipcp->dns1 == dns1
> + && ipcp->nbns1 == nbns1 && ipcp->nbns2 == nbns2)
> + /* As server, verify the client's info and then send
> + * acknowledgement back
> + */
> + return RCR_ACCEPT;
> + } else {
> + /* Client requests server to send IP/DNS/NBNS information in the
> + * config options
> + */
> + if (ipcp->peer_addr) {
> + guint8 *options;
> + guint16 len;
> +
> + options = ipcp_generate_peer_config_options(ipcp, &len);
> + if (!options)
> + goto reject;
> +
> + *new_len = len;
> + *new_options = options;
> + return RCR_NAK;
> + }
Here we want to ensure that we nak the client's options for as long as the
options don't match. Even ipcp->peer_addr is 0 (e.g. we're allocating
client's address via DHCP or something)
Overall I think this code path is a little too complicated. Can you see
whether you can clean it up a bit?
Regards,
-Denis
next prev parent reply other threads:[~2010-06-22 4:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-21 9:47 [PATCH 1/5] gatppp: Add PPP server extension Zhenhua Zhang
2010-06-21 9:47 ` [PATCH 2/5] atmodem: Fix GAtPPPConnectFunc interface change Zhenhua Zhang
2010-06-21 9:48 ` [PATCH 3/5] test-server: Add PPP server support Zhenhua Zhang
2010-06-21 9:48 ` [PATCH 4/5] test-server: Configure network interface Zhenhua Zhang
2010-06-21 9:48 ` [PATCH 5/5] gsmdial: Configure network interface for PPP Zhenhua Zhang
2010-06-22 4:36 ` Denis Kenzior [this message]
2010-06-22 6:24 ` [PATCH 1/5] gatppp: Add PPP server extension Zhang, Zhenhua
-- strict thread matches above, loose matches on Subject: below --
2010-06-25 3:19 [PATCH 0/5] Add PPP server support Zhenhua Zhang
2010-06-25 3:19 ` [PATCH 1/5] gatppp: Add PPP server extension Zhenhua Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201006212336.52715.denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox