aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-26 21:05:39 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-26 21:05:39 +0100
commit4e3e28e91632640490642108f7b89824e2b51b4f (patch)
treea52592c66cf05e9b897872af3005815de9ec135c
parent2a9bf2b61589a802454bd5c00c7f5575540b421f (diff)
mtp: Store the NetworIndicator in the mtp_link and use it
Prepare to make the ni configurable and store it inside the mtp_link where it can be changed by the user of the mtp_link. Initialize this to the current value.
-rw-r--r--include/mtp_data.h1
-rw-r--r--src/mtp_layer3.c7
2 files changed, 5 insertions, 3 deletions
diff --git a/include/mtp_data.h b/include/mtp_data.h
index b8f6af0..3096cb6 100644
--- a/include/mtp_data.h
+++ b/include/mtp_data.h
@@ -38,6 +38,7 @@
struct mtp_link {
/* routing info.. */
int dpc, opc;
+ int ni;
/* internal state */
/* the MTP1 link is up */
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 6b92666..817b51c 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -45,7 +45,7 @@ static struct msgb *mtp_msg_alloc(struct mtp_link *link)
msg->l2h = msgb_put(msg, sizeof(*hdr));
hdr = (struct mtp_level_3_hdr *) msg->l2h;
hdr->addr = MTP_ADDR(0x0, link->dpc, link->opc);
- hdr->ni = MTP_NI_NATION_NET;
+ hdr->ni = link->ni;
return msg;
}
@@ -253,6 +253,7 @@ struct mtp_link *mtp_link_alloc(void)
if (!link)
return NULL;
+ link->ni = MTP_NI_NATION_NET;
link->t1_timer.data = link;
link->t1_timer.cb = mtp_sltm_t1_timeout;
link->t2_timer.data = link;
@@ -287,7 +288,7 @@ static int mtp_link_sign_msg(struct mtp_link *link, struct mtp_level_3_hdr *hdr,
struct msgb *msg;
struct mtp_level_3_cmn *cmn;
- if (hdr->ni != MTP_NI_NATION_NET || l3_len < 1) {
+ if (hdr->ni != link->ni || l3_len < 1) {
LOGP(DINP, LOGL_ERROR, "Unhandled data (ni: %d len: %d)\n",
hdr->ni, l3_len);
return -1;
@@ -330,7 +331,7 @@ static int mtp_link_regular_msg(struct mtp_link *link, struct mtp_level_3_hdr *h
struct msgb *out;
struct mtp_level_3_mng *mng;
- if (hdr->ni != MTP_NI_NATION_NET || l3_len < 1) {
+ if (hdr->ni != link->ni || l3_len < 1) {
LOGP(DINP, LOGL_ERROR, "Unhandled data (ni: %d len: %d)\n",
hdr->ni, l3_len);
return -1;