当前位置:首页 » 操作系统 » linuxiff

linuxiff

发布时间: 2022-06-10 10:20:35

1. 如何伪造tcp数据包,并进行正确的校验的例子演示及源码linux gc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
下面的程序是在linux下进行tcp伪造的一个例子:涉及原始套接字和tcp的校验算法

/************************tcp_pseudo.c********************/
/** Author :cbchen. */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define INTERFACE "eth0"
#define IP ""
/*Prototype area*/
int Open_Packet_Socket();
int Open_Raw_Socket();
int Set_Promisc(char *interface, int sock);
void send_tcp_ack(int sockfd,struct sockaddr_in *addr);
unsigned short check_sum(unsigned short *addr,int len);
struct ip *iprecv;
struct tcphdr *tcprecv;
struct sockaddr_in addr;

int main()
{
int sockfd,sendfd,bytes_recieved;

char buffer[1518];
u_char *buf2;
char saddr[20],daddr[20];

sockfd=Open_Packet_Socket();
sendfd=Open_Raw_Socket();
//printf("sockfd:%d/tsendfd:%d/n",sockfd,sendfd);

int on=1;
/******** 设置IP数据包格式,告诉系统内核模块IP数据包由我们自己来填写 ***/
setsockopt(sendfd,IPPROTO_IP,IP_HDRINCL,&on,sizeof(on));
Set_Promisc(INTERFACE, sockfd);
int count=1;

while(1)
{

bytes_recieved = recvfrom(sockfd, buffer, 1518, 0, NULL, NULL);

buf2=buffer;
buf2+=14;
iprecv=(struct ip *)buf2;
//iprecv+=sizeof(struct ethhdr*);
/*See if this is a TCP packet*/
if(iprecv->ip_v == 4&iprecv->ip_p == 6) {
printf("---------------------------Number %d packet-----------------------------------------------/n",count);
count++;
printf("/nBytes received ::: %5d/n",bytes_recieved);
printf("ip version:%u/n",iprecv->ip_v);

printf("IP包头解码:/n");
printf("Source ip:%s/t",inet_ntoa(iprecv->ip_src));
printf("Dest ip:%s/t",inet_ntoa(iprecv->ip_dst));
printf("proto:%u/n",iprecv->ip_p);
buf2+=iprecv->ip_hl<<2;
printf("TCP包头解码:/n");
tcprecv = (struct tcphdr*)buf2;
//tcprecv = (struct tcphdr *)(buffer + (iprecv->ip_hl<<2));
printf("Source port :::%d/n",ntohs(tcprecv->source));
printf("Dest port :::%d/n",ntohs(tcprecv->dest));
printf("seq num:%u/n",ntohl(tcprecv->seq));
printf("ack num:%u/n",ntohl(tcprecv->ack_seq));
printf("urg:%x/tack:%x/tpsh:%x/trst:%x/tsyn:%x/tfin:%x/n",tcprecv->urg,tcprecv->ack,tcprecv->psh,tcprecv->rst,tcprecv->syn,tcprecv->fin);
bzero(&addr,sizeof(struct sockaddr_in));
addr.sin_family=AF_INET;
//addr2.sin_port=htons(thdr->source);
addr.sin_port=tcprecv->source;
//addr2.sin_addr=iphdr->ip_src;
addr.sin_addr=iprecv->ip_src;

/********* 发送阻隔包了!!!! ****/
if(tcprecv->syn==1&tcprecv->urg!=1&tcprecv->ack!=1&tcprecv->psh!=1&tcprecv->rst!=1&tcprecv->fin!=1)
{
//send_tcp_ack(sendfd,&addr);
//printf("It's a syn pocket!/n");
}
}
}
close(sockfd);
close(sendfd);
}
//end main

