Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libsmb/nmblib.c

    r596 r745  
    2121
    2222#include "includes.h"
     23#include "libsmb/nmblib.h"
    2324
    2425static const struct opcode_names {
     
    726727}
    727728
     729int packet_trn_id(struct packet_struct *p)
     730{
     731        int result;
     732        switch (p->packet_type) {
     733        case NMB_PACKET:
     734                result = p->packet.nmb.header.name_trn_id;
     735                break;
     736        case DGRAM_PACKET:
     737                result = p->packet.dgram.header.dgm_id;
     738                break;
     739        default:
     740                result = -1;
     741        }
     742        return result;
     743}
     744
    728745/*******************************************************************
    729746 Parse a packet buffer into a packet structure.
     
    10851102
    10861103/****************************************************************************
    1087  Receive a packet with timeout on a open UDP filedescriptor.
    1088  The timeout is in milliseconds
    1089 ***************************************************************************/
    1090 
    1091 struct packet_struct *receive_packet(int fd,enum packet_type type,int t)
    1092 {
    1093         fd_set fds;
    1094         struct timeval timeout;
    1095         int ret;
    1096 
    1097         if (fd < 0 || fd >= FD_SETSIZE) {
    1098                 errno = EBADF;
    1099                 return NULL;
    1100         }
    1101 
    1102         FD_ZERO(&fds);
    1103         FD_SET(fd,&fds);
    1104         timeout.tv_sec = t/1000;
    1105         timeout.tv_usec = 1000*(t%1000);
    1106 
    1107         if ((ret = sys_select_intr(fd+1,&fds,NULL,NULL,&timeout)) == -1) {
    1108                 /* errno should be EBADF or EINVAL. */
    1109                 DEBUG(0,("select returned -1, errno = %s (%d)\n",
    1110                                         strerror(errno), errno));
    1111                 return NULL;
    1112         }
    1113 
    1114         if (ret == 0) /* timeout */
    1115                 return NULL;
    1116 
    1117         if (FD_ISSET(fd,&fds))
    1118                 return(read_packet(fd,type));
    1119 
    1120         return(NULL);
    1121 }
    1122 
    1123 /****************************************************************************
    1124  Receive a UDP/137 packet either via UDP or from the unexpected packet
    1125  queue. The packet must be a reply packet and have the specified trn_id.
    1126  The timeout is in milliseconds.
    1127 ***************************************************************************/
    1128 
    1129 struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id)
    1130 {
    1131         struct packet_struct *p;
    1132 
    1133         p = receive_packet(fd, NMB_PACKET, t);
    1134 
    1135         if (p && p->packet.nmb.header.response &&
    1136                         p->packet.nmb.header.name_trn_id == trn_id) {
    1137                 return p;
    1138         }
    1139         if (p)
    1140                 free_packet(p);
    1141 
    1142         /* try the unexpected packet queue */
    1143         return receive_unexpected(NMB_PACKET, trn_id, NULL);
    1144 }
    1145 
    1146 /****************************************************************************
    11471104 Receive a UDP/138 packet either via UDP or from the unexpected packet
    11481105 queue. The packet must be a reply packet and have the specified mailslot name
    11491106 The timeout is in milliseconds.
    11501107***************************************************************************/
    1151 
    1152 struct packet_struct *receive_dgram_packet(int fd, int t,
    1153                 const char *mailslot_name)
    1154 {
    1155         struct packet_struct *p;
    1156 
    1157         p = receive_packet(fd, DGRAM_PACKET, t);
    1158 
    1159         if (p && match_mailslot_name(p, mailslot_name)) {
    1160                 return p;
    1161         }
    1162         if (p)
    1163                 free_packet(p);
    1164 
    1165         /* try the unexpected packet queue */
    1166         return receive_unexpected(DGRAM_PACKET, 0, mailslot_name);
    1167 }
    11681108
    11691109/****************************************************************************
     
    12381178        putip(sort_ip, (char *)&ip);
    12391179
     1180        /* TODO:
     1181           this can't use TYPESAFE_QSORT() as the types are wrong.
     1182           It should be fixed to use a real type instead of char*
     1183        */
    12401184        qsort(data, n, 6, QSORT_CAST name_query_comp);
    12411185}
Note: See TracChangeset for help on using the changeset viewer.