~zulcss/ubuntu/lucid/likewise-open/likewise-open-sru

« back to all changes in this revision

Viewing changes to samba/source/libsmb/smb_signing.c

  • Committer: Bazaar Package Importer
  • Author(s): Rick Clark
  • Date: 2008-08-27 08:56:20 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080827085620-5q0f58b9qtog9myq
Tags: 4.1.0.2956-0ubuntu1
* missing-likewise-logo.diff: removed
* fixed copyright notice
* updated Standards-Version to 3.8.0
* removed path from command in prerm
* removed stop in S runlevel

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
        struct outstanding_packet_lookup *prev, *next;
26
26
        uint16 mid;
27
27
        uint32 reply_seq_num;
 
28
        bool can_delete; /* Set to False in trans state. */
28
29
};
29
30
 
30
31
struct smb_basic_signing_context {
41
42
        /* Ensure we only add a mid once. */
42
43
        for (t = *list; t; t = t->next) {
43
44
                if (t->mid == mid) {
44
 
                        DLIST_REMOVE(*list, t);
45
 
                        SAFE_FREE(t);
46
 
                        break;
 
45
                        return False;
47
46
                }
48
47
        }
49
48
 
52
51
 
53
52
        t->mid = mid;
54
53
        t->reply_seq_num = reply_seq_num;
 
54
        t->can_delete = True;
55
55
 
56
56
        /*
57
57
         * Add to the *start* of the list not the end of the list.
78
78
                        *reply_seq_num = t->reply_seq_num;
79
79
                        DEBUG(10,("get_sequence_for_reply: found seq = %u mid = %u\n",
80
80
                                (unsigned int)t->reply_seq_num, (unsigned int)t->mid ));
81
 
                        DLIST_REMOVE(*list, t);
82
 
                        SAFE_FREE(t);
 
81
                        if (t->can_delete) {
 
82
                                DLIST_REMOVE(*list, t);
 
83
                                SAFE_FREE(t);
 
84
                        }
 
85
                        return True;
 
86
                }
 
87
        }
 
88
        return False;
 
89
}
 
90
 
 
91
static bool set_sequence_can_delete_flag(struct outstanding_packet_lookup **list, uint16 mid, bool can_delete_entry)
 
92
{
 
93
        struct outstanding_packet_lookup *t;
 
94
 
 
95
        for (t = *list; t; t = t->next) {
 
96
                if (t->mid == mid) {
 
97
                        t->can_delete = can_delete_entry;
83
98
                        return True;
84
99
                }
85
100
        }
594
609
}
595
610
 
596
611
/***********************************************************
 
612
 Enter trans/trans2/nttrans state.
 
613
************************************************************/
 
614
 
 
615
bool client_set_trans_sign_state_on(struct cli_state *cli, uint16 mid)
 
616
{
 
617
        struct smb_sign_info *si = &cli->sign_info;
 
618
        struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
 
619
 
 
620
        if (!si->doing_signing) {
 
621
                return True;
 
622
        }
 
623
 
 
624
        if (!data) {
 
625
                return False;
 
626
        }
 
627
 
 
628
        if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, False)) {
 
629
                return False;
 
630
        }
 
631
 
 
632
        return True;
 
633
}
 
634
 
 
635
/***********************************************************
 
636
 Leave trans/trans2/nttrans state.
 
637
************************************************************/
 
638
 
 
639
bool client_set_trans_sign_state_off(struct cli_state *cli, uint16 mid)
 
640
{
 
641
        uint32 reply_seq_num;
 
642
        struct smb_sign_info *si = &cli->sign_info;
 
643
        struct smb_basic_signing_context *data = (struct smb_basic_signing_context *)si->signing_context;
 
644
 
 
645
        if (!si->doing_signing) {
 
646
                return True;
 
647
        }
 
648
 
 
649
        if (!data) {
 
650
                return False;
 
651
        }
 
652
 
 
653
        if (!set_sequence_can_delete_flag(&data->outstanding_packet_list, mid, True)) {
 
654
                return False;
 
655
        }
 
656
 
 
657
        /* Now delete the stored mid entry. */
 
658
        if (!get_sequence_for_reply(&data->outstanding_packet_list, mid, &reply_seq_num)) {
 
659
                return False;
 
660
        }
 
661
 
 
662
        return True;
 
663
}
 
664
 
 
665
/***********************************************************
597
666
 Is client signing on ?
598
667
************************************************************/
599
668