/******* 发送阻隔包的实现 *********/
/*
void send_tcp_ack(int sockfd,struct sockaddr_in *addr)
{
struct send_tcp
{
struct iphdr ip;
struct tcphdr tcp;
} send_tcp;

struct pseudo_header
{
unsigned int source_address;
unsigned int dest_address;
unsigned char placeholder;
unsigned char protocol;
unsigned short tcp_length;
struct tcphdr tcp;
} pseudo_header;

int tcp_socket;
struct sockaddr_in sin;
int sinlen;

// form ip packet
send_tcp.ip.ihl = 5;
send_tcp.ip.version = 4;
send_tcp.ip.tos = 0;
send_tcp.ip.tot_len = htons(40);
send_tcp.ip.frag_off = 0;
send_tcp.ip.ttl = 64;
send_tcp.ip.protocol = IPPROTO_TCP;
send_tcp.ip.check = 0;
send_tcp.ip.saddr = iprecv->ip_dst.s_addr;
send_tcp.ip.daddr = addr->sin_addr.s_addr;

// form tcp packet
send_tcp.tcp.dest = addr->sin_port;
send_tcp.tcp.source = tcprecv->dest;
send_tcp.tcp.ack_seq = htonl(ntohl(tcprecv->seq)+0x01);
send_tcp.tcp.res1 = 0;
send_tcp.tcp.doff = 5;
send_tcp.tcp.fin = 0;
send_tcp.tcp.syn = 1;
send_tcp.tcp.rst = 0;
send_tcp.tcp.psh = 0;
send_tcp.tcp.ack = 1;
send_tcp.tcp.urg = 0;
send_tcp.tcp.res2 = 0;
send_tcp.tcp.window = htons(512);
send_tcp.tcp.check = 0;
send_tcp.tcp.urg_ptr = 0;
send_tcp.tcp.seq = tcprecv->seq;

// set fields that need to be changed
//send_tcp.tcp.source++;
send_tcp.ip.id = 0 ;
//send_tcp.tcp.seq++;
send_tcp.tcp.check = 0;
send_tcp.ip.check = 0;

// calculate the ip checksum
send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);

// set the pseudo header fields
pseudo_header.source_address = send_tcp.ip.saddr;
pseudo_header.dest_address = send_tcp.ip.daddr;
pseudo_header.placeholder = 0;
pseudo_header.protocol = IPPROTO_TCP;
pseudo_header.tcp_length = htons(20);
b((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32);
sinlen = sizeof(sin);
int count;
for(count=0;count<2;count++){
if(sendto(sockfd, &send_tcp, 40, 0, (struct sockaddr *)addr,sizeof(struct sockaddr))<0)
{
printf("sendto error!/n");
}
else
{
printf("send packet ok!/n");
}

}
*/

