libsmb/unexpected.c

ソースコードを見る。

データ構造

struct  unexpected_key

関数

void unexpected_packet (struct packet_struct *p)
static int traverse_fn (TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
void clear_unexpected (time_t t)
static int traverse_match (TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
packet_structreceive_unexpected (enum packet_type packet_type, int id, const char *mailslot_name)

変数

static TDB_CONTEXTtdbd = NULL
static time_t lastt
static struct packet_structmatched_packet
static int match_id
static enum packet_type match_type
static const char * match_name


関数

void unexpected_packet ( struct packet_struct p  ) 

unexpected.c40 行で定義されています。

参照先 bufbuild_packet()unexpected_key::countTDB_DATA::dptrTDB_DATA::dsizelenlock_path()packet_struct::packet_typeunexpected_key::packet_typetdb_open_log()tdb_store()tdbdpacket_struct::timestampunexpected_key::timestamp.

参照元 find_subnet_for_nmb_packet()process_dgram().

00041 {
00042         static int count;
00043         TDB_DATA kbuf, dbuf;
00044         struct unexpected_key key;
00045         char buf[1024];
00046         int len=0;
00047 
00048         if (!tdbd) {
00049                 tdbd = tdb_open_log(lock_path("unexpected.tdb"), 0, 
00050                                TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
00051                                O_RDWR | O_CREAT, 0644);
00052                 if (!tdbd) {
00053                         DEBUG(0,("Failed to open unexpected.tdb\n"));
00054                         return;
00055                 }
00056         }
00057 
00058         memset(buf,'\0',sizeof(buf));
00059         
00060         len = build_packet(buf, p);
00061 
00062         ZERO_STRUCT(key);       /* needed for potential alignment */
00063 
00064         key.packet_type = p->packet_type;
00065         key.timestamp = p->timestamp;
00066         key.count = count++;
00067 
00068         kbuf.dptr = (char *)&key;
00069         kbuf.dsize = sizeof(key);
00070         dbuf.dptr = buf;
00071         dbuf.dsize = len;
00072 
00073         tdb_store(tdbd, kbuf, dbuf, TDB_REPLACE);
00074 }

static int traverse_fn ( TDB_CONTEXT ttdb,
TDB_DATA  kbuf,
TDB_DATA  dbuf,
void *  state 
) [static]

unexpected.c82 行で定義されています。

参照先 TDB_DATA::dptrTDB_DATA::dsizelastttdb_delete().

00083 {
00084         struct unexpected_key key;
00085 
00086         if (kbuf.dsize != sizeof(key)) {
00087                 tdb_delete(ttdb, kbuf);
00088         }
00089 
00090         memcpy(&key, kbuf.dptr, sizeof(key));
00091 
00092         if (lastt - key.timestamp > NMBD_UNEXPECTED_TIMEOUT) {
00093                 tdb_delete(ttdb, kbuf);
00094         }
00095 
00096         return 0;
00097 }

void clear_unexpected ( time_t  t  ) 

unexpected.c103 行で定義されています。

参照先 lastttdb_traverse()tdbdtraverse_fn().

参照元 process().

00104 {
00105         if (!tdbd) return;
00106 
00107         if ((lastt != 0) && (t < lastt + NMBD_UNEXPECTED_TIMEOUT))
00108                 return;
00109 
00110         lastt = t;
00111 
00112         tdb_traverse(tdbd, traverse_fn, NULL);
00113 }

static int traverse_match ( TDB_CONTEXT ttdb,
TDB_DATA  kbuf,
TDB_DATA  dbuf,
void *  state 
) [static]

unexpected.c124 行で定義されています。

参照先 DGRAM_PACKETTDB_DATA::dptrTDB_DATA::dsizefree_packet()nmb_packet::headermatch_idmatch_mailslot_name()match_namematch_typematched_packetnmb_packet::name_trn_idpacket_struct::nmbNMB_PACKETpacket_struct::packetparse_packet().

参照元 receive_unexpected().

00125 {
00126         struct unexpected_key key;
00127         struct packet_struct *p;
00128 
00129         if (kbuf.dsize != sizeof(key)) {
00130                 return 0;
00131         }
00132 
00133         memcpy(&key, kbuf.dptr, sizeof(key));
00134 
00135         if (key.packet_type != match_type) return 0;
00136 
00137         p = parse_packet(dbuf.dptr, dbuf.dsize, match_type);
00138 
00139         if ((match_type == NMB_PACKET && 
00140              p->packet.nmb.header.name_trn_id == match_id) ||
00141             (match_type == DGRAM_PACKET && 
00142              match_mailslot_name(p, match_name))) {
00143                 matched_packet = p;
00144                 return -1;
00145         }
00146 
00147         free_packet(p);
00148 
00149         return 0;
00150 }

struct packet_struct* receive_unexpected ( enum packet_type  packet_type,
int  id,
const char *  mailslot_name 
)

unexpected.c156 行で定義されています。

参照先 lock_path()match_idmatch_namematch_typematched_packettdb_close()tdb_open_log()tdb_traverse()traverse_match().

参照元 cli_get_response()receive_dgram_packet()receive_getdc_response()receive_nmb_packet().

00158 {
00159         TDB_CONTEXT *tdb2;
00160 
00161         tdb2 = tdb_open_log(lock_path("unexpected.tdb"), 0, 0, O_RDONLY, 0);
00162         if (!tdb2) return NULL;
00163 
00164         matched_packet = NULL;
00165         match_id = id;
00166         match_type = packet_type;
00167         match_name = mailslot_name;
00168 
00169         tdb_traverse(tdb2, traverse_match, NULL);
00170 
00171         tdb_close(tdb2);
00172 
00173         return matched_packet;
00174 }


変数

TDB_CONTEXT* tdbd = NULL [static]

unexpected.c24 行で定義されています。

参照元 clear_unexpected()unexpected_packet().

time_t lastt [static]

unexpected.c77 行で定義されています。

参照元 clear_unexpected()reload_interfaces()traverse_fn().

struct packet_struct* matched_packet [static]

unexpected.c116 行で定義されています。

参照元 receive_unexpected()traverse_match().

int match_id [static]

unexpected.c117 行で定義されています。

参照元 receive_unexpected()traverse_match().

enum packet_type match_type [static]

unexpected.c118 行で定義されています。

参照元 receive_unexpected()traverse_match().

const char* match_name [static]

unexpected.c119 行で定義されています。

参照元 receive_unexpected()traverse_match().


Sambaに対してSat Aug 29 21:23:50 2009に生成されました。  doxygen 1.4.7