[PATCH] misc fixes for smsc_cimd2.c
Per Skaglund <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | Dialtone Oy |
| Message-ID | <[email protected]> |
Hi all,
Here are some very simple fixes for smsc_cimd2 driver. The patch has been
tested on multiple connections to three different operators. I hope this can
be commited before 1.3.2.
Votes for a commit are very welcome ;-)
Changes:
1. Increased the RESPONSE_TIMEOUT constant. The "Guidelines for CIMD
Application Development" document [http://ncsp.forum.nokia.com/downloads/
nokia/documents/Guidelines_for_CIMD_Application_Development_v1_0.pdf] states:
"In the case of a login attempt, applications are required to wait for the
login response from the ASE for at least one minute. Applications that don't
follow this rule can overload the comsystem by retrying to connect while SMSC
is still processing the first request". In my experience this change also
makes the smsc_cimd2 driver a _lot_ more stable.
2. Made sure the sequence number of cimd2 LOGIN packets always is 001. This
was true the first time Kannel logged in after startup, but smsc_cimd2 uses
the value of the send_seq counter when setting the sequence number of LOGIN
packets if there ever is a re-connect. In this situation the server would
reply to the LOGIN with a NACK (ignored by kannel, see 8). Kannel would be
able to log in after several login attempts, when the send_seq counter
eventually rolled over to 001. This fix decreases the time smsc_cimd2 spends
offline.
3. Re-added call to charset_gsm_to_latin1() for 7-bit MO content. Without this
call Kannel delivers messages to applications in the GSM charset instead of
latin1. It was removed when the driver was ported to smscconn.
4. Added smsc-id in info() calls.
5. The driver does no longer discard empty messages. This was an inconsistency
with other drivers, and is important for application side accounting.
6. Checks the sequence number of incoming cimd2 requests. This is a major
source of the infamous "duplicating MO messages" phenomena. In some situations
a cimd2 server can fail to receive the DELIVERY_REQUEST_RESPONSE packet sent
back by Kannel. The server will then issue a new DELIVERY_REQUEST with the
same sequence number. Reading the cimd2 specs I believe the correct procedure
for Kannel would be to reply with a NACK packet containing the expected
sequence number, but I'm not sure how the cimd2 servers would handle that...
However, a quick workaround is to check the sequence number of each request
against the sequence number of the previous request. If they match the message
is discarded, but the DELIVERY_REQUEST_RESPONSE is sent back to satify the
server.
7. The debug row "sending <PDU>" was printed before calling the functions
packet_set_send_sequence() and packet_set_checksum(), hence the debug output
displayed wrong sequence number/checksum.
8. Fixed a bug to allow the driver to correct the sequence number if the
server says it was wrong. The code contained a condition with a typo for
checking that the sequence number provided by the server in the NACK really
was an odd number.
--
Per Skaglund
Dialtone Oy
Tekniikantie 14, FIN-02150 Espoo, Finland
Tel. +358941743434, Mobile +358405198377
begin 600 smsc_cimd2.diff
M+2TM(&=A=&5W87DO9W<O<VUS8R]S;7-C7V-I;60R+F,)5&AU($%P<B @,R Q
M-3HQ.#HQ." R,# S"BLK*R!M>6=A=&5W87DO9W<O<VUS8R]S;7-C7V-I;60R
M+F,)1G)I($UA>2 @.2 Q,#HQ-#HQ,2 R,# S"D! ("TV.2PW("LV.2PW($!
M"B *( H@+RH@36EC<F]S96-O;F1S(&)E9F]R92!G:79I;F<@=7 @;VX@82!R
M97%U97-T("HO"BTC9&5F:6YE(%)%4U!/3E-%7U1)345/550@*#$P("H@,3 P
M,# P,"D**R-D969I;F4@4D534$].4T5?5$E-14]55" H-C @*B Q,# P,# P
M*0H@"B O*B!497AT=6%L(&YA;65S(&9O<B!T:&4@;W!E<F%T:6]N(&-O9&5S
M(&1E9FEN960@8GD@=&AE($-)340@,B!S<&5C+B J+PH@+RH@268@>6]U(&UA
M:V4@8VAA;F=E<R!H97)E+"!A;'-O(&-H86YG92!T:&4@;W!E<F%T:6]N('1A
M8FQE+B J+PI 0" M,30S-2PV("LQ-#,U+#D@0$ *('-T871I8R!V;VED('!A
M8VME=%]S971?<V5N9%]S97%U96YC92AS=')U8W0@<&%C:V5T("IP86-K970L
M(%!R:79$871A("IP9&%T82D*('L*(" @("!G=U]A<W-E<G0H<&1A=&$@(3T@
M3E5,3"D["BL@(" @+RH@3$]'24X@<&%C:V5T<R!A;'=A>7,@:&%V92!S97%U
M96YC92!N=6UB97(@,# Q("HO"BL@(" @:68@*'!A8VME="T^;W!E<F%T:6]N
M(#T]($Q/1TE.*0HK(" @(" @("!P9&%T82T^<V5N9%]S97$@/2 Q.PH@(" @
M("\J(%-E;F0@<V5Q=65N8V4@;G5M8F5R<R!A<F4@86QW87ES(&]D9"P@<F5C
M96EV:6YG(&%R92!A;'=A>7,@979E;B J+PH@(" @(&=W7V%S<V5R="AP9&%T
M82T^<V5N9%]S97$@)2 R(#T](#$I.PH@"D! ("TQ-3,T+#<@*S$U,S<L-R!
M0 H@(" @('1E>'0@/2!P86-K971?9V5T7W-M<U]P87)M*')E<75E<W0L(%!?
M55-%4E]$051!*3L*(" @("!I9B H=&5X=" A/2!.54Q,*2!["B @(" @(" @
M(&-O;G9E<G1?8VEM9#)?=&]?9W-M*'1E>'0L8V]N;BD["BT@(" @(" @("\J
M8VAA<G-E=" ](&-H87)S971?9W-M.R @5&AI<R!O=F5R<FED97,@=VAA="!W
M92!G;W0@9G)O;2!T:&4@1$-3("HO"BL@(" @(" @(&-H87)S971?9W-M7W1O
M7VQA=&EN,2AT97AT*3L*(" @("!](&5L<V4@>PH@(" @(" @(" O*@H@(" @
M(" @(" @*B!&25A-13H@268@1$-3(&EN9&EC871E<R!'4TT@8VAA<G-E="P@
M86YD('=E(&=E="!I="!I;B!B:6YA<GDL"D! ("TQ-34P+#(S("LQ-34S+#(W
M($! "B @(" @("H@;&%C:R!T:&5M+B @268@=&AE>2!S:&]U;&0@;F]T(&)E
M(&1I<V-A<F1E9"P@=&AE;B!T:&4@8V]D90H@(" @(" J(&AA;F1L:6YG('-M
M<R!M97-S86=E<R!S:&]U;&0@8F4@<F5V:65W960N(" M+2!20B J+PH@(" @
M(&EF("@A9&5S=&EN871I;VX@?'P@;V-T<W1R7VQE;BAD97-T:6YA=&EO;BD@
M/3T@,"D@>PHM(" @(" @("!I;F9O*# L(")#24U$,CH@1V]T(%--4R!W:71H
M;W5T(')E8V5I=F5R+"!D:7-C87)D:6YG+B(I.PHK(" @(" @("!I;F9O*# L
M(")#24U$,ELE<UTZ($=O="!335,@=VET:&]U="!R96-E:79E<BP@9&ES8V%R
M9&EN9RXB+ HK(" @(" @(" @(" @("!O8W1S=')?9V5T7V-S='(H8V]N;BT^
M:60I*3L*(" @(" @(" @9V]T;R!E<G)O<CL*(" @("!]"B @(" @:68@*"%O
M<FEG:6X@?'P@;V-T<W1R7VQE;BAO<FEG:6XI(#T](# I('L*+2 @(" @(" @
M:6YF;R@P+" B0TE-1#(Z($=O="!335,@=VET:&]U="!S96YD97(L(&1I<V-A
M<F1I;F<N(BD["BL@(" @(" @(&EN9F\H,"P@(D-)340R6R5S73H@1V]T(%--
M4R!W:71H;W5T('-E;F1E<BP@9&ES8V%R9&EN9RXB+ HK(" @(" @(" @(" @
M("!O8W1S=')?9V5T7V-S='(H8V]N;BT^:60I*3L*(" @(" @(" @9V]T;R!E
M<G)O<CL*(" @("!]"B *+2 @("!I9B H*"%T97AT('Q\(&]C='-T<E]L96XH
M=&5X="D@/3T@,"D@)B8@*"%51$@@?'P@;V-T<W1R7VQE;BA51$@I(#T](# I
M*2340R6R5S
M73H@1V]T(&5M<'1Y(%--4RP@:6=N;W)I;F<N(BP**R @(" @(" @(" @(" @
M;V-T<W1R7V=E=%]C<W1R*&-O;FXM/FED*2D["B @(" @(" @(&=O=&\@97)R
M;W(["B @(" @?0HM"BL@(" @"B @(" @;65S<V%G92 ](&US9U]C<F5A=&4H
M<VUS*3L*(" @("!I9B H(2!D8W-?=&]?9FEE;&1S*"9M97-S86=E+"!$0U,I
M*2!["B )+RH@6%A8(%-H;W5L9"!R96IE8W0@=&AI<R!M97-S86=E(#\@*B\*
M+0ED96)U9R@B0TE-1#(B+" P+" B26YV86QI9"!$0U,B*3L**R @(" @(" @
M9&5B=6<H(F)B+G-M<RYC:6UD,B(L(# L(")#24U$,ELE<UTZ($EN=F%L:60@
M1$-3(BP**R @(" @(" @(" @(" @;V-T<W1R7V=E=%]C<W1R*&-O;FXM/FED
M*2D["B )9&-S7W1O7V9I96QD<R@F;65S<V%G92P@,"D["B @(" @?0H@(" @
M(&UE<W-A9V4M/G-M<RYS96YD97(@/2!O<FEG:6X["D! ("TQ-3DR+#$X("LQ
M-3DY+#(V($! "B @(" @4')I=D1A=&$@*G!D871A(#T@8V]N;BT^9&%T83L*
M(" @("!-<V<@*FUE<W-A9V4@/2!.54Q,.PH@"BT@(" @+RH@5$]$3SH@0VAE
M8VL@:68@=&AE('-E<75E;F-E(&YU;6)E<B!O9B!T:&ES(')E<75E<W0@:7,@
M=VAA="!W90HM(" @(" J(&5X<&5C=&5D+B J+PHM"BT@(" @:68@*')E<75E
M<W0M/F]P97)A=&EO;B ]/2!$14Q)5D527U-405154U]215!/4E0I('L*+2 @
M(" @(" @;65S<V%G92 ](&-I;60R7V%C8V5P=%]D96QI=F5R>5]R97!O<G1?
M;65S<V%G92AR97%U97-T+"!C;VYN*3L*+2 @(" @(" @:68@*&UE<W-A9V4I
M"BT@(" @(" @(" @("!L:7-T7V%P<&5N9"AP9&%T82T^<F5C96EV960L(&UE
M<W-A9V4I.PHM(" @("!]"BT@(" @(&5L<V4@:68@*')E<75E<W0M/F]P97)A
M=&EO;B ]/2!$14Q)5D527TU%4U-!1T4I('L*+2 @(" @(" @(&UE<W-A9V4@
M/2!C:6UD,E]A8V-E<'1?;65S<V%G92AR97%U97-T+&-O;FXI.PHM(" @(" @
M(" @:68@*&UE<W-A9V4I"BT@(" @(" @(" @(" @;&ES=%]A<'!E;F0H<&1A
M=&$M/G)E8V5I=F5D+"!M97-S86=E*3L**R @("!I9B H*')E<75E<W0M/G-E
M<2 ]/2 R-30@)B8@<&1A=&$M/G)E8V5I=F5?<V5Q(#T](# I('Q\"BL@(" @
M(" @(" @("!R97%U97-T+3YS97$@/3T@<&1A=&$M/G)E8V5I=F5?<V5Q("T@
M,BD@>PHK(" @(" @("!W87)N:6YG*# L(")#24U$,ELE<UTZ(')E<75E<W0@
M:&%D('-A;64@<V5Q=65N8V4@;G5M8F5R(&%S('!R979I;W5S+B(L"BL@(" @
M(" @(" @(" @(" @;V-T<W1R7V=E=%]C<W1R*&-O;FXM/FED*2D["BL@(" @
M?0HK(" @(&5L<V4@>PHK(" @(" @("!P9&%T82T^<F5C96EV95]S97$@/2!R
M97%U97-T+3YS97$@*R R.PHK(" @(" @("!I9B H<&1A=&$M/G)E8V5I=F5?
M<V5Q(#X@,C4T*0HK(" @(" @(" @(" @<&1A=&$M/G)E8V5I=F5?<V5Q(#T@
M,#L**PHK(" @(" @("!I9B H<F5Q=65S="T^;W!E<F%T:6]N(#T]($1%3$E6
M15)?4U1!5%537U)%4$]25"D@>PHK(" @(" @(" @(" @;65S<V%G92 ](&-I
M;60R7V%C8V5P=%]D96QI=F5R>5]R97!O<G1?;65S<V%G92AR97%U97-T+"!C
M;VYN*3L**R @(" @(" @(" @(&EF("AM97-S86=E*0HK(" @(" @(" @(" @
M(" @(&QI<W1?87!P96YD*'!D871A+3YR96-E:79E9"P@;65S<V%G92D["BL@
M(" @(" @('T**R @(" @(" @96QS92!I9B H<F5Q=65S="T^;W!E<F%T:6]N
M(#T]($1%3$E615)?34534T%'12D@>PHK(" @(" @(" @(" @;65S<V%G92 ]
M(&-I;60R7V%C8V5P=%]M97-S86=E*')E<75E<W0L8V]N;BD["BL@(" @(" @
M(" @("!I9B H;65S<V%G92D**R @(" @(" @(" @(" @("!L:7-T7V%P<&5N
M9"AP9&%T82T^<F5C96EV960L(&UE<W-A9V4I.PHK(" @(" @("!]"B @(" @
M?0H@"B @(" @8VEM9#)?<V5N9%]R97-P;VYS92AR97%U97-T+"!P9&%T82D[
M"D! ("TQ-C,U+#$P("LQ-C4P+#8@0$ *(" @("!G=U]A<W-E<G0H<F5Q=65S
M=" A/2!.54Q,*3L*(" @("!G=U]A<W-E<G0H;W!E<F%T:6]N7V-A;E]S96YD
M*')E<75E<W0M/F]P97)A=&EO;BDI.PH@"BT@(" @9&5B=6<H(F)B+G-M<RYC
M:6UD,B(L(# L(")#24U$,ELE<UTZ('-E;F1I;F<@/"5S/B(L"BT@(" @(" @
M(" @;V-T<W1R7V=E=%]C<W1R*&-O;FXM/FED*2P*+2 @(" @(" @("!O8W1S
M=')?9V5T7V-S='(H<F5Q=65S="T^9&%T82DI.PHM"B @(" @:68@*'!D871A
M+3YS;V-K970@/" P*2!["B @(" @(" @('=A<FYI;F<H,"P@(D-)340R6R5S
M73H@8VEM9#)?<F5Q=65S=#H@<V]C:V5T(&YO="!O<&5N+B(L"B @(" @(" @
M(" @(" @(" @;V-T<W1R7V=E=%]C<W1R*&-O;FXM/FED*2D["D! ("TQ-C0Y
M+#8@*S$V-C L,3 @0$ *(" @("!P86-K971?<V5T7W-E;F1?<V5Q=65N8V4H
M<F5Q=65S="P@<&1A=&$I.PH@(" @('!A8VME=%]S971?8VAE8VMS=6TH<F5Q
M=65S="D["B **R @("!D96)U9R@B8F(N<VUS+F-I;60R(BP@,"P@(D-)340R
M6R5S73H@<V5N9&EN9R \)7,^(BP**R @(" @(" @("!O8W1S=')?9V5T7V-S
M='(H8V]N;BT^:60I+ HK(" @(" @(" @(&]C='-T<E]G971?8W-T<BAR97%U
M97-T+3YD871A*2D["BL*(" @("!R970@/2!O8W1S=')?=W)I=&5?=&]?<V]C
M:V5T*'!D871A+3YS;V-K970L(')E<75E<W0M/F1A=&$I.PH@(" @(&EF("AR
M970@/" P*0H@(" @(" @("!G;W1O(&EO7V5R<F]R.PI 0" M,38V-RPW("LQ
M-C@R+#<@0$ *(" @(" @(" @;V-T<W1R7V1U;7 H<F5P;'DM/F1A=&$L(# I
M.PH@(" @(" @(" O*B!#;W)R96-T('-E<75E;F-E(&YU;6)E<B!I9B!S97)V
M97(@<V%Y<R!I="!W87,@=W)O;F<L"B @(" @(" @(" J(&)U="!O;FQY(&EF
M('-E<G9E<B=S(&YU;6)E<B!I<R!S86YE+B J+PHM(" @(" @("!I9B H<F5P
M;'DM/G-E<2 A/2!R97%U97-T+3YS97$@)B8@*')E<&QY+3YS97$@)2 Q*2 ]
M/2 Q*2E<75E<W0M/G-E
M<2 F)B H<F5P;'DM/G-E<2 E(#(I(#T](#$I('L*(" @(" @(" @(" @('=A
M<FYI;F<H,"P@(D-)340R6R5S73H@8V]R<F5C=&EN9R!S97%U96YC92!N=6UB
M97(@9G)O;2 E;&0@=&\@)6QD+B(L"B @(" @(" @(" @(" @(" @(" @(&]C
M='-T<E]G971?8W-T<BAC;VYN+3YI9"DL"B @(" @(" @(" @(" @(" @(" @
:("AL;VYG*2!P9&%T82T^<V5N9%]S97$L( H@
`
end