/* 下面是首部校验和的算法 */
unsigned short in_cksum(unsigned short *addr, int len) /* function is from ping.c */
{
register int nleft = len;
register u_short *w = addr;
register int sum = 0;
u_short answer =0;

while (nleft > 1)
{
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
{
*(u_char *)(&answer) = *(u_char *)w;
sum += answer;
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
answer = ~sum;
return(answer);
}
int Open_Packet_Socket()
{
int sock;
sock=socket(AF_INET,SOCK_PACKET,htons(ETH_P_ALL));
if (sock==-1)
{
perror("socket");
exit(errno);
}
printf("sockfd:%d/n",sock);
return(sock);
}
int Open_Raw_Socket()
{
int sock;
sock=socket(AF_INET,SOCK_RAW,IPPROTO_TCP);
if (sock==-1)
{
perror("socket");
exit(errno);
}
printf("sendfd:%d/n",sock);
return(sock);
}

int Set_Promisc(char *interface, int sockfd )
{
struct ifreq ifr;
strncpy(ifr.ifr_name,interface,strnlen(interface)+1);
if (ioctl(sockfd,SIOCGIFFLAGS,&ifr)==-1)
{
perror("ioctl1");
exit(errno);
}
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl(sockfd,SIOCSIFFLAGS,&ifr))
{
perror("ioctl2");
exit(errno);
}

// printf("Setting interface ::: %s ::: to promisc...ok..../n", interface);
return(1);
}

2. 混杂模式的linux下通过C设置混杂模式(以eth0举例)

char *eth_name = eth0; //对网卡eth0进行混杂设置
struct ifreq ethreq; //网络接口结构
strncpy(ethreq.ifr_name, eth_name, IFNAMSIZ); //指定网卡名称if(-1 == ioctl(sock_raw_fd, SIOCGIFFLAGS, &ethreq)) //获取网络接口{perror(ioctl);close(sock_raw_fd);exit(-1);}
/*此处用 | 是因为必须在保留原来设置的情况下,在标志位中加入“混杂”方式*/ ethreq.ifr_flags |= IFF_PROMISC;if(-1 == ioctl(sock_raw_fd, SIOCSIFFLAGS, &ethreq)) //将标志位设置写入{perror(ioctl);close(sock_raw_fd);exit(-1);}

3. linux下里面如何获取网卡的实时网速

#include <time.h>
#include "tspeed.h"
int main ()
{
struct if_speed ndev;
int ret = 0;
bzero(&ndev,sizeof(ndev));
sprintf(ndev.ifs_name,"eth0");
ndev.ifs_us = 100000;
printf("Get %s Speed",ndev.ifs_name);
#if 1
ret = get_if_speed(&ndev);
if(ret < 0)
printf("[Fail]\n");
else
printf("[OK]\n");
float ispeed ,ospeed;
while(1){
time_t *timep = malloc(sizeof(*timep));
time(timep);
char *s = ctime(timep);
ispeed = ndev.ifs_ispeed * 1.0/(ndev.ifs_us/1000 * 0.001);
ospeed = ndev.ifs_ospeed * 1.0/(ndev.ifs_us/1000 * 0.001);
#if 0
printf("%s: Up Speed: %fMB/s || Down Speed: %fMB/s\r",
ndev.ifs_name,ispeed/(1024.0*1024.0),ospeed/(1024.0*1024.0));
#endif
sleep(3);
#if 1
printf("*****************************************************\n");
printf("*****************************************\n");
printf("***************************\n");
printf("*************\n");
printf("Time is %s || Down Speed: %fKB/s\n",s,ospeed/(1024.0));
#endif
get_if_speed(&ndev);
}
#endif
return 0;
} /* ----- End of main() ----- */
----------------------------------------------------------------------------
#include "tspeed.h"
int get_if_dbytes(struct if_info* ndev)
{
assert(ndev);
struct ifaddrs *ifa_list = NULL;
struct ifaddrs *ifa = NULL;
struct if_data *ifd = NULL;
int ret = 0;
ret = getifaddrs(&ifa_list);
if(ret < 0) {
perror("Get Interface Address Fail:");
goto end;
}
for(ifa=ifa_list; ifa; ifa=ifa->ifa_next){
if(!(ifa->ifa_flags & IFF_UP) && !(ifa->ifa_flags & IFF_RUNNING))
continue;
if(ifa->ifa_data == 0)
continue;
ret = strcmp(ifa->ifa_name,ndev->ifi_name);
if(ret == 0){
ifd = (struct if_data *)ifa->ifa_data;
ndev->ifi_ibytes = ifd->ifi_ibytes;
ndev->ifi_obytes = ifd->ifi_obytes;
break;
}
}
freeifaddrs(ifa_list);
end:
return (ret ? -1 : 0);
}
int get_if_speed(struct if_speed *ndev)
{
assert(ndev);
struct if_info *p1=NULL,*p2=NULL;
p1 = (struct if_info *)malloc(sizeof(struct if_info));
p2 = (struct if_info *)malloc(sizeof(struct if_info));
bzero(p1,sizeof(struct if_info));
bzero(p2,sizeof(struct if_info));
strncpy(p1->ifi_name,ndev->ifs_name,strlen(ndev->ifs_name));
strncpy(p2->ifi_name,ndev->ifs_name,strlen(ndev->ifs_name));
int ret = 0;
ret = get_if_dbytes(p1);
if(ret < 0) goto end;
usleep(ndev->ifs_us);
ret = get_if_dbytes(p2);
if(ret < 0) goto end;
ndev->ifs_ispeed = p2->ifi_ibytes - p1->ifi_ibytes;
ndev->ifs_ospeed = p2->ifi_obytes - p1->ifi_obytes;
end:
free(p1);
free(p2);
return 0;
}
------------------------------------------
#ifndef __TSPEED_H__
#define __TSPEED_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <error.h>
#include <ifaddrs.h>
#include <net/if.h> /* for ifconf */
#include <linux/sockios.h> /* for net status mask */
#include <netinet/in.h> /* for sockaddr_in */
#include <sys/socket.h>
#include <sys/ioctl.h>
/* For "open" function */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
struct if_data
{
/* generic interface information */
u_long ifi_opackets; /* packets sent on interface */
u_long ifi_ipackets; /* packets received on interface */
u_long ifi_obytes; /* total number of octets sent */
u_long ifi_ibytes; /* total number of octets received */
};

struct if_info
{
char ifi_name[16];
unsigned long ifi_ibytes;
unsigned long ifi_obytes;
};
struct if_speed
{
char ifs_name[16];
unsigned long ifs_ispeed;
unsigned long ifs_ospeed;
unsigned long ifs_us;
};
int get_if_dbytes(struct if_info *ndev);
int get_if_speed(struct if_speed *ndev);
#endif
------------------------
纯手打 代码都给你了

4. linux 3.10 kernel bridge 泛洪包会发到包的入口接口上吗

网桥接口的混杂模式取决于三个因素,一个是自身的混杂模式设置;第二是vlan过滤是否开启;最后是处于自动状态(auto_port)的子接口的数量。网桥的混杂模式管理函数br_manage_promisc如下:
void br_manage_promisc(struct net_bridge *br)
{
if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br))
set_all = true;

