Changeset 745 for trunk/server/source3/libsmb/nmblib.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/nmblib.c
r596 r745 21 21 22 22 #include "includes.h" 23 #include "libsmb/nmblib.h" 23 24 24 25 static const struct opcode_names { … … 726 727 } 727 728 729 int 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 728 745 /******************************************************************* 729 746 Parse a packet buffer into a packet structure. … … 1085 1102 1086 1103 /**************************************************************************** 1087 Receive a packet with timeout on a open UDP filedescriptor.1088 The timeout is in milliseconds1089 ***************************************************************************/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 packet1125 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 /****************************************************************************1147 1104 Receive a UDP/138 packet either via UDP or from the unexpected packet 1148 1105 queue. The packet must be a reply packet and have the specified mailslot name 1149 1106 The timeout is in milliseconds. 1150 1107 ***************************************************************************/ 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 }1168 1108 1169 1109 /**************************************************************************** … … 1238 1178 putip(sort_ip, (char *)&ip); 1239 1179 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 */ 1240 1184 qsort(data, n, 6, QSORT_CAST name_query_comp); 1241 1185 }
Note:
See TracChangeset
for help on using the changeset viewer.