parse_net.c
来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,161 行 · 第 1/5 页
C
2,161 行
/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Jean Fran鏾is Micouleau 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include "includes.h"#undef DBGC_CLASS#define DBGC_CLASS DBGC_RPC_PARSE/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth){ if (neg == NULL) return False; prs_debug(ps, depth, desc, "net_io_neg_flags"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("neg_flags", ps, depth, &neg->neg_flags)) return False; return True;}/******************************************************************* Inits a NETLOGON_INFO_3 structure.********************************************************************/static void init_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts){ info->flags = flags; info->logon_attempts = logon_attempts; info->reserved_1 = 0x0; info->reserved_2 = 0x0; info->reserved_3 = 0x0; info->reserved_4 = 0x0; info->reserved_5 = 0x0;}/******************************************************************* Reads or writes a NETLOGON_INFO_3 structure.********************************************************************/static BOOL net_io_netinfo_3(const char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth){ if (info == NULL) return False; prs_debug(ps, depth, desc, "net_io_netinfo_3"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("flags ", ps, depth, &info->flags)) return False; if(!prs_uint32("logon_attempts", ps, depth, &info->logon_attempts)) return False; if(!prs_uint32("reserved_1 ", ps, depth, &info->reserved_1)) return False; if(!prs_uint32("reserved_2 ", ps, depth, &info->reserved_2)) return False; if(!prs_uint32("reserved_3 ", ps, depth, &info->reserved_3)) return False; if(!prs_uint32("reserved_4 ", ps, depth, &info->reserved_4)) return False; if(!prs_uint32("reserved_5 ", ps, depth, &info->reserved_5)) return False; return True;}/******************************************************************* Inits a NETLOGON_INFO_1 structure.********************************************************************/static void init_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status){ info->flags = flags; info->pdc_status = pdc_status;}/******************************************************************* Reads or writes a NETLOGON_INFO_1 structure.********************************************************************/static BOOL net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth){ if (info == NULL) return False; prs_debug(ps, depth, desc, "net_io_netinfo_1"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("flags ", ps, depth, &info->flags)) return False; if(!prs_uint32("pdc_status", ps, depth, &info->pdc_status)) return False; return True;}/******************************************************************* Inits a NETLOGON_INFO_2 structure.********************************************************************/static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status, uint32 tc_status, const char *trusted_dc_name){ info->flags = flags; info->pdc_status = pdc_status; info->ptr_trusted_dc_name = 1; info->tc_status = tc_status; if (trusted_dc_name != NULL) init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, UNI_STR_TERMINATE); else init_unistr2(&info->uni_trusted_dc_name, "", UNI_STR_TERMINATE);}/******************************************************************* Reads or writes a NETLOGON_INFO_2 structure.********************************************************************/static BOOL net_io_netinfo_2(const char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth){ if (info == NULL) return False; prs_debug(ps, depth, desc, "net_io_netinfo_2"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("flags ", ps, depth, &info->flags)) return False; if(!prs_uint32("pdc_status ", ps, depth, &info->pdc_status)) return False; if(!prs_uint32("ptr_trusted_dc_name", ps, depth, &info->ptr_trusted_dc_name)) return False; if(!prs_uint32("tc_status ", ps, depth, &info->tc_status)) return False; if (info->ptr_trusted_dc_name != 0) { if(!smb_io_unistr2("unistr2", &info->uni_trusted_dc_name, info->ptr_trusted_dc_name, ps, depth)) return False; } if(!prs_align(ps)) return False; return True;}static BOOL net_io_ctrl_data_info_5(const char *desc, CTRL_DATA_INFO_5 *info, prs_struct *ps, int depth){ if (info == NULL) return False; prs_debug(ps, depth, desc, "net_io_ctrl_data_info_5"); depth++; if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) ) return False; if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain)) return False; if ( info->ptr_domain ) { if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth)) return False; } return True;}static BOOL net_io_ctrl_data_info_6(const char *desc, CTRL_DATA_INFO_6 *info, prs_struct *ps, int depth){ if (info == NULL) return False; prs_debug(ps, depth, desc, "net_io_ctrl_data_info_6"); depth++; if ( !prs_uint32( "function_code", ps, depth, &info->function_code ) ) return False; if(!prs_uint32("ptr_domain", ps, depth, &info->ptr_domain)) return False; if ( info->ptr_domain ) { if(!smb_io_unistr2("domain", &info->domain, info->ptr_domain, ps, depth)) return False; } return True;}/******************************************************************* Reads or writes an NET_Q_LOGON_CTRL2 structure.********************************************************************/BOOL net_io_q_logon_ctrl2(const char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth){ if (q_l == NULL) return False; prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) return False; if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) return False; if(!prs_align(ps)) return False; if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) return False; if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) return False; switch ( q_l->function_code ) { case NETLOGON_CONTROL_REDISCOVER: if ( !net_io_ctrl_data_info_5( "ctrl_data_info5", &q_l->info.info5, ps, depth) ) return False; break; case NETLOGON_CONTROL_TC_QUERY: if ( !net_io_ctrl_data_info_6( "ctrl_data_info6", &q_l->info.info6, ps, depth) ) return False; break; default: DEBUG(0,("net_io_q_logon_ctrl2: unknown function_code [%d]\n", q_l->function_code)); return False; } return True;}/******************************************************************* Inits an NET_Q_LOGON_CTRL2 structure.********************************************************************/void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name, uint32 query_level){ DEBUG(5,("init_q_logon_ctrl2\n")); q_l->function_code = 0x01; q_l->query_level = query_level; init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);}/******************************************************************* Inits an NET_R_LOGON_CTRL2 structure.********************************************************************/void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, uint32 flags, uint32 pdc_status, uint32 logon_attempts, uint32 tc_status, const char *trusted_domain_name){ r_l->switch_value = query_level; switch (query_level) { case 1: r_l->ptr = 1; /* undocumented pointer */ init_netinfo_1(&r_l->logon.info1, flags, pdc_status); r_l->status = NT_STATUS_OK; break; case 2: r_l->ptr = 1; /* undocumented pointer */ init_netinfo_2(&r_l->logon.info2, flags, pdc_status, tc_status, trusted_domain_name); r_l->status = NT_STATUS_OK; break; case 3: r_l->ptr = 1; /* undocumented pointer */ init_netinfo_3(&r_l->logon.info3, flags, logon_attempts); r_l->status = NT_STATUS_OK; break; default: DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n", r_l->switch_value)); r_l->ptr = 0; /* undocumented pointer */ /* take a guess at an error code... */ r_l->status = NT_STATUS_INVALID_INFO_CLASS; break; }}/******************************************************************* Reads or writes an NET_R_LOGON_CTRL2 structure.********************************************************************/BOOL net_io_r_logon_ctrl2(const char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth){ if (r_l == NULL) return False; prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2"); depth++; if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) return False; if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) return False; if (r_l->ptr != 0) { switch (r_l->switch_value) { case 1: if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) return False; break; case 2: if(!net_io_netinfo_2("", &r_l->logon.info2, ps, depth)) return False; break; case 3: if(!net_io_netinfo_3("", &r_l->logon.info3, ps, depth)) return False; break; default: DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n", r_l->switch_value)); break; } } if(!prs_ntstatus("status ", ps, depth, &r_l->status)) return False; return True;}/******************************************************************* Reads or writes an NET_Q_LOGON_CTRL structure.********************************************************************/BOOL net_io_q_logon_ctrl(const char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "net_io_q_logon_ctrl"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) return False; if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) return False; if(!prs_align(ps)) return False; if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) return False; if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) return False; return True;}/******************************************************************* Inits an NET_Q_LOGON_CTRL structure.********************************************************************/void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name, uint32 query_level){ DEBUG(5,("init_q_logon_ctrl\n")); q_l->function_code = 0x01; /* ??? */ q_l->query_level = query_level; init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);}/******************************************************************* Inits an NET_R_LOGON_CTRL structure.********************************************************************/void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level, uint32 flags, uint32 pdc_status){ DEBUG(5,("init_r_logon_ctrl\n")); r_l->switch_value = query_level; /* should only be 0x1 */ switch (query_level) { case 1: r_l->ptr = 1; /* undocumented pointer */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?