list_for_each_entry(p, &br->port_list, list) {
if (set_all) {
br_port_set_promisc(p);
} else {
if (br->auto_cnt == 0 ||
(br->auto_cnt == 1 && br_auto_port(p)))
br_port_clear_promisc(p);
else
br_port_set_promisc(p);
}
}
}
混杂模式设置
如下通过命令设置网桥br_2为混杂模式,此时,所有网桥子接口都将处于混杂模式(eth1与eth2 promiscuity mode):
ip link add br_2 type bridge
ip link set eth1 master br_2
ip link set eth2 master br_2
通过ip命令设置接口的混杂模式:
ip link set br_2 promisc on
或者ioctl系统调用设置混杂模式:
int set_bridge_promiscuity(void)
{
sockfd = socket(AF_INET, SOCK_DGRAM, 0);

strncpy(ifr.ifr_name, "br_2", IFNAMSIZ);
ioctl(sockfd, SIOCGIFFLAGS, &ifr);

ifr.ifr_flags |= IFF_PROMISC;
ioctl(sockfd, SIOCSIFFLAGS, &ifr);
}
VLAN过滤
如果网桥的VLAN filtering过滤功能没有开启,即使网桥没有设置混杂模式,也需开启所有子接口的混杂模式。
/sys/devices/virtual/net/br_2/bridge/vlan_filtering
自动状态接口AUTO_PORT
内核中对自动状态接口的定义如下,即设置了学习(learning)或者单播泛洪(flood)标志的接口。
#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)
#define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)
可通过bridge或者ip命令设置网桥接口的flood/learning等标志:
bridge link set dev eth1 flood on/off
bridge link set dev eth1 learning on/off
ip link set dev eth1 type bridge_slave flood on/off
ip link set dev eth1 type bridge_slave learning on/off
网桥添加网络设备时,新接口的flags赋值为BR_LEARNING与BR_FLOOD标志,即新接口为自动状态接口。
static struct net_bridge_port *new_nbp(struct net_bridge *br, struct net_device *dev)
{
struct net_bridge_port *p;
p->flags = BR_LEARNING | BR_FLOOD;
}
BR_LEARNING标志,在函数br_handle_frame_finish中判断,用来决定是否使用数据包的源MAC地址更新网桥的FDB转发表。
int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
struct net_bridge_port *p = br_port_get_rcu(skb->dev);
struct net_bridge *br;

