From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] ppp: implement ppp_packet_new()
Date: Mon, 10 May 2010 15:09:12 -0700 [thread overview]
Message-ID: <1273529352-8707-1-git-send-email-kristen@linux.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2136 bytes --]
Centralize allocation of PPP packets.
---
gatchat/gatppp.c | 8 ++++++++
gatchat/ppp.h | 1 +
gatchat/ppp_auth.c | 2 +-
gatchat/ppp_cp.c | 2 +-
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 82d1eca..8b6739a 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -84,6 +84,14 @@ void ppp_debug(GAtPPP *ppp, const char *str)
ppp->debugf(str, ppp->debug_data);
}
+struct ppp_header *ppp_packet_new(gsize infolen)
+{
+ struct ppp_header *ppp_packet;
+
+ ppp_packet = g_try_malloc0(infolen + sizeof(*ppp_packet));
+ return ppp_packet;
+}
+
/*
* Silently discard packets which are received when they shouldn't be
*/
diff --git a/gatchat/ppp.h b/gatchat/ppp.h
index 7f6c950..f7b6c4b 100644
--- a/gatchat/ppp.h
+++ b/gatchat/ppp.h
@@ -114,3 +114,4 @@ void ppp_lcp_finished_notify(GAtPPP *ppp);
void ppp_set_recv_accm(GAtPPP *ppp, guint32 accm);
void ppp_set_xmit_accm(GAtPPP *ppp, guint32 accm);
void ppp_set_mtu(GAtPPP *ppp, const guint8 *data);
+struct ppp_header *ppp_packet_new(gsize infolen);
diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c
index eae5d17..5f03fa4 100644
--- a/gatchat/ppp_auth.c
+++ b/gatchat/ppp_auth.c
@@ -83,7 +83,7 @@ static void chap_process_challenge(struct ppp_chap *chap, const guint8 *packet)
*/
digest_len = g_checksum_type_get_length(chap->method);
response_length = digest_len + sizeof(*header) + 1;
- ppp_packet = g_try_malloc0(response_length + sizeof(struct ppp_header));
+ ppp_packet = ppp_packet_new(response_length);
if (!ppp_packet)
goto challenge_out;
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index e152f6e..5a538b4 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -204,7 +204,7 @@ static struct pppcp_packet *pppcp_packet_new(struct pppcp_data *data,
struct ppp_header *ppp_packet;
guint16 packet_length = bufferlen + sizeof(*packet);
- ppp_packet = g_try_malloc0(packet_length + sizeof(*ppp_packet));
+ ppp_packet = ppp_packet_new(packet_length);
if (!ppp_packet)
return NULL;
--
1.6.6.1
reply other threads:[~2010-05-10 22:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1273529352-8707-1-git-send-email-kristen@linux.intel.com \
--to=kristen@linux.intel.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