Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13623


Change subject: LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity
......................................................................

LLC: Store the XID inside the LLC Entity, not LLC Mgmg Entity

The LLC XID exchange is negotiating parameters for a given SAPI,
and not for the entire connection from/to that given subscriber.

Change-Id: Iaeb54ca5ac58391be45e56c2e721f531969f3a9e
---
M include/osmocom/sgsn/gprs_llc.h
M src/gprs/gprs_llc.c
M src/gprs/gprs_sndcp.c
3 files changed, 25 insertions(+), 26 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/23/13623/1

diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h
index 376ae9a..711bcd6 100644
--- a/include/osmocom/sgsn/gprs_llc.h
+++ b/include/osmocom/sgsn/gprs_llc.h
@@ -145,6 +145,13 @@
        unsigned int retrans_ctr;

        struct gprs_llc_params params;
+
+       /* Copy of the XID fields we have sent with the last
+        * network originated XID-Request. Since the phone
+        * may strip the optional fields in the confirmation
+        * we need to remeber those fields in order to be
+        * able to create the compression entity. */
+       struct llist_head *xid;
 };

 #define NUM_SAPIS      16
@@ -169,13 +176,6 @@
        uint16_t nsei;
        struct gprs_llc_lle lle[NUM_SAPIS];

-       /* Copy of the XID fields we have sent with the last
-        * network originated XID-Request. Since the phone
-        * may strip the optional fields in the confirmation
-        * we need to remeber those fields in order to be
-        * able to create the compression entity. */
-       struct llist_head *xid;
-
        /* Compression entities */
        struct {
                /* In these two list_heads we will store the
diff --git a/src/gprs/gprs_llc.c b/src/gprs/gprs_llc.c
index abbb742..1cb0f5d 100644
--- a/src/gprs/gprs_llc.c
+++ b/src/gprs/gprs_llc.c
@@ -52,7 +52,7 @@
 /* Generate XID message */
 static int gprs_llc_generate_xid(uint8_t *bytes, int bytes_len,
                                 struct gprs_llc_xid_field *l3_xid_field,
-                                struct gprs_llc_llme *llme)
+                                struct gprs_llc_lle *lle)
 {
        /* Note: Called by gprs_ll_xid_req() */

@@ -89,8 +89,8 @@
        }

        /* Store generated XID for later reference */
-       talloc_free(llme->xid);
-       llme->xid = gprs_llc_copy_xid(llme, &xid_fields);
+       talloc_free(lle->xid);
+       lle->xid = gprs_llc_copy_xid(lle->llme, &xid_fields);

        return gprs_llc_compile_xid(bytes, bytes_len, &xid_fields);
 }
@@ -98,7 +98,7 @@
 /* Generate XID message that will cause the GMM to reset */
 static int gprs_llc_generate_xid_for_gmm_reset(uint8_t *bytes,
                                               int bytes_len, uint32_t iov_ui,
-                                              struct gprs_llc_llme *llme)
+                                              struct gprs_llc_lle *lle)
 {
        /* Called by gprs_llgmm_reset() and
         * gprs_llgmm_reset_oldmsg() */
@@ -123,8 +123,8 @@
        llist_add(&xid_reset.list, &xid_fields);

        /* Store generated XID for later reference */
-       talloc_free(llme->xid);
-       llme->xid = gprs_llc_copy_xid(llme, &xid_fields);
+       talloc_free(lle->xid);
+       lle->xid = gprs_llc_copy_xid(lle->llme, &xid_fields);

        return gprs_llc_compile_xid(bytes, bytes_len, &xid_fields);
 }
@@ -143,8 +143,8 @@
        struct gprs_llc_xid_field *xid_field_request_l3 = NULL;

        /* Pick layer3 XID from the XID request we have sent last */
-       if (lle->llme->xid) {
-               llist_for_each_entry(xid_field_request, lle->llme->xid, list) {
+       if (lle->xid) {
+               llist_for_each_entry(xid_field_request, lle->xid, list) {
                        if (xid_field_request->type == GPRS_LLC_XID_T_L3_PAR)
                                xid_field_request_l3 = xid_field_request;
                }
@@ -188,8 +188,8 @@
        }

        /* Flush pending XID fields */
-       talloc_free(lle->llme->xid);
-       lle->llme->xid = NULL;
+       talloc_free(lle->xid);
+       lle->xid = NULL;

        return 0;
 }
@@ -324,8 +324,7 @@

        /* Generate XID */
        xid_bytes_len =
-           gprs_llc_generate_xid(xid_bytes, sizeof(xid_bytes),
-                                 l3_xid_field, lle->llme);
+           gprs_llc_generate_xid(xid_bytes, sizeof(xid_bytes), l3_xid_field, 
lle);

        /* Only perform XID sending if the XID message contains something */
        if (xid_bytes_len > 0) {
@@ -576,7 +575,6 @@
 {
        gprs_sndcp_comp_free(llme->comp.proto);
        gprs_sndcp_comp_free(llme->comp.data);
-       talloc_free(llme->xid);
        llist_del(&llme->list);
        talloc_free(llme);
 }
@@ -1084,8 +1082,8 @@
        }

        /* Generate XID message */
-       xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
-                                       sizeof(xid_bytes),llme->iov_ui,llme);
+       xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes, 
sizeof(xid_bytes),
+                                                           llme->iov_ui, lle);
        if (xid_bytes_len < 0)
                return -EINVAL;
        xid = msgb_put(msg, xid_bytes_len);
@@ -1105,6 +1103,7 @@
                            struct gprs_llc_llme *llme)
 {
        struct msgb *msg = msgb_alloc_headroom(4096, 1024, "LLC_XID");
+       struct gprs_llc_lle *lle = &llme->lle[sapi];
        uint8_t xid_bytes[1024];
        int xid_bytes_len, rc;
        uint8_t *xid;
@@ -1118,8 +1117,8 @@
        }

        /* Generate XID message */
-       xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
-                                       sizeof(xid_bytes),llme->iov_ui,llme);
+       xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes, 
sizeof(xid_bytes),
+                                                           llme->iov_ui, lle);
        if (xid_bytes_len < 0)
                return -EINVAL;
        xid = msgb_put(msg, xid_bytes_len);
diff --git a/src/gprs/gprs_sndcp.c b/src/gprs/gprs_sndcp.c
index f0239cb..23d1e9a 100644
--- a/src/gprs/gprs_sndcp.c
+++ b/src/gprs/gprs_sndcp.c
@@ -989,8 +989,8 @@
        gprs_sndcp_comp_free(lle->llme->comp.data);
        lle->llme->comp.proto = gprs_sndcp_comp_alloc(lle->llme);
        lle->llme->comp.data = gprs_sndcp_comp_alloc(lle->llme);
-       talloc_free(lle->llme->xid);
-       lle->llme->xid = NULL;
+       talloc_free(lle->xid);
+       lle->xid = NULL;

        /* Generate compression parameter bytestream */
        xid_len = gprs_llc_gen_sndcp_xid(l3params, sizeof(l3params), nsapi);

--
To view, visit https://gerrit.osmocom.org/13623
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaeb54ca5ac58391be45e56c2e721f531969f3a9e
Gerrit-Change-Number: 13623
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to