br = p->br;
if (p->flags & BR_LEARNING)
br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false);
}
BR_FLOOD标志用来控制是否在接口上泛洪单播数据包,如果没有设置此标志,不能在此接口泛洪单播包。
void br_flood(struct net_bridge *br, struct sk_buff *skb, ...)
{
struct net_bridge_port *p;

list_for_each_entry_rcu(p, &br->port_list, list) {
switch (pkt_type) {
case BR_PKT_UNICAST:
if (!(p->flags & BR_FLOOD))
continue;
break;
}
网桥结构体中保存了自动状态接口的数量auto_cnt,在向网桥添加接口或者删除接口的时候,调用nbp_update_port_count更新自动状态接口的数量。通过遍历网桥的接口列表,获取自动接口数量。
static void nbp_update_port_count(struct net_bridge *br)
{
struct net_bridge_port *p;
u32 cnt = 0;

list_for_each_entry(p, &br->port_list, list) {
if (br_auto_port(p))
cnt++;
}
if (br->auto_cnt != cnt) {
br->auto_cnt = cnt;
br_manage_promisc(br);
}
}
所谓非自动接口,即此接口不自动学习数据包的源MAC地址,或者不泛洪单播包。对于此类接口,要正常转发报文,必须静态指定其在FDB转发表中的转发表项。由上文br_manage_promisc函数中的条件判断可知,当网桥下都是非自动接口时(auto_cnt=0),关闭混杂模式,因为此时所有接口都已经配置好了转发表项,不需要混杂模式。当只有一个接口时自动接口的时候,从这个接口接收到的数据包无非是要转发到系统剩余的其它接口,而其它接口都是非自动的,这就反向决定了此自动接口的转发路径也被确定下了,此时也不需要混杂模式。
所以当自动接口大于1时,开启混杂模式。
更多Linux信息可参考《Linux就该这么学》

5. 我在虚拟机下安装 linux 出现错误,安装不了,出现以下错误!怎么解决啊!

它的安装说是就是./setup
不过它说unix下的
我在freebsd也试了一下,还是不行
应该是脚本来的吧
#!/bin/sh -f
#=============================================================
# MODIFICATIONS
# ---------------------------------------------------------
# 06-Oct-97 $$1 JJE Created.
# 28-Oct-97 $$2 JJE Use -dirs
# 05-Dec-97 $$3 JJE Remove -vrdirs, set LC_NUMERIC to C
# 22-Dec-97 $$4 JJE Check DISPLAY
# 05-Jan-98 $$5 JJE ignore
# 13-Jan-98 $$6 JJE Use delta lib
# 22-Jan-98 $$7 JJE Add . to path on sgi
# 23-Jan-98 $$8 JJE Add startup messages
# 27-Jan-98 $$9 JJE Add cr
# 31-Jan-98 $$10 JJE Don't echo argv
# 23-Feb-98 $$11 ZRL Added remote install
# 06-Apr-98 $$12 JJE Add sgi_mips4
# 22-Jun-98 $$13 ZRL removed galaxy library
# 29-Jun-98 ##14 ZRL use galaxy library only on sgi_elf2
# 11-Aug-98 $$14 JJE Fix remote install for mips4
# 22-Oct-98 $$15 TWH Fixed remote install
# 11-Nov-98 TWH Fixed cleanup
# 20-Nov-98 $$16 TWH Fixed Trusted login check for Sun
# 08-Sep-99 $$17 JJE Migrate to new installer
# 20-Oct-99 $$18 MYA Add DPS_DIRECTORY
# 07-Aug-00 TWH Check if hpux11_pa32 exists
# 22-Aug-00 $$19 TWH rewritten to /bin/sh for multicd
# 18-Sep-00 $$20 TWH support non \c echo; -multicd iff using redirect
# 09-Oct-00 $$21 TWH Fix command-line args; fix PROSETUP_EXE bug
# 31-Oct-00 $$22 TWH Fix for $0 == "setup"
# 17-Jan-01 $$23 TWH always run sun4_solaris instead of _64 this script
# 16-May-01 $$24 TWH always run hpux11_pa32 instead of hpux_pa64
# 13-Jun-02 $$25 JJE Support -64 arg
# 16-Jul-02 $$26 TWH Set TMP & TEMP if not set
# 20-Aug-02 $$27 TWH Fix #26
# 26-Aug-02 $$28 TWH Another fix for #26
#=============================================================

rundir=`pwd`
fullscrname=$0
# :t
scrname=`echo $fullscrname | awk -F"/" '{ print $NF}'`
# :h
fullscrpath=`echo $fullscrname | awk -F"/" '{ ORS="/"} { n=split($0,A)} { for (i = 1; i < n; i++) print A[i] }'`
if [ "$fullscrpath" = "" ]
then
fullscrpath=$0
else
fullscrpath=`echo $fullscrpath | awk '{ n=length($0)} { n -= 1} { print substr($0,1,n)}'`
fi

if [ "$fullscrpath" = "$fullscrname" ]
then
fullscrpath=`pwd`
else
cd $fullscrpath
fullscrpath=`pwd`
fi

echostr=`echo "test \c"`
if [ "$echostr" = "test \c" ]
then
alt_echo=true
fi

bit_mode_64=false
other_args=""
i=1
while [ "$i" -le $# ]
do
if [ "$1" = "-display" ]
then
shift
echo "setting DISPLAY to: $1"
DISPLAY="$1"
export DISPLAY
shift
elif [ "$1" = "?" -o "$1" = "-h" -o "$1" = "-help" ]
then
echo ""
echo "Usage: $scrname [ -display unix:0 ]"
exit 0
elif [ "$1" = "-remote" ]
then
echo ""
echo "Sorry, remote installation is not supported in this release."
exit 1
elif [ "$1" = "-cdrom" ]
then
shift
echo "setting CDROM path to: $1"
fullscrpath="$1"
shift
elif [ "$1" = "-64" ]
then
shift
bit_mode_64=true
else
other_args="$other_args $1"
shift
fi
done

cd $rundir
prodir=$fullscrpath
imagedir=$fullscrpath
getpmtscr="getpmt.csh"

if [ ! -x "$imagedir/$getpmtscr" ]
then
echo ""
echo "ERROR: $imagedir/$getpmtscr - file is missing."
echo " Check the name of the CD mount directory."
exit 1
fi

mctype=`$imagedir/$getpmtscr`
if [ "$mctype" = "UNKNOWN" ]
then
echo ""
echo "ERROR: OS name unknown."
exit 1
fi

test "$TMP"
if [ $? != 0 ]
then
if [ -x "/tmp" ]
then
TMP="/tmp"
export TMP
elif [ -x "/var/tmp" ]
then
TMP="/var/tmp"
export TMP
fi
fi
test "$TEMP"
if [ $? != 0 ]
then
if [ -x "/tmp" ]
then
TEMP="/tmp"
export TEMP
elif [ -x "/var/tmp" ]
then
TEMP="/var/tmp"
export TEMP
fi
fi
test "$DISPLAY"
if [ $? != 0 ]
then
echo ""
echo 'ERROR: The DISPLAY variable is not set - '
echo ""
echo " Options:"
echo " o Press <cr> to set DISPLAY to `hostname`:0.0"
echo " o Type a value to use for the DISPLAY variable"
echo " o Enter 'q' to abort prosetup"
echo " o Specify '-display <host>:0' on the command line"
echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Set it to (`hostname`:0.0): [q to abort] "
else
echo "Set it to (`hostname`:0.0): [q to abort] \c"
fi
read line
if [ "$line" = "q*" -o "$line" = "Q*" ]
then
exit -1
elif [ "$line" = "" ]
then
DISPLAY="`hostname`:0.0"
export DISPLAY
else
DISPLAY="$line"
export DISPLAY
fi
echo ""
echo " DISPLAY has been set to: $DISPLAY"
echo ""
fi

echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Starting PTC.Setup, please wait ..."
else
echo "Starting PTC.Setup, please wait ...\c"
fi

if [ "$mctype" = "sun4_solaris_64" -a "$bit_mode_64" = "false" ]
then
mctype="sun4_solaris"
fi
if [ "$mctype" = "sun4_solaris" ]
then
PATH=$PATH:/usr/ucb
export PATH
fi

if [ "$mctype" = "sgi_elf2" -o "$mctype" = "sgi_mips4" ]
then
PATH=.:$PATH
export PATH
fi
if [ "$mctype" = "hpux_pa64" -a "$bit_mode_64" = "false" ]
then
mctype="hpux11_pa32"
fi
if [ "$mctype" = "hpux11_pa32" ]
then
if [ ! -d "$imagedir/dsrc/$mctype" ]
then
mctype="hp8k"
fi
fi

PTC_CDHOME=$imagedir
export PTC_CDHOME
PS_DIRECTORY=$imagedir/dsrc
export PS_DIRECTORY
DPS_DIRECTORY=$imagedir/dsrc
export DPS_DIRECTORY
PRO_MACHINE_TYPE=$mctype
export PRO_MACHINE_TYPE
LC_NUMERIC=C
export LC_NUMERIC

test "$PROSETUP_EXE"
if [ $? != 0 ]
then
PROSETUP_EXE="$imagedir/dsrc/$mctype/obj/ptcsetup"
elif [ -x "$PROSETUP_EXE" ]
then
echo ""
test "$alt_echo"
if [ $? = 0 ]
then
echo -n "Using $PROSETUP_EXE ..."
else
echo "Using $PROSETUP_EXE ...\c"
fi
($PROSETUP_EXE $other_args ) &
exit 0
fi

if [ ! -x "$PROSETUP_EXE" ]
then
echo ""
echo "ERROR: $PROSETUP_EXE - file is missing."
echo " Check the name of the CD mount directory."
exit 1
fi

REDIRECT_EXE="$imagedir/dsrc/$mctype/obj/redirect"
if [ -x "$REDIRECT_EXE" ]
then
($REDIRECT_EXE $other_args -multicd ) &
else
($PROSETUP_EXE $other_args ) &
fi

echo ""
exit 0

6. 谁知道在linux下的常用后缀名啊

在Linux系统中,可执行文件没有统一的后缀,系统从文件的属性来区分可执行文件和不可执行文件。而gcc则通过后缀来区别输入文件的类别,下面我们来介绍gcc所遵循的部分约定规则。
.c为后缀的文件,c语言源代码文件;
.a为后缀的文件,是由目标文件构成的档案库文件;
.C,.cc或.cxx 为后缀的文件,是C++源代码文件;
.h为后缀的文件,是程序所包含的头文件;
.i 为后缀的文件,是已经预处理过的C源代码文件;
.ii为后缀的文件,是已经预处理过的C++源代码文件;
.m为后缀的文件,是Objective-C源代码文件;
.o为后缀的文件,是编译后的目标文件;
.s为后缀的文件,是汇编语言源代码文件;
.S为后缀的文件,是经过预编译的汇编语言源代码文件。

7. 如何搭建基于Linux系统桌面环境的影音平台

视频、音频的处理加工一直是计算机在多媒体方面的重要应用,传统上是 Unix 工作站的天下。由于 Linux 是 Unix 操作系统的变体,从某种程度上说,它天生适用于图形市场。目前已有一大部分市场被 Linux 工作站所瓜分了。Linux 成为 Unix 系统在个人计算机上的一个代用品,并能用于替代那些较为昂贵的系统。因此,在家中使用 Linux 就能够完成一些工作任务。本文就介绍一下在家里就可以建立的一个基于 Linux 桌面环境的影音工作站。

MainActor 是一个处理视频、音频的优秀软件,具有极好的动画视频格式转换编辑剪接工具,并自带编辑功能 AVI<-->MPG、MPG<-->AVI、动画序列等。它可以用于许多文件格式的互相转换,带很多滤镜,其中支持的文件格式包括 AVI、FLI、FLC、JPEG、MOV、TGA、GIF、MPEG-Ⅰ/Ⅱ等。目前最新的版本可以直接捕捉、处理数码摄像机的信号。

由于处理视频、音频对于计算机的中央处理器、显示系统、存储系统等要求较高,所以应尽量提供一些高性能的硬件系统。下面就以我的硬件配置为例,介绍如何搭建影音平台。硬件配置:中央处理器为 AMD Duron 1.1G,内存为 256MB SDAM ,显示卡为 nVIDIA GeForce2 MX 32MB,声卡为创新 PCI 128 数码版,硬盘为希捷酷鱼三代 20GB(7200转,2MB 缓存)。为了提高工作效率,在搭建基于 Linux 桌面环境的平台时要尽量提供高性能的硬件系统。

软件下载与准备工作

1. 软件下载

MainActor 软件可以在它的主页下载。地址:

2. 系统要求

软件要求内核(Kenerl)至少在 2.4 以上。KDE 2.0,Window System XFree86 4.03,桌面分辨率至少为800×600,桌面颜色至少 16 位增强色。

硬件中央处理器为奔腾Ⅲ450MHz 以上,内存为 128 MB,硬盘空间为 600MB,OSS/Linux 兼容声卡,16MB 显示内存。

3. 准备工作

由于工作时需要使用 zlib、Qt、gtk 及 libpng 函数,因此安装前一定要检查计算机中是否已经含有下列的软件:zlib (zlib-1.1.3-xx以上) 、Qt (Qt-2.0.xx以上)、libpng gtk。可以使 rpm 分别来确认:

rpm -qa | grep gtk

rpm -qa | grep zlib

rpm -qa | grep qt

rpm -qa | grep libpng

检测结果见图 1 所示。

图 7 预览刚生成的新文件

◆ 预览结束后,如果没有问题就单击 “File” 选单的 “Save” 选项,将文件以一个工程方式(Project)保存到一个文件夹中。

Linux 是一个真正的抢占式多任务、多线程、多用户的操作系统,它构建影音平台在成本、技术上都有优势。通过介绍 MainActor 中 mave、maseg 两个主要软件模块的使用,基本上可以在 Linux 桌面环境上建立了一个低成本的影音工作平台。

8. linux 里通过想写一个c语言的文件 ,通过执行文件可以修改ifcfg-eth0中的IPADDR的值

//获取本机IP地址函数

view plain to clipboardprint?
01.QString GetLocalIp()
02.{
03.
04. int sock_get_ip;
05. char ipaddr[50];
06.
07. struct sockaddr_in *sin;
08. struct ifreq ifr_ip;
09.
10. if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
11. {
12. printf("socket create failse...GetLocalIp!\n");
13. return "";
14. }
15.
16. memset(&ifr_ip, 0, sizeof(ifr_ip));
17. strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);
18.
19. if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
20. {
21. return "";
22. }
23. sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
24. strcpy(ipaddr,inet_ntoa(sin->sin_addr));
25.
26. printf("local ip:%s \n",ipaddr);
27. close( sock_get_ip );
28.
29. return QString( ipaddr );
30.}
QString GetLocalIp()
{

int sock_get_ip;
char ipaddr[50];

struct sockaddr_in *sin;
struct ifreq ifr_ip;

if ((sock_get_ip=socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
printf("socket create failse...GetLocalIp!\n");
return "";
}

memset(&ifr_ip, 0, sizeof(ifr_ip));
strncpy(ifr_ip.ifr_name, "eth0", sizeof(ifr_ip.ifr_name) - 1);

if( ioctl( sock_get_ip, SIOCGIFADDR, &ifr_ip) < 0 )
{
return "";
}
sin = (struct sockaddr_in *)&ifr_ip.ifr_addr;
strcpy(ipaddr,inet_ntoa(sin->sin_addr));

printf("local ip:%s \n",ipaddr);
close( sock_get_ip );

return QString( ipaddr );
}

//修改本机IP地址的函数

int SetLocalIp( const char *ipaddr )
{

int sock_set_ip;

struct sockaddr_in sin_set_ip;
struct ifreq ifr_set_ip;

bzero( &ifr_set_ip,sizeof(ifr_set_ip));

if( ipaddr == NULL )
return -1;

if(sock_set_ip = socket( AF_INET, SOCK_STREAM, 0 ) == -1);
{
perror("socket create failse...SetLocalIp!\n");
return -1;
}

memset( &sin_set_ip, 0, sizeof(sin_set_ip));
strncpy(ifr_set_ip.ifr_name, "eth0", sizeof(ifr_set_ip.ifr_name)-1);

sin_set_ip.sin_family = AF_INET;
sin_set_ip.sin_addr.s_addr = inet_addr(ipaddr);
memcpy( &ifr_set_ip.ifr_addr, &sin_set_ip, sizeof(sin_set_ip));

if( ioctl( sock_set_ip, SIOCSIFADDR, &ifr_set_ip) < 0 )
{
perror( "Not setup interface\n");
return -1;
}

//设置激活标志
ifr_set_ip.ifr_flags |= IFF_UP |IFF_RUNNING;

//get the status of the device
if( ioctl( sock_set_ip, SIOCSIFFLAGS, &ifr_set_ip ) < 0 )
{
perror("SIOCSIFFLAGS");
return -1;
}

close( sock_set_ip );
return 0;
}

9. 在Linux下如果要使用接口标志要加什么头文件吗因为我在使用IFF_UP时会出错,说是未定义

头文件一般放在/usr/include目录下,
用grep 'IFF_UP' /usr/include/*.* |less
这个命令查找一下在哪个头文件里面有定义。

10. linux下设置网卡为混合模式中用到的ethreq在那个头文件里面

eth0
标识着网卡设备的ID值,告诉你有几个设备、虚拟的也算

热点内容
java微信公众号开发 发布:2024-11-02 04:35:29 浏览:586
php对象转为数组 发布:2024-11-02 04:33:45 浏览:719
阿里云启动服务器 发布:2024-11-02 04:31:51 浏览:110
数控编译错误802怎么解决 发布:2024-11-02 04:31:42 浏览:320
linux如何安装驱动 发布:2024-11-02 04:30:18 浏览:491
云服务器项目实施方案 发布:2024-11-02 04:26:00 浏览:246
写入存储 发布:2024-11-02 04:20:21 浏览:31
JavaString替换 发布:2024-11-02 04:14:29 浏览:560
百度查询脚本 发布:2024-11-02 04:14:22 浏览:99
阴阳师ios如何登录安卓 发布:2024-11-02 04:03:03 浏览:708